Hi, I only rarely use the Builder, but I think you would want to do something like the following.
You need a code component somewhere. Under Begin Experiment, you would put something like:
# ioHub configuration.
SERIAL_PORT = 'COM5'
BAUDRATE = 19200
iohubkwargs = {
'serial.Pstbox': dict(name='pstbox', port=SERIAL_PORT, baud=BAUDRATE)
}
# Start the iohub server and set up devices.
io = launchHubServer(**iohubkwargs)
pstbox = io.devices.pstbox
def get_stimulation_onset_time():
# We can use this to keep track of stimulation onset.
global stimulation_onset_time
stimulation_onset_time = core.getTime()
Under Begin Routine, I assume you could put the code to clear the response buffer:
pstbox.clearEvents()
rt_measurement_started = False
Under Each Frame, you could try to record the onset time of the stimulus stimulus
, to which the participants are supposed to respond:
if not rt_measurement_started and stimulus.status == STARTED:
# Will set the global variable `stimulation_onset_time` to the exact time
# the visual stimulus `stimulus` is being presented.
win.callOnFlip(get_stimulation_onset_time)
rt_measurement_started = True
It is important that the stimulus
is positioned above this code component in the Builder, otherwise RTs may be one frame off!
Under End Routine, you can check out the collected responses and save them:
pstevents = pstbox.getEvents()
if pstevents:
rt = pstevents[0].time - stimulation_onset_time
button = pstevents[0].button
else:
rt = None
button = None
trials.addData('RT', rt)
trials.addData('Response_Button', button)
Hope that helps.