psychopy.org | Reference | Downloads | Github

In sort pause routines on nominated trials

I am trying to implement a “pause” or “break” routine after a given number of trials. This previously suggested code works:

if trials.thisN > 0 and trials.thisN % 8 == 0: ## trial repeats 8 times
    continueRoutine = True
else:
    continueRoutine = False

However, during my first block, the ‘break’ or ‘pause’ routine runs after trial 9, not trial 8 (as I want it to be). I assume this has to do with the fact that the trials start from 0 and not from 1. During my second and third trial it works perfectly, but then the last 8 trials, instead of repeating 8 times, it repeats only 7 (which makes sense, since I only have 7 left in that last block). How can I avoid this from happening, i.e. having only 8 repetitions of the trial during the first, second, third and fourth block?

You just need to add some arithmetic to achieve what you want, e.g.

if (trials.thisN + 1) % 8 == 0: # start on the 8th trial (0-based number 7) 
    continueRoutine = True
else:
    continueRoutine = False

Sorry, I don’t understand this, perhaps in part because “trials” here seems to be inconsistently to refer to blocks of trials, and because it isn’t clear what you are intending to do. Describe your design fully, as otherwise it is very difficult to interpret what is actually going wrong.