Feedback on 1-back task with mouse response (also relevant to go-nogo paradigms)

PsychoPy version: 1.85.3
What are you trying to achieve?:

I am trying to implement a 1-back task in which the participant sees a sequence of images that can either be Image A or Image B. For each image (aside from the first one), the participant should click on the image if it is a repeat of the preceding image, and do nothing if it is different (the trial ends automatically if no click has been made after 4s). After each trial, the participant should receive accuracy feedback (i.e., correct if clicked for a repeat OR not clicked for a non-repeat, and incorrect if clicked for a non-repeat OR if not clicked for a repeat).

So far, my implementation of this task provides the appropriate feedback if the participant does make a mouse click (i.e., tells the participant they were correct if they clicked when they were supposed to, or incorrect if they clicked when they shouldn’t have). However, I don’t know how to set up the appropriate feedback for trials in which the participant does NOT click (i.e., correct for not clicking on a non-repeat or incorrect for not clicking on a repeat). My current setup tells participants they’re correct when they don’t click, regardless of whether that was actually correct. I’ve seen similar questions on this forum for go-no go tasks with keyboard responses, but don’t know how to implement this for mouse responses.

My current setup in builder consists of a loop within which are the following routines:

Routine 1: Presents stimulus Image A or B (based on a conditions file) & allows a mouse response for a finite amount of time (4s). Also includes a code element with the following code under “Each Frame”:

if mouse.isPressedIn(stimulus):
       #Check mouse click against a column, stimulus_Corr, in the conditions file   
       #that specifies the name of the image file shown as the stimulus IF it is a
       #repeat of the image shown on the previous trial, and is blank otherwise.
       #The accuracy of the click is stored both in the data output and as 
       #"practice_resp" which is used to determine feedback in the next routine
       if stimulus.image == stimulus_Corr:
             thisExp.addData('practice_correct', 1)
             practice_resp = 1
       else:
             thisExp.addData('practice_correct', 0)
             practice_resp = 0
       continueRoutine = False
       break

I suspect that, to achieve what I want, this code must be edited to set the value of “practice_resp” to 0 or 1 if the mouse is NOT clicked (depending on whether not clicking was the right option), but I’m not sure how.

Routine 2: Includes only a code element, with this in the Begin Experiment tab:

nRepsCorr = 0
nRepsIncorr = 0

and this in the Begin Routine tab:

if practice_resp == 1:
    nRepsCorr = 1
    nRepsIncorr = 0
else:
    nRepsCorr = 0
    nRepsIncorr = 1

Routine 3: Correct feedback screen. Currently just shows a green polygon for 1s & has its own loop where nReps$ is set to nRepsCorr

Routine 4: Same as 3, but shows a red polygon and nReps$ is set to nRepsIncorr

Something like this:

Each Frame:

if mouse.isPressedIn(stimulus):
    if stimulus.image == stimulus_Corr:
        practice_resp = 1 # correct click
    else:
        practice_resp = 0 # incorrect click
    continueRoutine = False
else:
    practice_resp = -1  # no click.
    # will continue with the routine.

End routine:

if practice_resp == -1: # no click made during routine
    if stimulus.image == stimulus_Corr:
        practice_resp = 0 # incorrect non-click
    else:
        practice_resp = 1 # correct non-click

# for all responses/non-responses, store the data:
thisExp.addData('practice_correct', practice_resp)

That appears to work great, thank you very much!