Unable to get response time from mouse clicks in an online experiment

Hi all,

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?

What is your Save Mouse State set to? If you want click times you might need to set it to On Click:
image

1 Like

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?
Untitled

I am not a specialist in that, but you might want to make it save “every frame” and just take the final ones in the trials you need.

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.

on the data analysis stage? It can be very easily done using mousetrap package.

1 Like

@agleontyev,

I think this is the only way then. I will use the method that you proposed. And thanks for recommending the package.

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

1 Like

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]);
}

Thank you.

1 Like