I honestly have no idea how to start writing this. I understand there is the
mouseMoved
but this only looks at the distance. I want to abort the trial if the mouse stops moving at all. Thoughts?
Hi, spitballing here!
Maybe you could try having a counter that start at a value “x” and gains an unit of value at a fixed time (e.g. 1 every 100 msec). If the counter reaches a certain value the trials stops.
Then, moving the mouse removes some value from the counter, up to a minimum of “x”.
tandy
Hello, thank you for your reply! Could you elaborate further? I think I understand (theoretically), but I’m not sure how to implement the part of moving the mouse subtracting from the counter.
Get the position of the mouse each frame. If it’s the same as the previous frame add 1 to a counter. If it’s different, reset the counter to 0
End the routine if the counter reaches a certain value
I figured this out by doing this:
At begin routine
x_coord = []
y_coord = []
counter = 0
And then at each frame
x_coord.append(mouse.getPos()[0])
y_coord.append(mouse.getPos()[1])
if trial_clock.getTime() > 2:
if (x_coord[-1] == x_coord[-2]) & (y_coord[-1] == y_coord[-2]) and buttons==[0,0,0]:
counter = counter + 1
if counter > 5:
abort = 1
continueRoutine = False
else:
continueRoutine = True
Thank you all for your help!