 #### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

# [solved] Specific participants, specific conditions

edited April 2013

Hi,

I would like the participants to receive only one out of three conditions (A,B,C).
(and I don't want to make 3 seperate experiments)
Like this:
pp 1 -> A
pp 2 -> B
pp 3 -> C
pp 4 -> A
pp 5 -> B
pp 6 -> c
etc etc
How do I accomplish this?

Thanks so much
Marianne

• edited April 2013

Hi Marianne,

A solution would be to use a little inline scripting to setting a 'condition' variable, which may then be used within OpenSesame (e.g. in a 'Run if' statement). You could do this as follows:

```# calculate modulus after division
# for subject number / number of conditions
mod = exp.get("subject_nr") % 3

# set condition to either A, B or C
if mod == 1:
exp.set("condition", "A")
elif mod == 2:
exp.set("condition", "B")
elif mod == 0:
exp.set("condition", "C")
```

Of course, a shorter version would be to use the modulus after division to code your conditions directly:

```exp.set("condition", exp.get("subject_nr") % 3)
```

Place an inline_script item at the beginning of your experiment and paste this into the prepare phase of said inline_script.

Good luck!

Edwin

• edited April 2013

Solved this one in person; marking as solved.

For future reference: the above experiment was not only to be counterbalanced for three different conditions, but the orders of two sequences as well, resulting in a 3x2x2 design.

Ugly solution:

```# calculate modulus after division
# for subject number / number of conditions
mod = exp.get("subject_nr") % 12

# set condition variables
if mod == 0:
exp.set("condition", "A")
exp.set("order1", "0")
exp.set("order2", "0")
elif mod == 1:
exp.set("condition", "B")
exp.set("order1", "0")
exp.set("order2", "0")
elif mod == 2:
exp.set("condition", "C")
exp.set("order1", "0")
exp.set("order2", "0")

elif mod == 3:
exp.set("condition", "A")
exp.set("order1", "1")
exp.set("order2", "0")
elif mod == 4:
exp.set("condition", "B")
exp.set("order1", "1")
exp.set("order2", "0")
elif mod == 5:
exp.set("condition", "C")
exp.set("order1", "1")
exp.set("order2", "0")

elif mod == 6:
exp.set("condition", "A")
exp.set("order1", "0")
exp.set("order2", "1")
elif mod == 7:
exp.set("condition", "B")
exp.set("order1", "0")
exp.set("order2", "1")
elif mod == 8:
exp.set("condition", "C")
exp.set("order1", "0")
exp.set("order2", "1")

elif mod == 9:
exp.set("condition", "A")
exp.set("order1", "1")
exp.set("order2", "1")
elif mod == 10:
exp.set("condition", "B")
exp.set("order1", "1")
exp.set("order2", "1")
elif mod == 11:
exp.set("condition", "C")
exp.set("order1", "1")
exp.set("order2", "1")
```

Slightly prettier solution:

```# conditions
cons = ['A', 'B', 'C']
or1 = [0, 1]
or2 = [0, 1]

conditions = []
for i in range(0, len(cons)):
for j in range(0, len(or1)):
for k in range(0, len(or2)):
conditions.append([cons[i], or1[j], or2[k]])

# calculate modulus after division
# for subject number / number of conditions
mod = exp.get("subject_nr") % len(conditions)

# set condition variables
con = conditions[mod]
exp.set("condition", con)
exp.set("order1", con)
exp.set("order2", con)
```