Getting reaction time during a canvas.show()
Hello!
So I am confused about how to record the time it takes for a mouse click when a canvas appear on the screen.
The thing I want to do is as follow:
- I present a canvas;
- I wait for a mouseclick to make it disappear.
So here is the code I used for now:
t = my_canvas_Practice_Sym.show()
my_mouse = Mouse(visible=False)
button, position, timestamp = my_mouse.get_click()
while True:
if button is not None:
break
var.reaction_time_canvas = timestamp - t
There are two things I am wonder here:
- could you confirm that timestamp corresponds to the time of the mouseclick and not the time when the mouse is initiated?
- I wonder if my approach is the best here for timing accuracy. First I draw the canvas and second I initiate the mouse. Could you confirm the time it takes to the mouse to initiate is so small it doesnt matter?
Thank you!
Comments
Hi,
Confirmed.
Probably true, but given the ease with which to fix it, there is no reason why not optimizing it.
Also, your
whileloop doesn't do anything currently. The button is pressed before, so that thewhileloop is effectively skipped. If you set the timeout of the mouse response to something else than infinite, you will probably even end up in an infinite loop. So, to fix it, here two suggstions:1) Drop the
whileloop and use the timeout keyword:2) Combine timeout and while loop
Hope this helps.
Eduard
Hey Eduard!
Thanks a lot yes it helps! I just do not understand why in the first example the canvas stop after a mouse click. I mean there is nothing indicating that my_canvas_Practice_Sym.show() should disappear after a mouse click no?
Thank you!
Sylvain
Hi,
I think this is because the experiment is simply over, no? If you have a sleep statement after the loop, it would stay on screen? But I must admit I haven't tried it myself.
Eduard
Hey Eduard,
No I just meant with your example:
I do not get how
Stop after a mouse click. Implicitely does it mean that showing the canvas just update the screen (like if we would set up a duration of 0ms to a sketchpad) and the script progress to the mouse object?
I was assuming that when my_canvas_Practice_Sym.show() was called somewhat it was staying active (updating the screen indefinitely) but it is just a call to a single update of the screen right?
Thank you!
Best,
Sylvain
HI,
Yes, it is a single call. Basically, once updating the screen and showing the canvas and then immediately proceeding to the mouse response and waiting for a click until the end of the timeout (2000ms). Once it was clicked (or time is up) it will proceed with the code below, or in case there is no code anymore, with the next item in the sequence. Does that make sense?
Eduard
Hey Eduard,
Yes I get it, it makes sense. It is like a single update of the screen. Much more simple than what I imagined!
Thanks!
Best,
Sylvain