#### Welcome!

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

# Multiple groups

Posts: 18

Hi all,

I'm currently programming an experiment and I need your help. The structure of the experiment is as follows:
The experiment has 2 different parts and 8 different groups:

Part 1:

Participants are assigned to a experimental or a control group

Part 2:

After they have completed the task participants of both groups are assigned to 1 of 4 tasks

--> This means that there are 8 groups in total: experimental group & Task 1; experimental group & Task 2; experimental group & Task 3; experimental group & Task 4 and control group & Task 1; control group & Task 2; control group & Task 3; control group & Task 4

I need all tasks in 1 file because it would get too messy if I had 8 different excel-sheets. As a consequence I need a code that allows me to separate the participant into 1 of the 8 groups. In the first part participants need to be separated into 2 groups (experimental vs. control condition). Then participants of both groups need to be assigned to 1 of the 4 tasks. In the end each group should entail 10 participants (80 participants in total). I know that it is possible to create a dictionary in python and I was hoping this would help me to separate the participants into different groups. Since I'm just learning to use python I was hoping someone could help me with the code or give me some advice.

Thank you very much,
Erwin

• Posts: 4

A simple selution is to use mod on the subject number. if 0-3 control, if 4-7 exp.
A mod of 4 can give you the different groups.

Thanked by 1erwinwirne
• Posts: 18

Thanks for your answer! I'm not sure if I understand what you exactly mean. Could you go into further detail? In my experiment I need to separate the participants twice in 2 steps: first step = control vs. experimental group and second step = separate participants in both groups into 4 different groups. Is it possible to do this with the mod function?

Thanks,
Erwin

• Posts: 1,001

Hi Erwin.

The mod function returns the residuals from a division. See here. So if you take the `var.subject_nr` and take the modulo with 4, you will always get values between 0 and 3. Then, you have to have a matching of condition to ID. So if you have 4 groups, something like that would do:

``````if ID == 0:
first = 0
second = 0
elif ID == 1:
first = 1
second = 0
elif ID == 2:
first = 0
second = 1
elif ID == 3:
first = 1
second = 1
``````

Eduard

Thanked by 1erwinwirne
• Posts: 18

Dear eduard, dear Korem N

Thanks for your answer! I looked into the modulo function and it certainly seems to be a good solution. However I think the modulo function distributes the participants regularly into the various groups (e.g. 4 participants in group 1 then 4 particpants in group 2 and so on). For my experiment I would like to distribute the participants randomly into the various groups. My solution for this problem is to create an `inline_script` at the beginning of the experiment where I define the groups:

``````var.experimentalgruppe = [1, 2, 5, 6, 7, 8, 11, 12] #this line should separate the participants into 2 groups experimental vs. control

var.aufgabe1 = [1, 7, 12] #the following 4 groups
var.aufgabe2 = [2, 3, 13] #the following 4 groups
var.aufgabe3 = [4, 11, 14] #the following 4 groups
var.aufgabe4 = [5, 8, 15] #the following 4 groups

var.limited_subject_nr = var.subject_nr % 16 #after 16 participants the whole process should be repeated``````

Then I would add another `inline_script` at the end of the experiment:

``````if (var.limited_subject_nr in var.experimentalgruppe):
print('Ego_Depletion_SST_Farbe')
else:
print('Ohne_Ego_Depletion')

if (var.limited_subject_nr in var.aufgabe1):
print('Folgeaufgabe_SST_Ton')

elif (var.limited_subject_nr in var.aufgabe2):
print('Folgeaufgabe_Stroop')

elif (var.limited_subject_nr in var.aufgabe3):
print('Folgeaufgabe_EFT')

else:
print('Folgeaufgabe_Anagramm')``````

These two `inline_scripts` should separate the participants into the experimental or the control group in the first step and then into one of the 4 groups in the second step. I used the print() function so I can look at the debug window and check if this solution works (it seems that the code works because it prints out the correct groups). Of course the print() function doesn't actually run the tasks so here is my question: How can I tell OpenSesame to run the tasks? I tried the .prepare() and .show() function but that doesn't seem to work. To be clear: let's say participant 11 is doing the experiment - according to my code this participant will get the experimental task in the first step and then task number 3 in the second step. Does this make sense?
I added my script in the attachment so you can see the structure of the experiment.

Cheers,
Erwin

• Posts: 1,001

Hi Erwin,

Well, you have to create the task first (What's the task actually?). Did you do that? Maybe have a look at the beginner's tutorial, to get an example of how a cueing experiment would look like. This will give you some inspiration how to implement your own task. http://osdoc.cogsci.nl/3.1/tutorials/beginner/

Eduard