OS (e.g. Win10): macOS 11.6 PsychoPy version (e.g. 1.84.x): 2022.2.4 Standard Standalone? (y/n) If not then what?: y What are you trying to achieve?: skip a loop with two Routines
Dear all,
my experiment has a trial-by-trial cueing design, where participants perform one of three possible tasks depending on the instructions they received at the beginning of the trial. In one out of three tasks, participants do a partial recognition test after seeing an image. So the logic behind my design is the following:
if task == taskA or task == taskB, skip the test
if task == taskC, do the test (which consists of two Routines, one 3s and one 1s long)
Now, this should be fairly simple by setting continueRoutine on false at the beginning of each Routine, if the condition is met:
if task == ‘A’ or task == ‘B’:
continueRoutine = False
However, instead of skipping the Routine, Psychopy displays a blank screen for 4 seconds (the summed duration of the two test Routines). So it looks like the Routine is not skipped, although no stimuli are shown.
Has anyone encountered this problem before? What would you recommend to sort it out?
Add print(task) to the top to check what values of task you are actually getting. Pay particular attention to spaces. I’m guessing that your other print statement isn’t showing.
It does print both the right task and the other statement.
The stimuli in “test” and “feedback” are not shown. But for some reason, I get a blank screen as long as test and feedback combined (4s), if task==‘LTM’ or task==‘STM_notest’.
Try putting the code in Each Frame. It shouldn’t be necessary but I think there was a bug in an earlier version that required that. Is your “use version “ blank?
I’ve just confirmed that continueRoutine = False does not work in 2022.2.x offline. It results in a blank screen for the normal duration of the routine.
This is to do with non-slip timing. Essentially, if you set continueRoutine = False during the frame loop, it takes note of the fact that the routine ended before the planned time so that the timer can be reset to 0 rather than having the expected duration subtracted (which we do for routines with a fixed duration as it prevents timing from slipping over several repeats). Because continueRoutine = False was set here before the routine, the frame loop never executes so it never learns that the routine was force ended.
I’ll put in a fix for the next version of PsychoPy so that what you did will work, in the meantime there’s two things you can do to avoid the problem:
In your Begin Routine code, add routineForceEnded = True after continueRoutine = False - this means your experiment will know that the routine was skipped before its intended end time so won’t subtract the duration from the timer
Move the code from Begin Routine to Each Frame, but put it inside of this if statement: if frameN == -1:. This means that continueRoutine will be set to False on the first frame, rather than before the first frame.