Recording keyboard response time relative to target stimulus onset time in a target detection task

Hello.

I’m creating a target detection task where I present a series of sound stimuli one at a time and the subject needs to respond to the “target items” by pressing the space bar. The task loops through a routine that has a stimulus and a keyboard component. I’m trying to record the keyboard response time relative to the onset time of the target item.

So far, I have set a timer at the beginning of the experiment and inserted the following code at “Begin Routine”.

if Sound == Target:
    targetOnset = Traintimer.getTime()

if TrainResp.keys in ['', [], None]:
    TrainResp.keys = None
if TrainResp.keys != None:
    responseOnset = Traintimer.getTime()
    reactiontime = responseOnset - targetOnset

It is recording the onset time for both the target stimulus and keyboard press, but the timing doesn’t seem to be accurate. I always get a RT of 300ms (which is the length of the sound stimulus) when I know I’m pressing the keyboard at the same time as the target onset (and should be getting a shorter RT).
I have also tried inserting the Traintimer.getTime() part in different places in the coder view but I’m still getting the same problem.

Is using the timer the right way to do this, and if so, where should I insert it?

Thank you!!

Hello,

I hope you are doing well.

I am wondering if you have successfully solved this problem. I am facing the very similar issue as yours.

In my experiment, I created a Textbox Component in the Psychopy builder, where participants could input their answers in a cued-recall test. I want to record the recall latency for each trial, that is, the time between the onset of the stimuli (the cue word) and the first keypress of the participants’ input in the Textbox. Unfortunately Textbox could not automatically record this response latency. Do you perhaps have any ideas about how to solve this problem?

Thank you!

Tian

1 Like

You want something like

if len(textbox.text) > 0 and RT == 0:
     RT = t

in Each Frame