Counterbalancing Images which are presented by pair on the screen, but selected ramdomly

Nowadays I’m creating an experiment about Numerical Cognition. I have a task where my participants must compare area’s sizing, then, I present an image with a specific size in the left side and one more image in the Right side at thew same moment. Psychopy resizes images, so, I have to reestablish values into images components in centimeters. However, the main idea of the experiment is that my stimuli were selected randomly from list of conditions in excel for each imagen that appear side by side. The problem is: how can I keep the sizes while stimuli are selected randomly? I’ve found a code that allows me to randomize two lists, but How can I code the size that every stimulus has while they are selected randomly. I know that Psychopy anchors rows with the next column to present the stimuli, but the code avoids it because I’m randomizing the images columns from excel.

Now, I share you a test for my real experiment. Also, I need to use the following code to establish the trials for the exp, because I have only eight stimuli that must be presented 10 times:

Begin Experiment:

myCount = 0

#Begin Routine:

myCount = myCount + 1
if myCount > 9:
trials.finished = True

Excel Conditions screenshot:


Begin Experiment:

import random, xlrd


in_file = ‘cond.xlsx’

num_items = 12

cur_pos1 = 0
cur_pos2 = 0

#Begin Routine:

inbook = xlrd.open_workbook(in_file)
insheet = inbook.sheet_by_index(0)

pos1 =
pos2 =
Shape_Size_W_pos1 =
Shape_Size_H__pos1 =
Shape_Size_W_pos2 =
Shape_Size_H__pos2 =

for rowx in range (1,num_items+1):

row = insheet.row_values(rowx)




There is a Code into the trial at the end of the Routine:

cur_pos1 = cur_pos2 + 1
cur_pos2 = cur_pos1 + 1


Experiment Files:

cond.xlsx (9.0 KB) images.psyexp (12.5 KB)

Images settings:

Experiment Builder: