Setting an image_button to different positions?
Hi, i'm currently trying to make an experiment where the participant must click an image that could be in different places in the main screen. My question is how can i implement this using the widget image_button. I supposed this could be arranged by making a 10x10 grid where i can assign a position using variables for row and column defined in the loop, but i can't manage to get it working. Is there an easy way to do this? Currently my best bet is in making 100 conditional statements depending of another variable, but i suppose there's something a lot clever than that ![]()
Great software by the way, longtime fan.
Comments
Hi Sebas,
That is certainly possible using forms and widgets. First you need to create all possible positions in your loop with two variables (row * column), but i assume you already did so?
Then you add an
inline_scriptwhere you want to create and present your widgets with the following placed in the run phase:And that's it! If you are having issues with the locations, check out the documentation on custom forms:
Please don't
Let me know whether this is what you had in mind!
Best,
Laurent
Hi, I think you can use a subloop to choose the position.
I set up a simple experiment to illustrate:



Insert a subloop in your formal experiment loop, and move the trial sequence in the subloop.
In the subloop, define the position variables. I supposed that you want a 10 x 10 grid, you can use the full-factorial design to make it easier. (Remember that the count starts with 0!)
Change 'Repeat' in the subloop to 0.01 (depends on your experimental design), so that each time you only get one of the possible positions.
Use the
formto present your image with widgetimage_button.If you want to identify the position where the image appears, use
image_idto define.You can go to this page for more infomation
http://osdoc.cogsci.nl/3.1/manual/forms/widgets/image_button/
Hope that help!
Elliot.
Thanks a lot for the responses.
I managed to set a experiment using the code in the inline provided by Knante, but my problem is adding a background image. I tried using the following script.
Where bg is a 1440x900 image and circle is a semi-transparent png with an empty circle on the center.
I'm trying to achieve something like this:
My issue is that i only get to display the background image. Is there any way to sort the priority of the images to show them in the expected order via the widgets?
Thanks a lot!
Hi Sebas,
If you want to add a background image to form, you have to monkey-patch it; that is, you have to replace the original
form.render()function by a custom function that does the same thing but first draws a background image. This sounds more complicated than it is, as you can see in the example below (adapted from here).However, if I understand correctly, there are many other and easier ways to do what you want to do; for example, why not simply use a
sketchpadand use variable coordinates for the bird's position?Cheers,
Sebastiaan
You can get this:
With a script like this:
Check out SigmundAI.eu for our OpenSesame AI assistant!