Spatial arrangment task: varied number of displayed images

I’m looking for advice. I’m building spatial arrangment task in Psychopy where I want to display randomised images for participants to arrange freely by drag-and-drop on the screen. The thing is I want to be able to display a flexible number of images at the trial either 30 or 15 or 10. Is there a way of programming it? As I understand for now, for each image I need to create the object with parameters like below. That looks tedious at best. Would Psychopy allow to create these objects en masse maybe via function? Maybe someone has an experience with it? Would appreciate any pointers!

image1 = visual.ImageStim(
    win=win,
    name='image1', 
    image=None, mask=None, anchor='center',
    ori=0.0, pos=(0, 0), size=(0.5, 0.5),
    color=[1,1,1], colorSpace='rgb', opacity=None,
    flipHoriz=False, flipVert=False,
    texRes=128.0, interpolate=True, depth=0.0)

Try the following

images = []
for Idx in range(10):
     images.append(visual.ImageStim(
    win=win,
    name='image'+str(Idx), 
    image=None, mask=None, anchor='center',
    ori=0.0, pos=(0, 0), size=(0.5, 0.5),
    color=[1,1,1], colorSpace='rgb', opacity=None,
    flipHoriz=False, flipVert=False,
    texRes=128.0, interpolate=True, depth=0.0))

Now you have a list of images from images[0] to images[9]

1 Like

Perfect! Thanks a lot, will try it tomorrow and let you know if that worked, but don’t see reason why it shouldn’t.

When coding drag and drop, I give priority to the object that is already moving to avoid losing it when it gets dragged over another lower numbered object.

Hello Izabela,
I’m planning to implement a spatial arrangment task for an online study and was wandering whether you ran your experiment online or locally? If online, I’m curious about the solution you used.
Thank by advance,
Inès

Hi Ines, no for now my study uses the script in-lab from Psychopy.

Best,
Izabela

Thanks for your answer :slight_smile: