[visionegg] Re: response timing from keyboard
- From: Andrew Straw <astraw@xxxxxxxxxxxxxxxxxxxxx>
- To: todd gureckis <todd@xxxxxxxxxxxxx>, visionegg@xxxxxxxxxxxxx
- Date: Sat, 24 Aug 2002 08:36:21 +0930
> hi,
>
> i am interested in using visionegg to collect some behavioral data.
> particularly i am looking for a way to collect data from the keyboard
> and to keep track of the response time (time between stimulus display
> and a key press). would vision egg be suitable for this purpose?
> thanks.
>
> todd gureckis
> (gureckis@xxxxxxxxxxxxxxxxxxx)
> department of psychology
> university of texas at austin
Hi Todd,
The Vision Egg could certainly be used for this task. If you specified
the degree of temporal precision you need in the data it would be easier
to answer your question.
If you need temporal precision better than approximately 10 msec, you
may face some challenges because the Vision Egg must run on a
multi-tasking operating system. Also, if you're using USB keyboards,
keep in mind that USB operates on "frames", which occur once every msec,
imposing a lower bound on temporal precision.
The easiest approach would have temporal resolution equal to your video
card's frame rate. If the Vision Egg syncs with the vertical retrace
signal (usually recommended) this is also the monitor's refresh rate,
and is quite slow (60-200 Hz). If you don't need to sync with the
vertical retrace signal, this can be much faster for simple stimuli
(thousands of frames per second). For an example, see the
mouseTarget.py demo and imagine timestamping the keypress events.
Another approach is to use 2 computers in your setup: one for stimulus
display (running the Vision Egg, for example) and a second to record
keypress timing (not necessarily running the Vision Egg). The temporal
precision would be limited by how well you could synchronize the two
computers. Using a network connection (UDP or TCP) would be one way to
acheive the synchronization. Using the "ping" program, I frequently get
round-trip latencies of 0.5 msec or less. This 2-computer approach is
what I use for my some of own experiments and works quite well (see the
demos in the Pyro subdirectory for one approach, see the Labview info on
our website for another), although I haven't used this approach to
measure keypress timing.
Hypothetically, it is possible to write a multi-threaded application
which checked the keyboard in one thread and updated the display in the
other thread. There will be some lag between thread switching, so this
may not actually solve the problem.
Another solution would be hypothetically possible if keypresses
triggered interrupts on your system. In this case, you could write an
interrupt service routine (ISR) which grabbed a timestamp when a key was
pressed. Even if possible on a given platform, writing an ISR is
tricky. I don't know which, if any, platforms generate interrupts for
keypresses, although if I remember correctly, old 8086s did, so perhaps
Win32 still does. I would recommend staying away from this approach if
possible.
Cheers!
Andrew
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
Other related posts:
- » [visionegg] Re: response timing from keyboard