Present a list of the same stimuli more than once

Hello all,

I need to present 5 categories of images with each category having 24 exemplars. The images are presented ina specific sequence. I achieved this by this code (see below) but the pop function only presentes an image once. I want to present each 24 images 4 times. SO 5 categories x 24 images x 4 times. How can I achieve replaying it 3 more times? Thank you for help.

Here is my code

BEGIN EXPERIMENT:
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)]
#randomize
shuffle(Faces)
shuffle(Scenes)
shuffle(Bodies)
shuffle(Tools)
shuffle(Scrambled)

BEGIN ROUTINE:

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

thisExp.addData(‘image_file’, image_file)

The Sequence is defined in an excel file.
Thank you in advance

So when I run it at the moment After 24 images I get an error of IndexError: pop from empty list. I guess because my list is 24 items and the pop function removes them but HowI can repeat them 3 times more?

Depending on how you want to do the randomization:

Faces = [f’Face_{i}.png’ for i in range(21,44)] * 3
shuffle(Faces)

So you just duplicate the list 3 more times, and everything is completely randomized.An alternative procedure is:

Faces = []
for i in range(4):
   current_faces = [f’Face_{i}.png’ for i in range(21,44)]
   shuffle(current_faces )
   Faces.extend(current_faces)

With this procedure, you will see each face once before any specific face is repeated.

Great I will try it out! Thank you very much!