[solved] How to assign participants to different sequences?
Hey there,
I am an Open Sesame newbie who is totally unfamiliar with phyton. Nonetheless, I got along pretty well - the program is really intuitive and easy to use. There is just one thing that I really struggle with: I've got three experimental conditions that I realized by creating different loops (positive, negative and ambivalent) and I would like to randomly assign my participants to these conditions. How can I do this? I suggest I have to create an if-statement but since I need three conditions I can not just divide the participants by their subject parity (odd vs. even). Can anybody help me out?
Thanks in advance!
Best,
L.

Comments
Hi Lisa,
So you're talking about a between-subject design? You could use the modulo ('%') for your if-statement. The idea of modulo is that it fits a number as often as possible in another number, e.g. in 10%3, 3 will fit three times in 10, and that will leave you with 1: hence, 10%3 is 1. A bit odd, but this comes in handy in your design. Taking subject_nr % 3, we could say that
Then, in the overview window clicking on the experimental sequence that contains your three loops, you'll find that all loops run 'always' by default. You can change this into a logic statement - for instance,
[subject_group] = 'B'.Hope this helps
Josh
Josh,
Thank you so much for your help! This is definitely a step in the right direction. Unfortunately, I still get an error message that says"IndentationError: unexpected indent". Do you happen to know how I could solve this?
Sorry for being so helpless, but I really don't know anything about phyton.
Thanks in advance!
best,
L.
Never mind, I figured it out! Thank you so much!!
Hi Josh,
I am also very new to programming and OpenSesame.
Where exactly do I put that code into the general script? Everytime I click apply it takes the code away so I assume I'm putting it in the wrong place.
Best,
Matthew
@MDJ
> Where exactly do I put that code into the general script? Everytime I click apply it takes the code away so I assume I'm putting it in the wrong place.
This is Python code, so you have to insert in an
inline_scriptitem, ideally at the very start of the experiment.For information about Python in OpenSesame, see:
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks Sebastian....I didn't realise that I needed to use an inline_script item to do that!
I have now placed the item at the start of the experiment and used similar code to Josh except I have 6 categories instead of 3.
However, an error is now coming up:
" Inline script, line 1, in <module>
NameError: name 'subject_nr' is not defined "
This is probably really obvious but where and how exactly should I define subject_nr?
Thanks again,
Matthew
Hi Matthew,
The script that Josh provided above is actually not entirely correct. Here's what it should look like:
If you want to use an
inline_script, I recommend at least walking through the intermediate tutorial to get some understanding of how this works. Otherwise you'll blindly stumble from one confusing problem into the other which is frustrating and inefficient!Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
An example is available at https://pablobernabeu.github.io/2023/assigning-participant-specific-parameters-automatically-in-opensesame
@pbe Thanks for sharing!
Check out SigmundAI.eu for our OpenSesame AI assistant!
My pleasure :)