In an online experiment, participants need to click on one of the two boxes and I set the mouse to force end the routine and to set mouse state on click. However, when I checked the data, it seems that it saves the first click, no matter if that click was on the valid stimuli or not.
How can I get RT from mouse clicks on valid stimuli in online experiments?
Thanks @jon. I already set it to On Click as you can see below. But the issue is that it saves the first click not the last one. So if I click on the screen after 2 seceonds nad then on clickable stimuli after 10 seconds, it saves 2.0 in the data file. How can I get the final click RT that ends the routine?
Thanks for your help. Actually, this option gives me RT for all clicks and I do not want all of those. It is difficult to extract the final one from a list of RTs in a file.
If you need an alternative custom check/output then you can always add that in does what you want. For instance it might be something like (untested):
End of Routine code:
if mouse_main.time:
thisExp.addData('finalClickTime', mouse_main.time[-])
That code creates a new column in your data file (finalClickTime) and fetches the last entry in the time attribute (the -1 index is the final one) only if there was at least one entry.
If you compile the experiment to its python script and look at the code already written about your mouse object then you’ll be able to refine the toy code above to do what you need. But it should be something as simple as that. Then you can paste your code back into a code component
Dear @jon. That was brilliant. Using this code, I can extract the final rt from the list of rts. I just made some changes to make it a JS code for those who has a same problem:
if (mouse_main.time) {
psychoJS.experiment.addData("final_response_rt", mouse_main.time.slice((- 1))[0]);
}