Howdy, Stranger!

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

Supported by

Problem with constrain command


I am attempting to create a sustained-attention-to-response task (SART). The SART consists of 9-trial blocks in which a single digit (1-9) is randomly presented, with the constraint that each digit is presented only once per block. The digits are presented in one of five possible type sizes, with the constraint that no type size appears more than twice per block.

I have created a loop representing all 45 possible combinations of digits and type sizes. I want to randomly present 9 combinations of digits and type sizes per 9 trial block. To implement this, I have added the following constraints to the OpenSesame script:

constrain digit maxrep=1

constrain font_size maxrep=2

But, even with these constraints added, digits are appearing more than once and font sizes more than twice per block.

I feel that I must be missing something obvious either in the use of the constrain commands or in some other settings for the loop items, but even after trying multiple possible solutions and watching the relevant tutorials I can't figure out the issue!

Any help would be most greatly appreciated. I've attached the script for reference.

Thank you for your development and support of this great tool!


  • Hi,

    The maxrep constraint refers to direct repetitions. So constrain digit maxrep=1 means that digit will not have the same value on two consecutive trials, but the same value may repeat at longer intervals.

    In your case, it seems that you want to randomly pair digit and font_size. To do this, I would create a loop table with 9 rows, and then use shuffle digit to randomly shuffle the digit column (but not the other columns), thus breaking the correspondence between digit and font_size. Does this make sense?

    One thing to consider is that you have 9 values for digit and 5 for font size, which is unbalanced. (Some font_size values will occur more often than others.) I would use, say, 10 digits and 5 font sizes, or 8 digits and 4 font sizes. That strikes me as more elegant.



  • Thanks Sebastiaan! This is very helpful. Unfortunately I'm stuck with the 9 digits and 5 font sizes because this a direct replication of a specific version of the task, but I think I should be able to build it out using the information you provided here. Thanks again!

Sign In or Register to comment.