Issue with online mouse tracking

URL of experiment:

Description of the problem: Dear all,

I’m trying to perform an experiment using mouse tracking. Participants will be asked to answer to several stimuli moving from one point to another on the screen and then to click on the response they think is correct.

The task runs well with the builder which stores x and y coordinates for each frame, however, when I upload it on Pavlovia (latest version), in the csv output file the task writes only x and y values of the mouse clicking. Do you know how to solve it?

Thanks for your help

Daniele

Hi there,

Please could you try adding a code component set code type to be JS and add something like:

Begin experiment tab:
thisExp=psychoJS.experiment;

Each frame tab:
thisExp.addData('mousePos', mouse.getPos());

Let us know how you get on,
Becca

2 Likes

Dear Becca,
Thanks for your help. I put the code components you suggested in the routine which should record the mouse (correct?), but nothing changed.

Should I change the options in the mouse response? Now is on save mouse -> every frame.

Thanks again for your help

Daniele

Hi Daniele,

Rather counterintuitively, this works if you have the save mouse status as save ‘on click’ - the attached demo should do what you want Rebecca Hirst / track_mouse_demo · GitLab

Let us know how you get on,
Becca

1 Like

Dear Becca,
Thanks again for your kind help. But even uploading your demo on Pavlovia it returned no mouse tracking data, but only one value for x and another for y. Is there anything we can do?

Thanks againd

Daniele

Hi Daniele,

Sorry about that! I just had a play again (and pushed the changes to the demo) and it seems if you set your mouse force end routine to ‘never’ and save state to ‘every frame’ (as you correctly described) the x and y columns return a list of coordinates (so this should do the trick).

Let me know if this works for you,
Becca

Dear Becca,
Sorry to report another issue. Since, actually I need the click to end each trial, this is not working, because if end routine is set on “never”, the task does not goes on. Is there a way to record mouse tracking and to use mouse click to answer?

Thanks again

Daniele

Hi Daniele,

You should be able to add a second mouse component that ends the trial on a click :slight_smile: So the first component is doing the tracking to map the movement the second one will keep an eye on when the trial should end.

(I have added a component ‘endMouse’ to the demo to illustrate)

Becca

1 Like

Dear Becca, now it works! Many thanks!

Daniele

Excellent! good to hear - please could you mark the solution with a tick for future users? :slight_smile:

Thanks,
Becca