How do I obtain coordinates from a participant's clicks? (Also: Image size on different computers)
Hello,
I am a beginner in OpenSesame and am trying to learn what participant's perceive as the central point or value of different portions of an image. I want to set up my experiment such that when the participant clicks with their mouse/trackpad it will enter into the log file as an x,y coordinate. Is there an easy way to do that?
Side points:
Will there be issues in logging responses if some participants use a trackpad vs a mouse?
I was working with Psychtoolbox when looking at coordinates in my image before and the coordinate system starts in the upper left corner while I believe in Opensesame it starts at the centre at 0,0.What is an easy way of reversing this?
Will the image that appears be different on different computers and their respective screen sizes(Mac, Linux, Desktop comps.. and would that affect the coordinates in any way?
Thank you so much in advance
Comments
Hi rozemun,
You always get the x,y coordinate for mouse clicks.
See: https://osdoc.cogsci.nl/3.3/manual/python/mouse/ and https://osdoc.cogsci.nl/3.3/manual/response/mouse/
As far as I know, OpenSesame does not recognize whether the mouse responses comes from the touchpad of a laptop or an additional USB mouse. What I know is that both works fine.
You can always change the x and y coordinates by adding/subtracting a certain value (the difference of the center and left upper corner).
You need to be careful with the image size. It can be different on different computers. That's what I do:
Hope that helps,
Stephan
Thank you so much Stephan! That makes sense. I see the cursor_x and cursor_y coordinates now. However, I have the same image repeating a number of times and I want to log separate x,y coordinates for each click on each iteration of the image. However, whenever I run it, it does not log all the cursor_x,y positions. It only logs a few of them... I am wondering if they are being rewritten or whether I have not defined my desired output in the loop! If you have any advice on how best to log each click as individual x,y coordinates I would be grateful!
Also, the experiment runs fine on my computer and saves on an excel file but when I run it on the browser after it has run the screen turns white and the data is not stored anywhere. I figure this must be some server issue related to OSweb.. I am not sure how best to proceed.
Thank you for your response,
Rozemun
Hi @rozemun ,
Could you attach your experiment (by clicking the paperclip icon) so that we can have a look?
Cheers,
Lotje
Did you like my answer? Feel free to

Hi,
I figured out the issue! thank you!
Now I am struggling with this issue:
I am recording participant clicks aka: cursor_x & cursor_y positions of my images. However, when I share this experiment online different participants will have different computers and therefore different screen resolutions. So when they select points the coordinates of cursor_x and cursor_y will be very different across participants and will not give me consistent information that I need.
Is there a way I can either define/fix the resolution so I know that the coordinates will be the same across participants or is there some calculation I can do to scale points across resolutions to make them consistent...
Does this make sense?
Thank you in advance!
Hi,
If you divide the x coordinate by the half of the width, and the y coordinate by half of the height, you should get a measure of the relative eccentricity of your mouse clicks, that is independent of the screen dimension.
Note, I say half of width/height, because these variables span the entire screen from left to right edge (top to bottom edge). But since the Zero point is in the middle of the screen, the maximal number the width can get is half the size of the variable var. width.
I hope this makes sense.
Good luck.
Eduard
Hi Eduard,
But the width and height will depend on the computer and specific resolution of each participant's computer right? And that is something I will need to establish/ask each participant before I can do any calculation?
Thanks for your response,
Rozemun
Opensesame creates those variable automatically I believe. So, can you check in your logfile, whether you have the variables
widthandheightincluded? If this does not work, you might be able to choose some conservative screen resolution (1280,1050 or something like this). If I am not mistaken the rest of the screen will be then simply filled with the background color (or black), and the experiment will be restricted to the specified area. Like this you will still have variability with regards to different resolutions, but at least the dimension won't be a problem anymore.Unfortunately, I don't think it is possible to read out online what the screen features are and adapt the window accordingly.
Hi Eduard,
Thank you for your response. So I kept that in mind and sent a version of my experiment as a JATOS link to my supervisor who uses a Lenovo Thinkpad with a resolution of 2560 X 1440 and my Mac on the other hand has a different resolution on which the experiment was designed. So not only does the experimental screen not fit completely in her browser(She has to scroll up and down to see the complete image), the coordinates are different on her computer.
So basically I asked her to click the same place for each trial to obtain x,y coordinates from her computer and I clicked the same place during each trial on my computer. What I found out was that both of our X-coordinates were the same but the Y-coordinates were different(around a 100 pixel difference). Since the X,Y coordinates are the most important feature of my experiment I am trying to figure out how to standardise this across different screens. I am thinking it's also possibly because when I am sending her a link the browser is not opening in the size it should hence the coordinates are messed up on the y-axis...
Any advice regarding this issue would be appreciated!
Thank you so much,
Rozemun
Hi Rozemun,
I am surprised that it doesn't fit the screen. Have you set the experiment to run in full screen (settings in general tab, and F11 in the browser)?
What I found out was that both of our X-coordinates were the same but the Y-coordinates were different(around a 100 pixel difference).
That is also a bit weird, since this would suggest that the aspect ratio of the images was not retained. Did the image look weird for one of you?
So far, I haven't worked with JATOS, and only the try-in-browser version of OSweb, so I'm not really sure what is going on.
Eduard
Hi,
When you say set the experiment to run in full screen, do you meant on Jatos I set that beforehand? Are these settings set on OpenSesame on my computer or someplace else?
Best,
Rozemun
Hi Rozemun,
I don't know whether you can set those things in JATOS. I did it in the general settings tab of Opensesame:
There change this line:
set fullscreen noto
set fullscreen yesHi,
Thank you for that advice! I will implement it. Would you by any chance know how I can make the cursor appear without having to click the screen. So I am recording the mouseclicks and when the image appears the cursor isn't there till I click the screen and then I can click again and it moves onto the next image.
Ideally the cursor would appear upon presentation of the image and the participant would only need to click once till it shifts to the next image.
Best,
Rozemun
Hi,
There are a couple of methods to adjust cursor visibility. I can never remember which is the one that works. Probably
set visible true, but maybe check the forum for some older discussions. For example here:If you run it on Jatos, you can't use the mouse object though (in an inline_script), instead you have to set it in the sketchpad that you are using (I think).
Not sure whether this here helps at all. I hope it does!
Eduard
Okay great thanks!
I want to use this recommendation: 'set visible true' in the inline script but every time I add any code into the inline script it doesn't save and when I click somewhere else and come back to the inline script the change isn't implemented even though I had previously clicked the 'apply' button.
Also where do you recommend I add 'set visible true'.. in the collect mouse response form, the individual sketchpads, or in the general script at the very start?
I don't know why I am having so many small small issues that don't get resolved!!
Thank you in advance!!
Rozemun
Hi @rozemun ,
I want to use this recommendation: 'set visible true' in the inline script but every time I add any code into the inline script it doesn't save and when I click somewhere else and come back to the inline script the change isn't implemented even though I had previously clicked the 'apply' button.
There's a few things here:
Firstly, OpenSesame code like this line doesn't go in an
inline_scriptitem (which takes Python or JS code) but in the script of themouse_responseitem (and not in the precedingsketchpad). But I think this is what you did do, right?Secondly, can you try to use the line
instead of
?
Finally, did you make sure the duration of the item preceding the mouse_response item (probably a sketchpad?) is set to 0? (And not to 'mouseclick', for example?
If you still keep having this issue, could you upload your experiment here?
Cheers,
Lotje
Did you like my answer? Feel free to

Hello,
Perfect that worked! I had not set the duration of the sketchpad to 0, I had set it to mouseclick hence I was having to click it twice!
Now all that remains is making the clicks consistent across different resolutions. So far when my supervisor clicks the same spot as me she is not getting the same x,y coordinates unfortunately.
Thank you for your help,
Rozemun