Howdy, Stranger!

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

Supported by

[solved] How to assign participants to different sequences?

edited October 2015 in OpenSesame

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

  • edited 6:52AM

    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

        if subject_nr % 3 == 0:
               subject_group = 'A'
        elif subject_nr % 3 == 1:
               subject_group = 'B'
        elif subject_nr % 3 == 2:
               subject_group = 'C'
    
        exp.set('subject_group', subject_group) # (this makes the variable available outside
                                                                     # your inline script)
    

    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

  • edited 6:52AM

    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.

  • edited 6:52AM

    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_script item, ideally at the very start of the experiment.

    For information about Python in OpenSesame, see:

    Thanked by 1MDJ

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • MDJMDJ
    edited March 12

    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 var.subject_nr % 3 == 0:
      var.subject_group = 'A'
    elif var.subject_nr % 3 == 1:
      var.subject_group = 'B'
    elif var.subject_nr % 3 == 2:
      var.subject_group = 'C'
    

    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

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

Sign In or Register to comment.