Howdy, Stranger!

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

Supported by

Constrain not working

Hello!

I am almost finished with my experiment but I have one last little problem to solve. In the 'different' loops I do not want any objects repeated. So I have made a column that is called nbr and I have assigned all rows with repeating objects the same number. Then I put constrain nbr maxrep=1. When I do this one row is repeated every time. I do not know why? Furthermore, I do not want the correct answer to land on the same side more than twice. So, I made a column labeled side where the items are 'l' and 'r.' Then I put constrain side mindist=2. If I put both:

constrain side mindist=2
constrain nbr maxrep=1
it will not run. it says error (maxshuffle=100)

I would appreciate any advice you may have! Thanks so much in advance.

Best,
Mollie

Comments

  • Hi Mollie,

    > Then I put constrain nbr maxrep=1. When I do this one row is repeated every time. I do not know why?

    Could you give an example of this? This constraint has the effect of not allowing the same value of `nbr` to be repeated. But perhaps that's not what you mean by one row being repeated?

    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

  • Hey Sebastian!

    Thanks for your reply! I do not want any of the same objects repeated during a block. I am measuring proactive interference so during one block every trial should have the same objects and during the other block every trial should have different objects. So, there are four different ways that object 3 and object 4 can be presented I have labeled all of the these with ‘nbr’ 1. There are four different ways that object 5 and object 6 can be presented so I have labeled these ‘nbr’ 2. When I put constrain ‘nbr’ Maxrep=1 I am hoping that it will display the objects that have ‘nbr’ 1 one time, that have nbr 2 one time etc. Therefore, no objects should be presented twice during a block. Thanks so much!

    Best,
    Mollie
  • Hi Mollie,

    Right, I see now. That's not what the maxrep constraint does, though: It prevents direct repetitions of some value, i.e. in consecutive rows.

    But what you want is essentially to have some variables (left and right) fixed while others (target, elmo, and side) are randomly chosen.

    I would do this using the Python random.choice() function, like so:

    Do you get the idea? So you select a fixed value for left and right, and randomly select values for the other variables. You don't need any constraints other advanced loop operations.

    To make this work, you need to import the choice() function into the Python workspace of OpenSesame. You can do this by inserting an inline_script at the start of the experiment with the following line in the Prepare phase:

    from random import choice
    

    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

  • Hey Sebastian,

    Thanks so much. The problem with this is I don't want the target to be a random choice because I want to make sure that the correct answer does not end up on the same side more than twice in a row. So I do not want any objects repeated but I also don't want the correct answer to be on the same side more than twice in a row. Does that make sense? If I am randomly selecting the target then I can't control if the correct answer is on the right or left. Sorry about the confusion! Thanks so much for any advice.

    I appreciate your time,
    Mollie

  • Sorry one more thing! When I try what you suggested I get an error.
    TypeError: choice() takes exactly 2 arguments (3 given)... any idea why? Thanks so much!

  • Hi Mollie,

    I see. So if I understand correctly, for some variables, such as side, you want:

    • A random starting value for the first cycle
    • Then switch to another value (the other side) on each subsequent cycle

    You could do this with a clever expression in the loop table, but that's probably more trouble then it's worth. So instead I would insert an inline_script at the start of the sequence and define the variable in the Prepare. Here's a dummy example that implements the basic logic:

    from random import choice
    
    # On the first cycle, randomly pick a value
    if var.live_row == 0:
        var.my_var = choice(['a', 'b'])
    # On subsequent cycles, switch from a to b or vice versa
    elif var.my_var == 'a':
        var.my_var = 'b'
    elif var.my_var == 'b':
        var.my_var = 'a'
    # A sanity check to make sure that there are no typos etc.
    else:
        raise ValueError('This should not happen!')
    

    TypeError: choice() takes exactly 2 arguments (3 given)... any idea why?

    Right, the elements to choose from should have been inside a [l, i, s, t] rather than passed as individual arguments!

    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

  • thank you!!

Sign In or Register to comment.