Images as buttons on the screen

I’m suggesting you don’t need to do any of this stuff:

The mouse component will automatically store for you what stimulus name was clicked (because you have told it to do exactly that by providing the list of clickable stimuli).

So in the “end routine” tab, you just need code that does something like this:

if RESPOSTARMexemplo is in mouse_resp_RM.clicked_name:
    accuracy = 1
else:
    accuracy = 0

thisExp.addData("theirResponse", mouse_resp_RM.clicked_name[0])
thisExp.addData("accuracy", accuracy)

Note that the clicked name will correspond to the names of the stimuli, like 'button1', 'button2', etc. So either the variable you use to compare against has to look like that, or you need to extract just the last character of the clicked name (i.e. just the number) to compare against. If so, you need to be careful about the types of your variables. The integer value 1 won’t equal the character '1', for example, so you might have to coerce one or the other using str() or int() to make the comparisons work.

3 Likes