Change image at every loop repetition

What are you trying to achieve?:

I need people to see 15 images, one at the time, in a specific order, and press a key to go to the next one. I can easily do it by creating 15 routines, each one with the image and the keys to press, but I don’t know how to do it with a loop. I mean, I suppose there’s a way to tell the loop to change the image every time it repeats, and start the routine again when I press the keys. But I’m totally new to programming and to PsychoPy and I don’t know how to do it.
Thank you in advance for your help!

Hi @Alessandro_Costa,

you only need one routine. In this routine, have an image component. For the path of this image component, don’t select a specific file but use a variable, e.g. $ImageFile and set the component to be updated “every repeat”. Now, create an xlsx (Excel) file, that has the column “ImageFile” in which the 15 images are listed in order. Surround the routine you created with a loop, which is set to “sequential” and has your xlsx file in the “Conditions” field.

I hope this gets you started!

Thank you very much, it worked!
I got another question after this answer. If I want to share my script, so that another person can use this experiment, and I want him to use the same picture folder that I have without him renaming each path inside the excel file, is there a way to do that? So that the variable can pick each image inside the folder in every computer

The path to your picture folder should be relative to your experiment folder (usually a sub folder) rather than absolute.

1 Like