Saving mouse position for every frame in online experiment

Buenas!

I haven’t had time to look at your experiment but I had exactly the same issue. After looking at it for a while I realised that pavlovia only records the position when there’s a mouse click. Since I basically know nothing about Java, what I’ve done is to put a code component saving the data, and it seems to work, yay!
So here is what I made:

In begin routine I wrote the following in Python:
x_coord = []
y_coord = []

Which translates into Java:
x_coord = [];
y_coord = [];

In each frame for Python:
x_coord.append(mouse_response.getPos()[0])
y_coord.append(mouse_response.getPos()[1])

For Java:
mouse_position = mouse_response.getPos();
x_coord.push(mouse_position[0]);
y_coord.push(mouse_position[1]);

And in end routine in Python:
thisExp.addData(‘x_coord’, x_coord)
thisExp.addData(‘y_coord’, y_coord)

And in Java:
psychoJS.experiment.addData(‘x_coord’, x_coord);
psychoJS.experiment.addData(‘y_coord’, y_coord);

It worked for me, hope it can help!

5 Likes