# Multiple groups

**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

## Comments

6A 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.

18Thanks 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

1,115Hi 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:Eduard

18Dear 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:Then I would add another

`inline_script`

at the end of the experiment: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

1,115Hi 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