Not getting the correct answer with mouse

I’m trying to do an emotion test.

I want a random image of an emotion (3 differents types of emotions) to appear and 3 boxes with the name of the emotion. The participant need to click on the good boxe depending the image that randomly appeared.

I wrote this code on every frame :

for stimulus in [heureux, neutre, triste]:

# check if the mouse is pressed within the current one:
if mouse.isPressedIn(stimulus):

# Yes, so store the reaction time in the data:
    thisExp.addData('RT', t)

# check if the stimulus' image filename matches the correct answer:
    if stimulus.image == eval(reponse):
        thisExp.addData('correct', 1)
        correct_responses = correct_responses + 1
        thisExp.addData('correct', 0)

# end the trial once done here:
    continueRoutine = False

# stop any further checking:

The problem is : when I look in the log, even if the participant clicked on the good answer, I get a 0.

I upload my excel file too.

Thanks a lotemotions2.xlsx (8.1 KB)

stimulus.image will be a filename, like triste.jpeg. You are trying to compare it to your response variable, which contains only, say triste, so the comparison will always be false. But actually, you also use eval(), which will evaluate the string 'triste' into the variable triste (which refers to one of your stimuli). This comparison (of a filename to one of the stimulus components) will also always fail.

You could simply do this, to directly compare the image filename to the intended filename:

# compare to the filename in your conditions file:
if stimulus.image == face:
1 Like