Skipping routine A or routine B in every other repetition of the outer loop

I have several types of routines that runs in loops within an outer loop like this:

I am trying to alternate between skipping one of the two last inner loops (trial2 and trials2b) on each repetition of the first outer loop so that in the first repetition trial2 runs and trials2b is skipped and in the second repetition trial2 is skipped and trials2b runs and so on. Crucially, this order (every other) must continue through all the repetitions of the first outer loop as it is repeated by the second, outermost loop.

Any ideas about how can I achieve this?


If you have a loop counter (or use .thisN) then you could set nReps for one inner loop as loopIdx%2 and the other as 1-loopIdx%2

If you want a random start then add randint(0,2) to loopIdx

Thank you for your answer! I’m having some trouble understanding still. Could you specify a little? For example, I wonder where and how I should define loopIdx

Begin Experiment
loopIdx = -1

Begin Routine (inside loop)
loopIdx +=1

It does not work quite as I hoped. It skips one of the routines but on the next round of the first outer loop (block_2to5_nReps3) it skips the same routine as in the previous round.

Perhaps I made a mistake somewhere? I did like this (nothing more or less):

Begin experiment (in the “trial2” routine):
loopIdx = -1

Begin Routine (in both the “trial2” and “trials2b” routines):
loopIdx +=1

Loop around “trial2”:

Loop around “trials2b”:

I’m guessing that each inner loop has an even number of trials.

I notice that you have a routine in the outer loop that isn’t in the inner loops. Try starting loopIdx at 0 and increment it in that loop. Just once per circuit of the outer loop.

SOLVED: Like you suggested, incrementing in a routine that only repeats once per outer (“middle”) loop circuit was part of the solution. Starting loopIdx at 1 was the other part.

Thank you for your help!