Sustained Attention Task in PsychoPy

I have created a PsychoPy script for the Sustained Attention to Response Task (SART) and a Vigilance Task. Both of the tasks are very similar. In SART the task is to press the key space as fast and accurate as possible on all targets (digits 1, 2, 4–9) except for one (digit 3). In the Vigilance Task, however, the task is to withhold response on all targets but the digit 3.  It might be obvious that in this case the Vigilance Task is a modified version of the SART (i.e., there are other tasks).

Sustained Attention

Sustained attention can be defined as the capacity one have to direct and focus attention on a task. It has been argued that it is crucial to carrying out more cognitively demanding goals, sequenced actions, or thoughts.


Vigilance, a construct related to sustained attention (according to wikipedia vigilance is also known as sustained concentration), can be defined as the ability to maintain focused attention over longer time periods.

The experiments are free to use as anyone pleases. You need to have PsychoPy installed to run these tasks. Luckily, PsychoPy is free!

Please note, I have not yet piloted the tasks more than testing them myself. If you are planning on using them, please do pilot test the tasks and let me know if there are any problems.

The script can be downloaded at my Github page; SART.

Note, response time data is stored in seconds. If you need to convert it to milliseconds, just use your favorite software and multiply each cell by 1000 (one second is 1000ms). Do pilot the task before you use it, I have not.

For more information on SART see Robertson et al.m (1997).


Robertson, I. H., Manly, T., Andrade, J., Baddeley, B. T., & Yiend, J. (1997). “Oops!”: performance correlates of everyday attentional failures in traumatic brain injured and normal subjects. Neuropsychologia, 35(6), 747–58. Retrieved from

Smilek, D., Carriere, J. S. a, & Cheyne, J. A. (2010). Failures of sustained attention in life, lab, and brain: Ecological validity of the SART. Neuropsychologia, 48(9), 2564–2570.

12 thoughts on “Sustained Attention Task in PsychoPy

  1. Hi!
    Please I have been using psychopy to run the SART programme that you created. However it gives raw data as output. Any idea how I can summarize scores?
    I would be glad to receive your great direction.
    Thank you

    1. I suggest that you look in one of the references in the post. If that does not help or you cant access them, I can try to help you. I may even update the post with some directions.



  2. Hello,

    When run the SART task, the following message appears:
    self.mask = self.files[‘circleMask’][0]
    KeyError: ‘circleMask’

    Any idea?

    Thanks for yor help!

    1. Hey Contantine,

      I am sorry for the late reply. I just ran the task on my computer and did not get that error. Have you downloaded the entire folder. You’ll need the Stimuli folder also. It contains the circle that is used as masking stimulus between the target stimuli.

      1. Hey Emanuele,

        I tested the script running Ubuntu and Windows 8.1, just now. I can run the task. Not sure why you and Contantine have this problem. If you use another file than’circleMask.png’ (located in the ‘Stimuli’ subfolder) you either have to use the name of that file as a key or change the filename to ‘circleMask’. Right now, I can’t think of any other solutions (I don’t know why this happens to you).



  3. hi Erick, i’d like to use you script, but testing it i can’t figure out in the data file the number that refers to the RTs. The number is too long (e.g 11164231300354000). Is it a cell format problem? How can a set it to read the RTs in ms?

    1. Giulia, sorry for the late reply. The response times from the script should be in seconds. However, that long numbers mean that something else is going on. On my Ubuntu computer, I get the RT in seconds. It’s really hard to know whats going on. I am sorry.

    1. The response times are in seconds. One second is 1000ms. Thus, you can just convert your RTs to ms. by multiplying each RT. I typically start by using Python when preprocessing my data. Using Pandas data frames to store date, you can just take your column (RT) and multiply it by 1000: frame.RT = frame.RT*1000. If you are using SPSS you could probably use “compute variables” (if I remember it correctly) or syntax. Hope it helps,


  4. Hi Erik,

    I’m interested in using the SART experiment you created for my thesis. I’ve been running it on Psychopy for the past hour and it’s not working for me. It says that there’s an error on line 189. The first box that asks for information such as age, sex and other variables pops up. When I want to start running the experiment, my screen goes black and then nothing happens. It says that there’s an error in line 189, though I’m not sure why.

    Could you help me out?


    1. Hey Fernanda,

      Sorry for the late reply. It would be easier for me if you could copy-paste the error since it’s very hard for me to know what’s going on except for something on line 189. Do this by sending me an email, preferably, and I will try to help you get the SART task running. Also, be careful to see that your data is correctly recorded (see other comments for instance regarding the response time from the SART task.

Leave a Reply

Your email address will not be published. Required fields are marked *