| Reference | Downloads | Github

Outer Loop not running

OS (e.g. Win10): Windows 7 enterprise
PsychoPy version (e.g. 1.84.x): 3.1.0
Standard Standalone? (y/n) If not then what?: Standalone

I am trying to make a Digit Span test that adapts to participants’ input. Basically it starts with 3 digits and after a correct answer is given, the participant moves on to 4 digits, then 5 digits, etc. If the participant gives an incorrect answer, they try again at the same digit span length. After 2 consecutive incorrect answers, they go down a digit span. (e.g., If I’m at 5 digits and I give a wrong answer two times, then I have to do the 4-digit span again).

To make this work, I created an excel file with each column being a sequence in the span, and a CorrAns column. In builder view, I created each digit span as its own routine, with a loop around it. If the participant gives a correct answer, the loop is finished and they can move to the next span.

The issue I’m having is trying to get it to go in the reverse order after 2 consecutive incorrect answers. I added an outer loop going from 4 digits to 3 digits, and it works fine. However, when I attempt to add another outer loop going from 5 digits to 4 digits, the builder does not let me. It seems to only allow an inner loop. When I try to run it with the inner loop, I get to the 4 digit span and then can no longer move either forward or backward.

Below are images showing what I have done so far. Any ideas about how to structure the loops, or if I have to restructure the entire experiment? Any tips will be greatly appreciated!!


I think I would take a slightly different approach here. Rather than defining routines for every possible load, I would have one routine handling the load using a code component. Please find a minimal working example attached.

What the example does:

  • It uses a dictionary of dictionaries to define loads as well as eligible stimuli within a load together with the appropriate stimulus presentation time within a load (currently the same for all loads)
  • It counts the number of correct responses and lets you move freely between loads (e.g., 2 → 3 → 4 → 5 → 4 → 3)

What the example does not do:

  • The main issue might be that there is a non-zero probability of a specific number combination being repeated on the next trial; you could either minimise this possibility by adding as many combinations as possible or you could exclude this possibility completely by removing elements from the list of stimuli after they have been chosen for presentation or by using an index for selecting elements from the list
  • Longer presentation times for higher loads; the main issue here would be to push back the response component in line with the stimulus presentation time (alternatively, you could have a separate routine for collecting responses, like you have now)
  • The participants can’t see what numbers they entered
  • The experiment doesn’t count the overall number of correct trials and thus doesn’t
    quit after 14 trials


digit_span.psyexp (12.2 KB)

Hi Jan,
Firstly, sorry for my delayed response.
Thank you very much for your advice and the example! I took your advice of having only one routine to handle all of the loads. Through the code component I have managed to count the span they are on, and stop the number display routine as necessary for the appropriate span, going on to the response routine.

Now its working like a charm - Thanks again for all of your help!