Create visual array of pictures with presented and new objects

I am building an object memory task whereby 10 pictures are presented consecutively followed by a 30 second video. For responding, the participant will see the 10 original pictures plus 10 distractor pictures and click all of the pictures that were apart of the originally viewed 10. All pictures have the opportunity to be test and distractor images.

To create this array I will need to call upon the 10 pictures presented and then 10 more from the original list of pictures. Can someone point me in the right direction for solving this?

Hi @sarahnpope, how do you choose which images are the targets for the first presentation? From which list and how are they sampled?

It is randomly chosen from a list

Ok, then this could work for you. This code samples 20 elements from your full list and then divides them into targets and distractors evenly.

ListOfStimuli = range(100) 
Selection = random.sample(ListOfStimuli , 20)
Targets = Selection[0:11]
Distractors = Selection[10:21]

Let me know if that works!

Thank you!!! I will add that this week and see how it goes. I’ll let you know!

Will I need to adjust some of these variables in the code? Like, my list of stimuli is in an excel sheet, should I replace "ListOfStimuli with that excel file name?

Ok, then you need to do it a bit differently:

For both loops, use the same xlsx. Before the first loop, run

TargetsAndDistractors = random.sample(range(n_rows), 20)
Targets = TargetsAndDistractors[0:11]
  • n_rows needs to be replaced with the number of rows in your xlsx file

Then, use $Targets in the “selected rows” field of your first loop, and $TargetsAndDistractors for the second loop. Set both loops to “random”.

If you want to mark the trials of your second loop as being target or distractor trials you can do

if trials.thisIndex in Targets:
    thisExp.addData("trialtype", "target")
elif trials.thisIndex in TargetsAndDistractors:
    thisExp.addData("trialtype", "distractor")
  • “trials” needs to be replaced with the name of your second loop

in “End routine” of each trial.

Would $Targets and $TargetsAndDistractors be an image component? Or would I need to have this as a condition in the excel file?

No, these are the indices of the rows that are chosen to be targets and distractors. They determine, which rows of your xlsx are used as targets and distractors. This is why they have to be used in “selected rows”.