How to randomize the presentation of 5 images (a visual scale) on one screen

I am all new to Psychopy and especially coding, and I am trying to figure out a way to randomize the presentation of 5 images on one screen (image1, image2, image3, image4, image5), and I am having some trouble finding some pointers that do just this.

So far I have created the experiment using only builder and a conditions file. The experiment will vary on 1) name of job seeking candidate, 2) descriptions of job, and 3) pay. I have managed to randomize these factors in the builder function. Participants read about a candidate and sees an image of said candidate, then reads a job description. My dependent variable is to ask participants to select one of five images of a job candidate presented on the screen. The images have been morphed in terms of typically masculine traits and so ranges from 1 = least masculine, 5 = most masculine.

Their positions on the screen are:
imageF1 (-0.55, 0.1)
imageF2 (0, 0.1)
imageF3 (0.55, 0.1)
imageF4 (-0.27, -0.3)
imageF5 (0.25, -0.3)

The images are now being uploaded via the same conditions file for each of the 24 candidates. However, I would like the images to be shuffled randomly between these five positions on the screen to avoid confounds or the purpose of the experiment becoming apparent to participants. It is also not sufficient to randomize the positions in excel if that means the randomized positions will be the same within each trial.

So, if possible, the same set of five images per candidate should be retrieved per trial, but their position on the screen should vary randomly per trial.

You could use a code component in which you do the following:

  • define a list with all possible image positions
  • pick a random entry from that list
  • set it as the location for your first image
  • repeat for the other images

It could look something like that:

possible_positions = [ [-0.55, 0.1], [0, 0.1], [0.55, 0.1], [-0.27, -0.3], [0.25, -0.3] ]

imageF1.pos = possible_positions.pop(randint(0,len(possible_positions)))
imageF2.pos = possible_positions.pop(randint(0,len(possible_positions)))
imageF3.pos = possible_positions.pop(randint(0,len(possible_positions)))
imageF4.pos = possible_positions.pop(randint(0,len(possible_positions)))
imageF5.pos = possible_positions.pop(randint(0,len(possible_positions)))

Paste this into the “Begin Routine”-Tab of the code component.

1 Like

Ohh!! This worked perfectly! Thank you SO much!! :pray:

Personally I would shuffle the positions once and then use position [0], position[1], position[2] , etc instead of popping from the list.