Help with digit span experiment

OS (e.g. Win10): Mac
PsychoPy version (3)
Hi, I’m trying to create a digit span experiment, where a series of numbers will be presented and if they answer correctly, then in the next trial, the sequence will be a number longer.
I’m confused about how to do this?
Would I need to make 8 separate excel spreadsheets with possible combinations (one spreadsheet for when one 2 numbers are shown, and then 3, then 4 etc) and then create different routines for each and have the trial end if they give the correct answer? Or should I create an excel spreadsheet with just a list of the numbers 1-9 and then repeat the numbers randomly? But then how would the response work? Or is there a different way?

If using a spreadsheet to control this, I think the best way would be to have 9 columns for numbers for every row. You would monitor the span you are currently at and only present the number required for that trial. That way, you can randomise the presentation of row orders and it won’t matter how many numbers are required on that trial, as all 9 will be available.

The way to implement this would be to have two loops, one nested with the other. The outer loop is connected to the conditions file. The inner loop is not connected to the conditions file and is just set to have an nReps value of 9. When the span number (e.g. two for the first trial) is reached, you would have code that would terminate the inner loop so the next trial would commence.

If you name the columns like num_0, num_1, num_2, etc then you can extract the value to use on each presentation by referring to the loop counter of the inner loop. e.g. in the text stimulus, put an expression like this:

$eval('num_' + your_inner_loop_name.thisN)

so the first number presented in a trial will come from the num_0 column, the second from num_1, and so on.

Also insert a code code component (from the “custom” component panel). In the “Begin experiment” tab, initialise the counter variable for the span level:

span = 2

and in the “end routine” tab, put something like this to terminate the inner loop when the current span length has been reached:

# remember Python counts from 0:
if your_inner_loop_name.thisN + 1 = span:
    your_inner_loop_name.finished = True

i.e. when the inner loop terminates, the outer loop will start its next iteration (going on to the next trial, from the next row in the conditions file).

The last thing you need to do is increment the span as required, but we can leave that until you have the basic structure running.

1 Like

Thank you so much!

By searching for similar questions asked on this forum before:

https://discourse.psychopy.org/search?q=feedback%20routine

https://discourse.psychopy.org/search?q=terminate%20loop