[solved] define regions of interest for mouseclicks
Hello,
I can't figure out how to define regions of interest for mouseclicks and would like to ask for help with it.
In my experiment, subjects see a sketchpad with three boxes and are asked to choose between them via clicking on one of them. I first tried to use the touch_response item to collect the mouseclicks, but my supervisor asked me to limit the clickable areas exactly to the three boxes (Image_buttons and form base won't work either because the picture showing the three boxes has to correspond exactly to the last frame of a previous shown video). I think the best way to do this would be using an inline script. Unfortunately I don't know anything about programming, so I am not able to solve this by myself. If given the coordinates of the three boxes, could you provide me with a script to define the regions of interest?
Thanks
Comments
Hi Tabea,
Don't worry, if you don't know how to program yet. Python is rather easy to learn and you'll be able to do quite a lot after a short while. I'd like to suggest, that you give it a try and do a few online tutorials (there are plenty good ones around, just google).
Regarding your question, the general idea of what you want is following:
1) Sample current mouse position and waiting for a click
2) As soon as mouse gets clicked, take its position and check whether this position lies within the boundaries of one of the 3 ROIs
2a) Check the first ROI whether it got clicked:
If the current x-coordinate is bigger the the lower x-boundary AND
smaller than the upper x-boundary AND the same for the y-coordinates. If every condition is true, you know this ROI was clicked, if at least one of them is false, proceed with the next ROI
2b) same as 2a, just with different coordinates.
2c) same as 2a, just with different coordinates.
In a slightly more pythonic way, it will look something like this:
From that point you continue running your script depending on which ROI was clicked.
It may seem complicated, but it actually isn't. Give it a try, if you need again help, just ask.
Good luck,
Eduard
Hello,
thank you for encouraging me to give Python a try! It was actually quite fun (regarding my blank despair in the beginning).
The script I finally used looked like this:
Great to hear. And thanks for sharing your solution.
Eduard