psychopy.org | Reference | Downloads | Github

Assign subjects to 4 different conditions

Hi I’m a total beginner with psychopy, would be extremely thankful for all help.

OS: Windows 10 home
PsychoPy version: 3
Standard Standalone? Yes

What are you trying to achieve?: I want to assign subjects to 4 different conditions. The participants each have a number and a version (1-6). Unfortunately version number is a character between 1 and 6 (can’t change this it was decided by the professor). And I want to assign all participant to 4 different conditions. I have tried by adding a code and under #begin routine placed the following code:
if int(expInfo[“version”]) > 3:
continueRoutine = True
int(expInfo[“participant”]) % 2 == 0
Which I hoped would allow participants with that has a version number greater than 3 and a participant number that is even (or uneven? can’t figure out which), of course I have four different versions of the code placed on to the different conditions (routines), but I can’t run the experiment. It just shuts down with no error message.

I hope someone can give me a clue to how to solve this problem!

Hi there!! Have you had a play with the “branched experiment” demo in builder? That might be a useful example to build from :blush:

What is “version” intending to correspond to? And is “participant” unique for each participant?

If you close and reopen PsychoPy do you get an error message when you run (there is currently a known bug where error messages might not appear if the runner has been closed. This has been fixed for the next release, but for now the solution is to open your file from PsychoPy (rather than directly from the psyexp file) and ensure to leave the runner view open.

If you get an error message then please do share that too :blush:

Becca

Hi Becca :blush:Thank you for all the helpful information! The “version” is a number between 1 and 6 that the teacher assigned randomly to all the participants, and the reason we try to combine participant ID (which is unique for each participant, yes) and participant version is because we want them to do different tasks in different orders.
When I try to open the experiment from the runner directly I get the following error code:
Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\runner\runner.py”, line 255, in loadTaskList
experiments = json.load(file)
File “C:\Program Files\PsychoPy3\lib\json_init_.py”, line 296, in load
return loads(fp.read(),
File “C:\Program Files\PsychoPy3\lib\encodings\cp1252.py”, line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x9d in position 54959: character maps to

Thanks again :star_struck:
Marika

Hi again!
it is running slightly better now, but counterbalancing with this code if int(expInfo[“version”]) > 3 and int(expInfo[‘participant’]) % 2 == 0:
continueRoutine = True
under #begin routine still doesn’t work. If I want to counter balance via a second loop instead using a code such as $“version”+expInfo[‘version’]+".xlsx" I would need to add a condition where those participant with number 5 and 6 get randomized to a number between 1 and 4 how would that look? can this be inserted into the above code somehow+
if expinfo[“version”]=='5’or expinfo[“version”]==‘6’:
expInfo [“version”]=random.randint(1,4)

thank you!

Found a different solution! :grinning:

1 Like

Could you please mention what you tried out in the end? I am also looking for a way to assigning subjects different conditions. I used counterbalance, but then the participant has option to choose, which I dont want. I want to assign the conditions randomly.

It you’re running your experiment online then you might find my VESPR Study Portal useful for this.