Present multiple images of varying numbers in different trials and drag and drop into different boxes

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): PsychoPy3
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?:

Hi all,

This is a temporal order memory task (and will eventually be online). Participants will learn sequences of short videos during study, their memory for the order of videos within a sequence will be tested later. I will skip the study phase here since it’s not the focus.
In the memory task, participants need to judge the order of videos for each sequence. There will be 72 sequences, of 4 different sequence length: 4, 5, 6, & 7 (so 18 sequences for each length). Thumbnails of videos for a studied sequence will be shown on the screen simultaneously (in several predetermined positions). Also on the same screen there will be several boxes. Participants need to drag and drop the images (thumbnails) to the boxes to sort them in order.
image
(just an illustration, sth like this)

I want the sequences to be presented in random order, but every four sequences to contain all the four sequence length, which means I should have sth like sequence of length 5, 6, 7, 4,…,4, 5, 7, 6,…
Also I want to use a single routine with nested loops to accomplish this.

What did you try to make it work?:
I have created an experiment like this.


Materials attached (excluding the study phase).
chooseTestSequenceLength.xlsx (9.3 KB)
demoTemporalOrderMemory.psyexp (92.4 KB)
testSequenceLength4A.xlsx (9.6 KB)
testSequenceLength5A.xlsx (9.7 KB)
testSequenceLength6A.xlsx (9.8 KB)
testSequenceLength7A.xlsx (10.6 KB)

I have created a condition file for the outer loop to decide which sequence length file to go to, and four condition files for the four sequence length for the inner loop.
(Screenshot for the condition file for the outer loop)
image

(Screenshot for one of the condition file for the inner loop)

To control which sequence to go to, I have a code component in routine “selectSequence” to decide which sequence to present (this code might be fine since I have sth similar in the study phase so I’m not showing it here). The main problem I guess is with the way I tried to use a single routine to present sequences of different number of images. My current logic is I have seven boxes and images components. But I have a code to decide the positions and opacity of them to show different number of boxes and images according to sequence length of the current loop.

# Begin Experiment
boxesPos = []
boxesOpac = []
imagesPos = []
imagesOpac = []


# Begin Routine
# crate lists for box positions and opaicity according to sequence length
# for example, only four boxes (and images) should be presented when sequence length = 4
# so set the opacity of the boxes (and images) so that some are invisible
if testBlockSequenceLength == 4:
    boxesPos = [(-0.6, 0.25), (-0.2, 0.25), (0.2, 0.25), (0.6, 0.25), (0.8, 0.5), (0.8, 0.5), (0.8, 0.5)]
    boxesOpac = [1, 1, 1, 1, 0, 0, 0]
elif testBlockSequenceLength == 5:
    boxesPos = [(-0.59, 0.25), (-0.295, 0.25), (0, 0.25), (0.295, 0.25), (0.59, 0.25), (0.8, 0.5), (0.8, 0.5)]
    boxesOpac = [1, 1, 1, 1, 1, 0, 0]
elif testBlockSequenceLength == 6:
    boxesPos = [(-0.645, 0.25), (-0.399, 0.25), (-0.133, 0.25), (0.133, 0.25), (0.399, 0.25), (0.645, 0.25), (0.8, 0.5)]
    boxesOpac = [1, 1, 1, 1, 1, 1, 0]
elif testBlockSequenceLength == 7:
    boxesPos = [(-0.6855, 0.25), (-0.457, 0.25), (-0.2285, 0.25), (0, 0.25), (0.2285, 0.25), (0.457, 0.25), (0.6855, 0.25)]
    boxesOpac = [1, 1, 1, 1, 1, 1, 1]
    
# crate lists for image positions and opaicity according to sequence length
if testBlockSequenceLength == 4:
    imagesPos = [(-0.6, -0.325), (-0.2, -0.125), (0.2, -0.325), (0.6, -0.125), (0.8, 0.5), (0.8, 0.5), (0.8, 0.5)]
    imagesOpac = [1, 1, 1, 1, 0, 0, 0]
elif testBlockSequenceLength == 5:
    imagesPos = [(-0.59, -0.325), (-0.295, -0.125), (0, -0.325), (0.295, -0.125), (0.59, -0.325), (0.8, 0.5), (0.8, 0.5)]
    imagesOpac = [1, 1, 1, 1, 1, 0, 0]
elif testBlockSequenceLength == 6:
    imagesPos = [(-0.645, -0.325), (-0.399, -0.125), (-0.133, -0.325), (0.133, -0.125), (0.399, -0.325), (0.645, -0.125), (0.8, 0.5)]
    imagesOpac = [1, 1, 1, 1, 1, 1, 0]
elif testBlockSequenceLength == 7:
    imagesPos = [(-0.6855, -0.325), (-0.457, -0.125), (-0.2285, -0.325), (0, -0.125), (0.2285, -0.325), (0.457, -0.125), (0.6855, -0.325)]
    imagesOpac = [1, 1, 1, 1, 1, 1, 1]

Then I set the position and opacity for boxes and images by hand like this.

What specifically went wrong when you tried that?:
For now, the experiment won’t run without reporting any error. So I’d appreciate if anyone can help me check if I’m on the right track. I haven’t come to the part of “drag & drop” (I found some helpful links that works for a fixed number of images Drag & Drop Stimuli and would need to modify that to work for different sequence length, and check which box has an image been put into), but suggestion on that is also welcomed. Thank you in advance! Let me know if anything is unclear :blush:

In principle it looks like your method should work. If you have a maximum of 7 objects and can do the drag and drop for when all seven are showing then you could just leave the code as is and accept the possibility that participants might occasionally drag invisible objects. Alternatively you could check the opacity of the object and only select it if the value is 1.

(post deleted by author)