Present images with specific order

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): windows 11
PsychoPy version (e.g. 1.84.x): The latest
Standard Standalone? (y/n) If not then what?: Yes
What are you trying to achieve?: Hello to everyone, I have an experiment with image presentation.
During the first part I want the images to be presented in random order which I easilty achieved with just checked “random” in the trial loop. In the second part I would like the images to be presented in a specific
order so (Category1-Category2-Category3-Category4-Category5) and the program shoudl pick randomly for th pull of each category. It is not convenient to do it in builder just picking "sequestial2 since I watn the images for each cateogy to be ricked randomly within the sequence. So lets say Cateogry 1 is faces there are 24 exemplars within it. Any ideas how I do this with code? Thank you very mich!

Hi @Anastasia_Dimakou,

If I understand what you’re looking to achieve correctly, this Blocks and Counterbalancing page might solve your problem without the need for code at all!

Let me know if this helps,


Thank you Kimberley! I will try it out and let you know!

I figured out with this code
begin experiment :

Blockquote# create image lists:
Faces = [f’Face_{i}.png’ for i in range(21,44)]
Scenes = [f’Scene_{i}.png’ for i in range(21,44)]
Bodies = [f’Body_{i}.png’ for i in range(21,44)]
Tools = [f’tool_{i}.png’ for i in range(21,44)]
Scrambled = [f’scrambled_{i}.tif’ for i in range(21,44)]


anf then begin routine

if Sequence == ‘F’:
image_file = Faces.pop()
if Sequence == ‘S’:
image_file = Scenes.pop()
if Sequence == ‘B’:
image_file = Bodies.pop()
if Sequence == ‘Sr’:
image_file = Scrambled.pop()
if Sequence == ‘T’:
image_file = Tools.pop()

thisExp.addData(‘image_file’, image_file)

And a file in the loop with the order I want. I think it works do not now if it super elegant

1 Like