psychopy.org | Reference | Downloads | Github

Varying the set of stimuli shown based on group

I am trying to have participants with pre assigned groups see a different set of stimuli depending on their group. For example: If I put A in the group field of the dialog box participants will only see an image of a dog, but if I put B participants will only see an image of a cat. How do I implement this into the builder view? I currently have the group field in the dialog box, but I’m unsure how to implement this. I’m guessing some sort of if else statement in the ‘begin routine’ part a code component inside the image routine, but I do not know what functions to refer to. I looked at this post Trying to use different excel columns based on participant number , and I think this is pretty much what I need to do, but I did not know where to put this code.

You can access information from the dialog box like this:

theGroup = expInfo["Group"]  # assuming the corresponding dialog box field is called Group

This could be part of a code component in the welcome or instruction routine. You can then use the variable theGroup anywhere in your experiment. For example, you could use it to select a conditions file in a loop. If your condition files are called groupA.xlsx and groupB.xlsx, you could use this code in the Conditions field of the loop:

$"group" + theGroup + ".xlsx"

Hope this helps.

Jan