measuring reaction time

3,320 views
Skip to first unread message

ariel.g...@gmail.com

unread,
Mar 19, 2009, 2:41:06 PM3/19/09
to psychopy-users
Hi
I was wondering what programing language is most easy and most worthy
of learning inorder to program my experiments, and python using the
psy module seems to be it. I would like to now if there is a reliable
and easy way to measure the reaction time of subjects, lets say from
the presentation of a stimuli to the time they touch a botton? and if
so what is the resolution (miliseconds, hundredth-second ?).
any information would be much appriciated
Ariel

Dave Britton

unread,
Mar 20, 2009, 8:13:25 AM3/20/09
to psychop...@googlegroups.com
I am currently using PsychoPy in an experiment which presents a sequence of
three stimuli (sound, picture,word) and measures the subject's reaction time
in a same-different discrimination task. It works fine at capturing the
reaction time of key presses at the millisecond level.
-Dave

Jonathan Peirce

unread,
Mar 20, 2009, 1:15:31 PM3/20/09
to psychop...@googlegroups.com
Dave is right, but I would add an word of caution:

Although PsychoPy and Python can produce response times with this sort of accuracy, your keyboard can't (expect delays of 20-30ms with around a few ms variability, depending on model). Also, your screen is refreshing only every 10ms or so (depending on refresh) and is either drawing the top of the screen several ms before the bottom (for CRTs) or ramping up over a period of many ms (for LCDs).

So, in measuring the time a keypress occurs relative to the precise onset of a stimulus, you might reasonably expect a *precision* of 10-15ms, mostly limited by your monitor, but a lag of 30-50ms mostly caused by the keyboard.

But it isnt the software that's usually the limit (beware misleading claims of some vendors). If you really need high precision/accuracy in RTs then consider a dedicated timing/response device (of the type that Alex Holcombe recently shows to be rather flaky! :-( )

Jon
-- 
Dr. Jonathan Peirce
Associate Professor
Nottingham Visual Neuroscience
School of Psychology
Nottingham University

+44 (0)115 8467176 (tel)
http://www.peirce.org.uk/

This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.

ariel goldstien

unread,
Mar 21, 2009, 5:14:31 AM3/21/09
to psychop...@googlegroups.com
hi
I hope I am not too rude , but I have some problems with psypy could you pleas send me the code you described (presenting visual and audio and measure the reaction time). it will help a lot.
thanks anyway for responding
arielon

khallg

unread,
Apr 1, 2009, 12:40:51 AM4/1/09
to psychopy-users
Hi,

Does anyone know where I would look in the source code to find the
function that records timing information to record reaction time
information?

I'm glad to hear the PsychoPy is capable of recording reaction time
information, and am hoping to use these libraries to create a Stroop
test to measure response latencies between when a stimulus is
presented and when a keyboard response is given by the participant. I
have not found a tutorial online that explains this, and I did not see
any obvious reference to time-related information in the source code
for event.py (http://code.google.com/p/psychopy/source/browse/branches/
v2/psychopy/event.py). I would imagine that the way to go about
recording this would be to record the time that the stimulus is
presented, then record the time that a key is pressed by the
participant -- but I'm having trouble finding these functions in the
code.

Any help in directing me to information on how I can record reaction
time information for keyboard input would be very helpful. Thanks!

Kevin

On Mar 21, 3:14 am, ariel goldstien <ariel.goldst...@gmail.com> wrote:
> hi
> I hope I am not too rude , but I have some problems with psypy could you
> pleas send me the code you described (presenting visual and audio and
> measure the reaction time). it will help a lot.
> thanks anyway for responding
> arielon
>

Dave Britton

unread,
Apr 1, 2009, 10:14:17 AM4/1/09
to psychop...@googlegroups.com
Here's a reaction time demo that uses the latest PsychoPy version (0.97)
with improved keypress time capture in it.

# ==========================
# RTdemo.py
"""
ask a question,
get a keystoke
measure reaction time
"""
from psychopy import visual, event, core
from random import random

#create a window to draw in
wintype='pyglet' # use pyglet if possible, it's faster at event handling
myWin = visual.Window((600.0,600.0),allowGUI=False,winType=wintype)

sans = ['Gill Sans MT', 'Arial','Helvetica','Verdana'] #use the first font
found on this list
ask4key=visual.TextStim(myWin, text='Press a key as fast as you can RIGHT
NOW!', \
font=sans, units='norm', height=.10,pos=(-.95,0),alignHoriz='left')

RT = core.Clock() # make a clock for capturing RT (reaction time)

while True: # replace the .... 's with spaces or a tab
.... # clear any keystrokes before starting
.... event.clearEvents()
.... allKeys=[]

... # paint the stimulus to react to:
.... ask4key.draw()
.... myWin.flip()
.... RT.reset() # reaction time starting immediately after flip

.... while len(allKeys)==0: # wait for a keypress
.... .... allKeys=event.getKeys(timeStamped=RT)
.... .... # see the online PsychoPy reference manual on event.getKeys for
details of use and code
.... .... # if timeStamped = a core.Clock object, it causes return of the
tuple (key,time-elapsed-since-last-reset)

.... # now allKeys is [(key, milliseconds)]
.... # if you don't have pyglet, you need to get the time explicitly
.... if not wintype == 'pyglet':
.... .... allKeys[0][1] = RT.getTime()

... # unpack allKeys taking the first keypress in the list
.... thekey=allKeys[0][0].upper()
.... theRT =allKeys[0][1]

.... if theKey=='ESCAPE': core.quit()

.... if theRT < 500 : feedback="Pretty fast! Now wait for it..."
.... else: feedback="You can do better. C'mon now! ready....and ..."
.... msg="Your reaction time was %5.4f milliseconds. %s"%(theRT,feedback)
.... ask4key.setText(msg)
.... ask4key.draw()
.... myWin.flip()

.... ask4key.setText('Press a key as fast as you can RIGHT NOW!')
.... # wait for 3-8 seconds to read feedback and have uncertain wait time
before next trial
.... core.wait(3+int(random()*6))
# -----------------------------------------------------

LisaLondon

unread,
Feb 6, 2014, 10:50:11 AM2/6/14
to psychop...@googlegroups.com


Hello, I have a question and thought I could add it to this post...
I have created an experiment testing RTs for judgements of auditory stimuli. I am not 100% sure when the measurements of RT begins to record..is it straight after stimulus onset or after the end of the presented stimulus? I have auditory stimuli which vary slightly in their length (400-900ms length), just wondering how to control for this..
thanks very much!

Michael MacAskill

unread,
Feb 9, 2014, 4:12:09 PM2/9/14
to psychop...@googlegroups.com
Hi Lisa,

I presume you are using Builder?

PsychoPy can't know which stimulus you want to record the reaction time relative to. For example, you might be presenting a visual fixation point, an auditory warning cue, and an actual target auditory stimulus. Similarly, it can't know what is the relevant time point (stimulus start, stimulus end, etc). You have to decide that yourself (which is a good thing).

So if you are using a Keyboard component to measure your responses, the reaction time will be *relative to the onset of that Keyboard component*. So if you want the RT relative to tone onset, for example, set it so that the Keyboard component appears in your time line at the same time as the start of the relevant Sound component.

Hope that helps,

Michael

EvaB

unread,
Nov 10, 2015, 11:37:53 AM11/10/15
to psychopy-users, michael....@otago.ac.nz
Hi,

I was wondering what units PsychoPy uses to record reaction time (through the Builder). The recorded response I obtain are like:  0.000280142.

Any clarification of that would be much appreciated!

Eva

Jeremy Gray

unread,
Nov 10, 2015, 11:40:25 AM11/10/15
to psychop...@googlegroups.com
Hi Eva,

PsychoPy uses units of seconds for all response time information. (Some visual display uses units of visual frames.)

So yeah, 0.00028 looks implausible as an RT.

--Jeremy


--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/5f3a2b56-2c21-48a7-8f45-b0103b7e4f85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael MacAskill

unread,
Nov 10, 2015, 3:43:01 PM11/10/15
to <psychopy-users@googlegroups.com>

> On 11/11/2015, at 05:40, Jeremy Gray <jrg...@gmail.com> wrote:
>
> So yeah, 0.00028 looks implausible as an RT.

Dear Eva,

When people have reported this sort of thing in the past, it has usually been because the subject is actually making a late response to the previous trial, which is recorded as a very fast response to the the current one.

You'd need to describe more about how you've set up your keyboard component (in particular, whether it has a fixed duration or is set to "Force end of trial".

Within a trial, it's important to know how it is located relative to the stimulus (e.g. if your stimulus has a variable onset time, the keyboard onset time has to match it).

Regards,

Michael

EvaB

unread,
Nov 11, 2015, 7:55:57 AM11/11/15
to psychopy-users
Thank you both!
There was actually a typo, so I started recording the keypress too late. But now I sorted it out and it works fine.
Reply all
Reply to author
Forward
0 new messages