'How to add a break in a trial loop in PsychoPy

I'm learning how to work with PsychoPy. My problem is that I cannot add a break in a trial loop within another loop.

Situation: There are two stimuli lists: ListA.xlsx and ListB.xlsx. Both lists contain 20 sentences. A third list ('AB.xlsx') refers to block A ('ListA.xlsx') and block B ('ListB.xlsx').

When I start the experiment, PsychoPy runs through the twenty sentences of ListA.xlsx in a loop. After block A, the experiment stops for a break. The participant can continue the experiment by pressing the spacebar. When the experiment resumes, PsychoPy runs through the twenty sentences of ListB.xlsx in a loop.

For the block break, I'm using the following code:

if blocks.thisTrialN not in [1] :
    continueRoutine=False

Problem: What I want to add is a break within block A and within block B, i.e. I want to add a break after 10 sentences. I've already tried many different things, but I don't get it to work.

I'd appreciate any advice!



Solution 1:[1]

In your "break" routine, insert a code component and put something like this in its "begin routine" tab:

if currentLoop.thisN != 9: # NB counting is 0-based
    continueRoutine = False

Builder maintains a variable named currentLoop to refer to whatever loop is currently running, so this code and routine can be re-used in any loop in your experiment, without needing to refer to the name of the specific loop that is enclosing it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael MacAskill