Drag and drop; Mouse trap; Back-end
Hello,
I'm trying to use the mouse trap function in my experiment that is based on drag and dropping some stimulus on a horizzontal line. I entirely defined the task with python script without using any opensesame integrated element. The experiment (build with psychopy backend) works very well. The problem now is related to mousetracking data collection. I realyzed that there is no compatibility between psychopy and mousetrap. So, as i change the backend in legacy or xpyriment the logic i wrote for the drag and drop doesnt' works anymore as it doesnt' fits well with legacy or xpyriment.
Do you have any suggestion on how resolve this problem?
Kind regards,
Lorenzo
Comments
Hi Lorenzo,
I assume that even if you rewrite your code so it works with legacy or expyriment, mousetrap won't be of much help as the tracking of the cursor coordinates using mousetrap functionality will likely not work in parallel with your custom drag and drop implementation.
However, since you have already written the complete drag and drop functionality, I would assume that you only need to add a bit of extra code to record the cursor coordinates. Essentially it just involves setting up empty lists for timestamps, x- and y-positions first and then using the mouse.get_click function with a fixed small timeout (the logging interval) to collect the cursor coordinates and append them to the lists. You can see how this is implemented for mousetrap here (this code contains much more additional functionality which you likely not need in your case): https://github.com/PascalKieslich/mousetrap-os/blob/master/plugins/mousetrap_response/PyMT_response/__init__.py
I assume that you already continuously collect the coordinates in the drag and drop part so for this part you likely only need to store the coordinates in the lists.
Best regards,
Pascal
Dear Pascal,
first of all thank you for your suggestions and help. I tried to set up the lists but the problem is that i can't effectively register the tracking data, later in the output. In the drag and drop i used the function my_mouse.get_click but obviously wasn't able to record correctly the coordinates. As i try to change and use the my_mouse.get_pos i always have problem of definition of x and y coordinates where the "string indices must be integers, not 'str'". Moreover, by using get_pos, i'm not able anymore to move the stimulus.
Kind regards,
Lorenzo
Dear Lorenzo,
sorry, I am not sure whether I understand your problem in detail. One thing that could be of interest is that since OpenSesame 4.0.0, lists are not logged anymore (but you can still handle and store them as normal Python variables - however, when you want to log them, you need to convert them to strings) - see the following change in one of the mousetrap example experiments here: https://github.com/PascalKieslich/mousetrap-os/commit/5cbecaaffe61d8ea338e6ce59aebd13efd900061 and the OpenSesame change note here: https://osdoc.cogsci.nl/4.0/notes/400/#important-backwards-incompatible-changes
Best regards,
Pascal