What I’m trying to do?
Record the response time by each trial.
What consist my experiment?
My experiment is a task where the participant need to discover the relation between two images that will be presented on the screen. For illustrative puporse:
The participant need to observe the images and select with the mouse one of the options: True or False
What I did until now?
I’m using this code in Each Frame
if response.isPressedIn(left_response_box): # target is the name of the object to click on
rt = round(t*1000) # t is seconds since the start of the routine
thisExp.addData('RT',rt)
latency += rt
elif response.isPressedIn(right_response_box): # target is the name of the object to click on
rt = round(t*1000) # t is seconds since the start of the routine
thisExp.addData('RT',rt)
latency += rt
This code in Each Frame works well! But sometimes in my Excel’s spreedsheet the “rt” isn’t recorded
Why do you need a code componet to record RTs in the first place? The mouse component alone should do the job (if fact the column “response.time” seems to be alredy recording the RTs for each trial).
it might be that Excel does not import the numbers in the proper format (selects the wrong format). What does the response.time look like when opening the *csv with a simple text-editor?
First, I need to measure the response time (in miliseconds) in each trial;
Then, I need to add the values and divide by the numbers of trials.
For example, in the first trial the participant selects an answer (True or False) in 3000 ms. In the second trial the participant selects an answer in 1000ms.
add the values: 3000ms + 1000ms = 4000ms
divide the value by the numbers of trials: 4000ms/2 = 2000ms
I think that psychopy store the RTs in seconds. I am not very familiar with making calculation inside psychopy (I usually do them with R starting from the .csv files), but I think you can create a vector/list of RTs in millisecond for each trial (storing response.time * 1000 at the end of each trial routine) and at the end sum the content of the list/vector and divide for the number of trial (which can be nother variable that starts at 0 and goes up by one at the end of each trial routine).
Yes, PsychoPy store the RTs in seconds.
My solution:
It’s seems that this code in End Routine works better than in Each Frame. I don’t know why. But here my solution. If anyone has any suggestion, feel free to answer here!
End Routine
if response.isPressedIn(left_response_box): # target is the name of the object to click on
rt = round(response.mouseClock.getTime()*1000)
thisExp.addData('RT',rt)
latency += rt
elif response.isPressedIn(right_response_box): # target is the name of the object to click on
rt = round(response.mouseClock.getTime()*1000)
thisExp.addData('RT',rt)
latency += rt