[open] Image button functions
Hey guys,
I am currently building a procedure for Evaluative Conditioning studies and I have got a small problem, so I hoped that perhaps someone could have some ideas on that!
In the recognition task that I implemented I always present one picture that was previously paired with one of 15 stimuli and I ask participants to choose the one with which they think the picture was paired. I would like to gather the coordinates of the picture they clicked on, so that later I can assess if they chose the correct one.
Does anyone have an idea what kind of command I should use?
I was wondering about using Image_button functions, so that they could click on the picture, but don't know where I should apply this part of the procedure. Shall I add it in the script of a sketchpad in which I am presenting all the stimuli or is there a new section I should add below the sketchpad?
How to collect data by clicking on the pictures and have an outcome variable since the stimuli will be randomized and I would need to know then which one exactly the participant chose?
I would be super grateful for any feedback and help here.
Cheers,
Boris
Comments
Hi Boris,
I think it would be best for you to use an inline_script for this. The first step is to create a canvas, so that it would present the 15 pictures in a way similar to the sketchpad. http://osdoc.cogsci.nl/python/canvas/. The canvas can be built in the 'prepare-phase' of your inline_script. You then show it (e.g. exp.canvas.show()) in the run-phase.
Right after that, it's time to collect a mouse response (i.e., in the same run-phase). All the relevant functions are here: http://osdoc.cogsci.nl/python/mouse/. You see that the
mouse.get_click()command returns not only the button and time, but also a set of coordinates. With these coordinates you could find out which picture participants clicked. Going back to the run phase, you could make a variable calledpicture_coordinates, and give it a value like so:Every tuple in this list would refer to the center of a picture; the third element of the list would refer to the center coordinates of the third picture. Also note that it may be convenient to first create this variable and then build your canvas:
Back to the run-phase, we want to do some response processing. Let's say your pictures are size 80x80 pixels. This would mean that the third picture was clicked if
(100-40)<x<(100+40) and (300-40)<y<(300+40). Here, x and y are respectively the first and second element of the coordinate variable that was returned by our mouse.get_click() command. Hence, right after this command you could first insert the linesx=coordinates[0]andy=coordinates[1], (that is, if you named this variable coordinates; in the example of http://osdoc.cogsci.nl/python/mouse/ it's named 'position').In the end, you could do something like this:
Cheers,
Josh