| Reference | Downloads | Github

Provide feedback (mean RT and number of stops) after a block in a SST task


Hi all,
I am trying to provide feedback after a completion of a block in a stop signal task.
I followed John’s example, [].
But it seems that the sample code only works if there is only one routine.
Here is my code in the begin routine properties.

nCorr =['StopResp.corr']
meanRt =['GoResp.rt']
msg = "number of successful stop = %\nRT = %.3f in this block"%(nCorr.sum(),meanRT.mean())

Note that I have

msg=' ' 

in the begin experiment properties and a text routine displaying $msg below the code component.

When I run, I get

meanRT = GoRoutine.Data['GoResp.rt']
KeyError: 'GoResp.rt'

FYI, I also tried with

nCorr =['StopResp.corr']
msg = "number of successful stop = %i" %(nCorr.sum())

simplifying the code just requesting number of successful stops, but this code appeared to only store the last stop success, i.e., displaying 1 if the last stop was successful and 0 for stop failure in the last trial.

I would appreciate if you could help me solving this issue.
Many thanks,


The first error suggests that data GoResp.rt is never created. Is it showing up in the data files? Maybe your code component is executing too early (ie. before a GoResp measure has been taken)?

I don’t know why the second issue is occuring. You could do print(nCorr) to see what’s in it?


Hi Jon,
Thanks for your input.
Indeed GoResp.rt is created in the data files

Please note that this is a csv file.

is in the “end” routine which comes after all the routine (please see below)

If I request print(nCorr), I get [[1.0]]. I suppose it is saying that I have only 1 successful stop, which does not correspond to the data (csv) file.

Just in case, I have uploaded the relevant files for you to inspect.
Thank you again for your help.

SimpleSSRT_FrameEEG.psyexp (38.1 KB)
RoutineCtrl.xlsx (8.5 KB)Go.xlsx (10.2 KB)
Stop.xlsx (8.4 KB)


OK, I’m betting that your experiment is set up so that GoRoutine and StopRoutine have nTrials of 0 or 1. The reason that your data has only one value is because you ask it to run only a single trial but then you do that multiple times. Asking for 10 trials is not the same as asking for 1 trial 10 times. Does that make sense?

I suggest in your code component you don’t bother trying to access the data as stored by PsychoPy, but keep a track of it yourself. Create a variable at the start of the experiment:

GoRTs = []
GoCorrs = []

and then at the end of each trial do


That way you understand better what values are stored and what format. Then you can use those in your other code

The other solution would be to get rid of your different routines for Go and NoGo trials and just have a single routine. Use the conditions file to change each trial to be Go or NoGo rather than a separate routine. Then you don’t need the nested loops and things should become easier to understand.

Stop signal task creation

Thanks a lot for your input.
It is working now.

For your information, below is the codes which requests the feedback using np as

nCorr = np.sum([StopCorrs])
meanRT = np.mean([GoRTs])
msg = "number of successful stop = %i\nRT = %.3f in this block" %(nCorr,meanRT)

Many thanks,


Hi, is it possible for you to explain me how you did solve this problem, please?