psychopy.org | Reference | Downloads | Github

Present paired images in multiple trials

Hi all,

I am totally new to PsychoPy and not very good at coding with Python. Below is my experiment design and the problem I encountered.

OS (e.g. Win10): macOS Catalina
PsychoPy version (e.g. 1.84.x): PsychoPy v2020.1.2
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?:
For each participant, a random set of 6 * 10 images was chosen from 120 possible Mooney images (with their corresponding grayscale image). Each experimental block consisted of three phases of 10 trials (10 different images).
Phase 1: participants will be asked to identify the object in the Mooney image. A total of 10 trials will be performed.
Phase 2: a template exposure phase follows. Participants will be shown the 10 grayscale images that corresponded to the Mooney images they have seen in the previous phase. Each grayscale image will be shown once, in random order.
Phase 3: in the after-exposure phase (“post phase”), participants will be presented with the same 10 Mooney images they have seen in the first phase of the block. Image presentation will be again randomized.

What did you try to make it work?:
I tried to make this experiment design work using Builder. Phase 1 has been settled down. As you can see, however, images that will be used in Phase 2 should be the paired template images with those Mooney images that are presented in Phase 1 and should be presented in random order. Mooney images that will be presented in Phase 3 should be the same images that are presented in Phase 1, and will also be presented in random order.
I named the Mooney images and their corresponding template images with the same names but saved in different folders.

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.
Ten Mooney images were selected randomly from 120 images. The loops were set as attached. I wonder how I could select the paired template images and the same set of Mooney images for the subsequent two phases using Builder?

Please let me know if anything is unclear. Any assistance you can provide would be greatly appreciated.

All the best,
Sherry

Hi Sherry,

What I would do is discard all the phase loops and just keep the trials loop, linking it to a .csv conditions file with three fields: trials_phase1, trials_phase2 and trials_phase3. So that each trial, it chooses a whole row of this table, meaning the stimuli are matched.

The obstacle then is that you want to use only 10 rows of the full 120, but this can be achieved using the Selection field in the trials loop. Set the value to be something beginning with a $, this tells PsychoPy that you’re giving a variable name. This can be anything, but you should make it something descriptive, like $randselect.

You can then add a code component before the trials loop, creating the variable you specified in the Begin Experiment tab, and assigning it a value of 10 random numbers within the range of your conditions file. For example:

import random
randselect = random.sample(range(0,119), 10) # Choose 10 trials at random

When PsychoPy now reads in the condition file, it will only read in the rows specified by randselect, which will be a list of random numbers between 0 and 119 (as you have 120 possible rows).

EDIT
I’ve just spotted an easier solution: Rather than using $randselect, you can actually type into the Selection box a command to choose random numbers:

random(10) * 119

Meaning you wouldn’t need a code component!

Hi TParsons,

Thanks so much for your reply! I really appreciate it!

I changed my design accordingly. I had the new flow attached below. Without the phase loops, however, only one Mooney image and it’s corresponding template image was randomly selected per trial. That is, every trial ran: one Mooney image → the corresponding template image → the Mooney image. The trial loop then let it run ten times. What I actually want in each trial, however, is 10 Mooney images → 10 corresponding template images (present randomly) → 10 Mooney images (same as the first phase, but present randomly). This trial then is supposed to run in a total of 6 times. Are there anyways to make this design work?

Thanks again for your help! Please let me know if anything is unclear or if any further information is needed.

Best,
Sherry

Ah, I see what you mean now… Yes, this is possible! If you use the method with the code component, you can refer back to randselect throughout and it will be the same values, so will refer to the same rows. So you would need to make a loop for each phase, link all loops to the same conditions file, then set Selection in each loop to be $randselect.

1 Like

Thanks TParsons! This perfectly addressed my problem!!

Thanks so much for your input!!