How to record reaction time in psychopy

Dear,
I want to record reaction time in result.csv. Since I am a novel and so poor at coding, I indeed need you kind help. By the time I have knew that:

thisExp.timestampOnFlip(win1, 'gamble.started')
thisExp.timestampOnFlip(win1, 'gamble.chosen')

What I decide to do is recording the RT by the equation: ‘gamble.chosen’ - ‘gamble.started’.
How can I write the code to record and add it to csv directly rather than additional work by hand. Or maybe is there a function succeeding at achieving it? Thanks much to your generous help in advance!

Hello Tse_Cherry,

why don’t you use the Builder to build your experiment instead of coding yourself? The Builder helps you to set up the code in a proper manner with, perhaps, some additional code-components.

Best wishes Jens

1 Like

Hi Jens,
Thanks much for your advice! Because my experiment needs some random variables, psychopy seems to be the best choice in the terms of flexibility. In order to mark the start time and the chosen time, I have applied the functionthisExp.timestampOnFlip. The point is how to minus the value and record it directly to the result. I refer it as to a python coding problem or a better function I don’t know yet.
Best wishes Cherry

Not sure If I understood you, but why don’t you add the following code whenever you calculate the reaction time?

thisExp.addData('reactionTime', gamble.chosen - gamble.started)

Hello Tse_Cherry,

I guess that @Chen’s suggestion will do the trick. However, random variables are not a problem for the Builder. :wink: And the Builder is part of PsychoPy.

Best wishes Jens

1 Like

Hi,Chen
I have applied this method in my code but it didn’t work, and finally I use timerget function to measure the reaction time. The result actually don’t match perfectly with the figure A-B calculating in excel by hand(including the time running the code). Fortunately, I have tried my best to restricted the error to 0.01. Hope it would not cause much trouble when I record the RT within individual.
Thanks again for your generous help. Best wishes, Cherry

Hi Jens,
I can’t agree more with your comment that I can use variables in Builder especially in loop case. It do help decreasing much more coding trouble. However, my experiment requires two wheels with different prob. winning or losing tokens. When participant decide to gamble wheel A or B, an arrow rotates and the reward depends on its final location. Such procedure may be achieved in coder better than builder.
Anyway, thanks much for your attention again
Cherry

As someone who has just coded a script to create a CSV file from a set of log files in Builder, I’m interested to know what you believe can do in Coder more easily than in Builder with code components.