Holcombe:ButtonBox: Difference between revisions

From OpenWetWare
Jump to navigationJump to search
No edit summary
Line 41: Line 41:


== Sending a an external trigger into the box ==
== Sending a an external trigger into the box ==
Box needs to be in General Purpose mode
Box needs to be in General Purpose mode, http://community.cedrus.com/showthread.php?t=717
http://docs.psychtoolbox.org/CedrusResponseBox
 
== Timing Precision ==
== Timing Precision ==
A file summarizing our tests of the precision of the timing is here [[media:buttonBoxPrecisionSummary.doc]]
A file summarizing our tests of the precision of the timing is here [[media:buttonBoxPrecisionSummary.doc]]

Revision as of 23:09, 1 February 2009

Recent members

Alex Holcombe
• Ryo Nakayama



Technical

Skills Checklist
Python Programming
Psychopy/VisionEgg Installation Notes
R analysis,plot,stats
Statistics
Buttonbox
Buttonbox with photocell
Programming Cheat Sheets



The box

The button-box we have used for our "sensorimotor synchronisation" experiments is a Cedrus RB-730 response pad. It is on loan from Nenad and the IT office. It connects to the computer via a USB port, and is controlled by the computer as a serial port (or something like that). [1]. To work, you must install a driver from the Cedrus website here:[2], and surprisingly, I also had to install a USB to serial port driver from a company called Keyspan: [3]. I used the driver for their USA-28x product.

I had all of the little dip switches in back in the down position.

Basic programming with the box

To use the button-box with a python program, we put dipswitches 1 and 2 down so the box used XID (eXperimental Interface Device) communication protocol, which provides timestamps of button press times. Then you need these lines at the start of your code:

from psychopy import serial
from struct import unpack

And to initialize the box:

s = serial.Serial('/dev/tty.usbserial-FT3ERKOD', 115200)

To erase all info in the box about previous button-presses:

s.flushInput()

To reset the button-box internal clock to 0:

s.write('e5')

Critically, the box records both the press and release of the button and sends a signal in exactly the same way (at least how it's set up now). To avoid this, you need to record both separately. In the attached file that shows how we tested the precision of the box relative to the computer clock, you can see how I did this. But basically, to check if a key has been pressed or released, you check this:

if s.inWaiting() > 0:   ......

To get out the data about the button press or release:

response=s.read(6)
formatted_response=unpack('<cBI>', response)
time_in_msec = formatted_response[2]

Example code to increment a counter of presses and button-releases:

pressEventCodes = (48,80,112,144,176,208,240) #7 buttons from left to right
releaseEventCodes=(32,64,96,128,160,192,224) #7 buttons from left to right
eventType = formatted_response[1]
if (eventType in pressEventCodes):
   pressEvents += 1
elif (eventType in releaseEventCodes):
   releaseEvents += 1

Sam T tried to do an experiment collecting multiple responses per trial, but seemed that the Cedrus RB-730 measured multiple responses inaccurately, accumulating a timing error of roughly 500ms over a 20-tap-piloting trial.

Sending a an external trigger into the box

Box needs to be in General Purpose mode, http://community.cedrus.com/showthread.php?t=717 http://docs.psychtoolbox.org/CedrusResponseBox

Timing Precision

A file summarizing our tests of the precision of the timing is here media:buttonBoxPrecisionSummary.doc

For on-line, during-experiment timing verification we would like to trigger a photodetector by drawing on the screen at a known time, and have the photodetector press a button on the button box using what? an "Active Switch Closure" lead?

Another way to verify timing and precision would be with this expensive device.