MacOS
PsychoPy version: latest
Standard Standalone Installation? (y/n) Y
Do you want it to also run online? (y/n) Y
What are you trying to achieve?: Expand on an existing code How to make a Digit Span Task in PsychoPy — Workshops
What did you try to make it work?: I followed instructions but the version does not run.
Link to the most relevant existing thread you have found: How to make a Digit Span Task in PsychoPy — Workshops
What specifically went wrong when you tried that?:
Unfortunately it crashes after the instructions… so that is a screenshot of part of the message I receive after it crashes.
Hello @Psytina
The syntax for random.randint is random.randint(a, b) which gives you an integer n with the following limits a < n < b.
Best wishes Jens
2 Likes
Thank you so much, Jens. It works. Now, I thought the “seriesLen” in the Conditions file would help me create digit sequences of a minimum of 3 digits, and a max of 7 digits but it keeps on presenting just on or two digits… would you know what I’m missing here?
Hello @Psytina
You need to show me how you implemented your experiment. seriesLenis the column-name in your condition file? It spans from 1 to 6 and you use seriesLen in the nReps field in your inner loop? You specify the condition file in your outer loop?
Best wishes Jens
Yes, Conditions in the outer loop, seriesLen is the column name in the conditions file. I changed it to 3-7 instead of 1-6..? And inner loop has the seriesLen in the nReps field.
Hello @Psytina
So, the digit span is just one or two trials long or is it three to six trials long but consists of just one or two numbers? How do set the the text component with randint? Did you set set every repeat?
Best wishes Jens
Yes, set every repeat.
Ideally, the digit span is supposed to start presenting 3 digit sequences, then detect if, say, 3 out of 4 answers (4 trials) are correct, then move on to a longer digit sequence (4 trials). As soon as there are more than 1 error within a sequence, the task is stopped. But I haven’t even gotten to presenting it correctly.. 
Below is the textbox where numbers can be entered:
randint():
Hello @Psytina
this little digit span program at least displays an increasing number of numbers from trial to trial. It start with three numbers and then goes up seven numbers. You have to press a mouse button to end the answer routine.
digitspan.psyexp (16.5 KB)
series.xlsx (18.0 KB)
Have the numbers been presented in the way you want them to be?
There is no correct response checking yet.
Best wishes Jens
Thank you so much for sending yours. Works great. In order to set each sequence to 4 repeats
4x 3 digit sequence and if 3 out of 4 are answered correctly, it continues to
4x 4 digit sequence and so on.
In order to do that where do I tell PsychoPy to repeat the current sequence 4 times and how would I make it conditional?
I updated the conditions file after I realized it was not pulling the correct file. Check.
I added 3 more to each condition of the same condition: 33334444555566667777
Now I won’t have the response check but even with this it will record what the participant types which I can check in the excel later. It might even be better since this way every participant has the same condition, just different numbers.
Again, thank you so much for sending yours, it helped clarify the dumb little mistake I was working with and if I find a way to get a response check I will implement it.
Cheers und vielen Dank!
Hello @Psytina
the response check does need some code. Insert a code-component in your showStim-routine. Initialisethe variables
stim = []
correct = False
stripText = " "
in a Begin experiment tab. In the End routine tab specify
stim.append(text.text)
assuming that the component to show the digits is called text.
Add a code-component in your recall-routine and specify the following in the end routine tab
stripText = textbox.text.replace(" ","") #replace space
stimString = "".join(stim) # change list to string
if textbox.text == stimString: #compare response with stimulus
correct = 1
else:
correct = 0
thisExp.addData("digits", stimString) #save digits to results
thisExp.addData("correct", correct) #save correct to results
stim = [] # empty stim for next trial
This will save a 1 for a correct response and a 0 for an incorrect response taking order into account. In addition, the code also saves the presented digits.
Best wishes Jens