[open] Log response time of button press via serial port
Hello,
we are dealing with a staircase paradigm in the fMRI scanner and we record subject's responses through a serial port. We use PySerial to set the serial port and log the responses. Responses are mostly given while the current stimuli are still being presented. After they are presented we can read the serial port. OS correctly records the response button identity, and uses it to set subsequent stimuli presentations (following the logic of our staircase). However, we are not able to log the actual time of button press. We checked PySerial documentation to see whether there is a function that logs the instant in which the serial port receives a bit ( = a subject's button press), but there is none.
Do you have any suggestion on how to approach this issues?
Thanks, Stefania and Ambra
Comments
Hi Stefania and Ambra,
Assuming that your button box simply sends a response as soon as a press has been detected, you can just use OpenSesame's
self.time()function to get the time immediately after you have collected the response, like so:This will log the timestamp of the response, not the response time relative to some other event, such as the presentation of a
sketchpad. But you can deduce the response time easily, simply subtracting the timestamp of the starting event from the timestamp of the response.Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
thank you for your immediate response, that we really appreciated.
However, if the subject presses the button while the stimulus is still being presented (60 frames), the serial port receives a response during the loop. We only read the response after that loop, so this means that self.time() does not necessarily report the precise time of button press (i.e. when it occurred during the loop).
We probably need a parallel pooling loop that reads the serial port (and uses self.time() to get the actual time of presses) inside the presentation loop. Is that correct? again, any suggestions will be very welcome.
Thanks, Stefania and Ambra
Hi guys,
Actually, you could do this in a serial fashion, rather than using the more complicated parallel threading approach. Place the following code in an inline_script placed directly behind the sketchpad that you use to present your stimulus, and set the duration of that sketchpad to 0.
Does that work for you?
First of all thanks for putting out this great program! Quick question: in PsychoPy it is possible to start recording keypresses at certain frames. My experiment uses a paradigm where I need a 'beep' played at a certain frame (the first after an edit) and the participant will then press a button, the RT time of which also needs to be recorded. How do I anchor the keypress, the recording, and the sound to a certain frame?
Hi Xandra,
That really depends on how your experiment is structured. What does your trial look like exactly and how have you implemented it at the moment?
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!