Noob question: write correct response following mouse press in the correct image

Hi! I have a screen with several images and only one correct. Participants click on one, and the next stimulus is shown. For each of these screens, I would like to record whether participants gave the correct or incorrect answer.

I have in begin experiment

response_joy.text = “joy”
response_anger.text = “anger”
response_sadness.text = “sadness”
response_fear.text = “fear”
response_disgust.text = “disgust”
response_surprise.text = “surprise”

and somewhere in the forums I found the following code which I thought I could adapt here but I am not being able to make it work

if words in existWords:
memoryCorrect = 1
else:
memoryCorrect = 0
thisExp.addData (“memoryCorrect”, memoryCorrect)

Any thoughts? Thanks!

Not enough information with just that, I’m afraid. What is existWords? Where is it defined? When i the code at the end executed? Is it every frame, end of routine, or somewhere else?

Also please put your code in a preformatted text block so we can see the indentation levels. You can use the “</>” button in the composition window. I believe what you shared is supposed to look like this:

if words in existWords:
    memoryCorrect = 1
else:
    memoryCorrect = 0
thisExp.addData (“memoryCorrect”, memoryCorrect)

It is, yes. Sorry but I am new at coding.

The user who created that code had in begin experiment a list of words that made up existWords. I don’t have a list of words, what I have there is:

response_alegria.text = "alegria"
response_raiva.text = "raiva"
response_tristeza.text = "tristeza"
response_medo.text = "medo"
response_nojo.text = "nojo"
response_surpresa.text = "surpresa"

The code he created run at each frame.

I just need some code that would allow me to write my output whether the participant clicked on the correct image or one of the incorrect ones.

I believe my entire code for this is the following:

# Initialize components for Routine "emocoes_video_response"
emocoes_video_responseClock = core.Clock()
emocoes_response = event.Mouse(win=win)
x, y = [None, None]
emocoes_response.mouseClock = core.Clock()
response_alegria = visual.ImageStim(
    win=win,
    name='response_alegria', 
    image='imagens/response_alegria.png', mask=None,
    ori=0.0, pos=(-0.5, 0), size=(0.4, 0.4),
    color=[1,1,1], colorSpace='rgb', opacity=None,
    flipHoriz=False, flipVert=False,
    texRes=128.0, interpolate=True, depth=-1.0)
response_raiva = visual.ImageStim(
    win=win,
    name='response_raiva', 
    image='imagens/response_raiva.png', mask=None,
    ori=0.0, pos=(0, 0), size=(0.4, 0.4),
    color=[1,1,1], colorSpace='rgb', opacity=None,
    flipHoriz=False, flipVert=False,
    texRes=128.0, interpolate=True, depth=-2.0)
response_tristeza = visual.ImageStim(
    win=win,
    name='response_tristeza', 
    image='imagens/response_tristeza.png', mask=None,
    ori=0.0, pos=(0.5, 0), size=(0.4, 0.4),
    color=[1,1,1], colorSpace='rgb', opacity=None,
    flipHoriz=False, flipVert=False,
    texRes=128.0, interpolate=True, depth=-3.0)
response_medo = visual.ImageStim(
    win=win,
    name='response_medo', 
    image='imagens/response_medo.png', mask=None,
    ori=0.0, pos=(-0.5, -0.5), size=(0.4, 0.4),
    color=[1,1,1], colorSpace='rgb', opacity=None,
    flipHoriz=False, flipVert=False,
    texRes=128.0, interpolate=True, depth=-4.0)
response_nojo = visual.ImageStim(
    win=win,
    name='response_nojo', 
    image='imagens/response_nojo.png', mask=None,
    ori=0.0, pos=(0, -0.5), size=(0.4, 0.4),
    color=[1,1,1], colorSpace='rgb', opacity=None,
    flipHoriz=False, flipVert=False,
    texRes=128.0, interpolate=True, depth=-5.0)
response_surpresa = visual.ImageStim(
    win=win,
    name='response_surpresa', 
    image='imagens/response_surpresa.png', mask=None,
    ori=0.0, pos=(0.5, -0.5), size=(0.4, 0.4),
    color=[1,1,1], colorSpace='rgb', opacity=None,
    flipHoriz=False, flipVert=False,
    texRes=128.0, interpolate=True, depth=-6.0)
response_alegria.text = "alegria"
response_raiva.text = "raiva"
response_tristeza.text = "tristeza"
response_medo.text = "medo"
response_nojo.text = "nojo"
response_surpresa.text = "surpresa"
emocoes_video_helper = visual.TextStim(win=win, name='emocoes_video_helper',
    text='Selecione a emoção',
    font='Arial',
    pos=(0, 0.5), height=0.075, wrapWidth=None, ori=0.0, 
    color='white', colorSpace='rgb', opacity=None, 
    languageStyle='LTR',
    depth=-8.0);

# Initialize components for Routine "instructions_end_3"
instructions_end_3Clock = core.Clock()
instrucoes_png_fim_6 = visual.ImageStim(
    win=win,
    name='instrucoes_png_fim_6', 
    image='instructions3/instructions3.009.png', mask=None,
    ori=0.0, pos=(0, 0), size=(1, 1),
    color='white', colorSpace='rgb', opacity=None,
    flipHoriz=False, flipVert=False,
    texRes=128.0, interpolate=True, depth=0.0)
end_key_6 = keyboard.Keyboard()

# Create some handy timers
globalClock = core.Clock()  # to track the time since experiment started
routineTimer = core.CountdownTimer()  # to track time remaining of each (non-slip) routine 

I see. What you’re trying to do is actually going to be a bit more complicated than that. I think this thread describes what you’re going to need to do to start with: