#### Howdy, Stranger!

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

Supported by

# Restrict loop so no two pairs of trials are repeated

Hi there,

Thanks for advance for any help with this question. In my experiment, I have a series of trials that I want to be repeated 6 times in a loop. See below screenshot for how this has been set up:

I want the following two constraints in the loops:

1) Ensure a given trial does not occur twice in a row. I have successfully implemented this by editing the script and using "constrain [variable/trial] maxrep = 1" command (following the advice in this link)

2) Ensure that no two pairs of trials follow each other. I am having more difficulty achieving this. To illustrate what I mean, see the screen shot below of a preview of the loop table I have generated so far. I have highlighted an instance of what I want to avoid - i.e., two pairs of trials repeating - T4,T4,T4,T3.

Does anyone know if its possible to restrict the loops such that no two pairs of trials are repeated using the 'view script' aspect of the loop item? Alternatively, would you be able to suggest a way to do this using an inline script?

Thanks in advance, and do let me know if this hasn't been explained sufficiently.

Matthew

• Apologies - I had a typo above when explaining the pairs of repeating trials that I highlighted. I meant to say, "T4, T3, T4, T3".

Matthew

• Hi Matthew,

I don't think this is possible with loop operations. Well, you would be able to exclude those cases my setting maxrep to 2, but than you would exclude also cases like T4, T3, T4, T1, not sure whether this is a nogo for you. If so, you will have to resort to Python coding via inline_scripts. The strategy is: (1) Generating a Python-based loop table, (2) Keep on shuffling until all your criteria are fulfilled (implying that you also have to implement the checks that control for your criteria)

Hope this helps,

Eduard

• Hi Eduard,

Thanks that helps a lot. Yes, I may just set maxrep to 2. That shouldn't really be an issue for me I think. If I try the inline_scripts route I'll post it here.

Thanks!

Matthew