# Feedback to keypress not working on certain trials

URL of experiment: https://gitlab.pavlovia.org/lbdlpsych/tiny

Description of the problem:

This task is a version of a go/no-go task. There are 4 unique stimuli that correspond to four conditions: go/win, go/lose, no-go/win, no-go/lose. The go/no-go refers to whether the optimal response is to press the spacebar or to refrain from pressing the spacebar. The win/lose refers to the feedback – whether the participant is rewarded for their correct response or punished for their incorrect response. These feedback are presented by changing the background color to either green (for correct), yellow (which may be correct or incorrect depending on the condition) or red (for incorrect). The sham variable changes which response is rewarded for the trial for a probabilistic reinforcement proportion of 80/20 (sham = 1: normal, 80% of the time; sham = 2: opposite, 20% of the time).

This is the code (in the code component for the feedback routine in begin routine):

``````if action == 'go' and reward == 'win':
optimalResp = targetSide
if sham == 1: #high probability trials
if targetPress.keys == optimalResp:
sawOutcome = 0.25
optimalCorrect = 1
yFBvar=0
gFBvar=1
rFBvar=0
else:
sawOutcome = 0
optimalCorrect = 0
yFBvar=1
gFBvar=0
rFBvar=0
else: #low probability trials (sham 2)
if targetPress.keys == optimalResp:
sawOutcome = 0
optimalCorrect = 1
yFBvar=1
gFBvar=0
rFBvar=0
else:
sawOutcome = 0.25
optimalCorrect = 0
yFBvar=0
gFBvar=1
rFBvar=0

if action == 'go' and reward == 'lose':
optimalResp=targetSide
if sham == 1:
if targetPress.keys == optimalResp:
sawOutcome = 0
optimalCorrect = 1
yFBvar=1
gFBvar=0
rFBvar=0
else:
sawOutcome = -0.10
optimalCorrect = 0
yFBvar=0
gFBvar=0
rFBvar=1
else:
if targetPress.keys == optimalResp:
sawOutcome = -0.10
optimalCorrect = 1
yFBvar=0
gFBvar=0
rFBvar=1
else:
sawOutcome = 0
optimalCorrect = 0
yFBvar=1
gFBvar=0
rFBvar=0

if action == 'nogo' and reward == 'win':
optimalResp=None
if sham == 1:
if targetPress.keys == optimalResp:
sawOutcome = 0.25
optimalCorrect = 1
yFBvar=0
gFBvar=1
rFBvar=0
else:
sawOutcome = 0
optimalCorrect = 0
yFBvar=1
gFBvar=0
rFBvar=0
else:
if targetPress.keys == optimalResp:
sawOutcome = 0
optimalCorrect = 1
yFBvar=1
gFBvar=0
rFBvar=0
else:
sawOutcome = 0.25
optimalCorrect = 0
yFBvar=0
gFBvar=1
rFBvar=0

if action == 'nogo' and reward == 'lose':
optimalResp=None
if sham == 1:
if targetPress.keys == optimalResp:
sawOutcome = 0
optimalCorrect = 1
yFBvar=1
gFBvar=0
rFBvar=0
else:
sawOutcome = -0.10
optimalCorrect = 0
yFBvar=0
gFBvar=0
rFBvar=1
else:
if targetPress.keys == optimalResp:
sawOutcome = -0.10
optimalCorrect = 1
yFBvar=0
gFBvar=0
rFBvar=1
else:
sawOutcome = 0
optimalCorrect = 0
yFBvar=1
gFBvar=0
rFBvar=0
``````

targetPress is the name of the keypress (for both practice and real trials). targetSide is always “space” and is defined in a list that is read into the loop. The FBvar is then piped into the opacity of three rectangles that are green, yellow, and red so that only one is made for each trial.

This code works for the actual trials feedback, but for some reason, it is not working on the “go” conditions during the practice trials (the no-go conditions work). In the go conditions, regardless of whether you press the space or not, it gives feedback as if you did not press the space. In the no-go conditions, it gives the correct feedback when you do or don’t press the spacebar, which leads me to believe that it is not a problem with the task not recording the space press. If noteworthy, the sham variable = 1 for every trial in the practice.

It is not a problem with the autotranslate of the word “None.” I manually edited the JS side to translate it to undefined rather than null. I really have no other ideas of what could be wrong, so any guidance would be so appreciated - thanks!

Hi, Sorry but did you manage to fix this issue? As I am having the same issue with my go/no go experiment

Sorry I just now saw this. I figured I would reply even though I hope you’ve been able to figure it out in the meanwhile. Javascript has slightly different uses for different numbers of equals signs. === means strict equivalence, while == means less strict equivalence. In general, it is much better to use === to determine equivalency. However, in this situation, it works if you use ==, not ===, because JS will recognize that the spacebar press is the same as “space” only in less strictly equivalent terms.

I would check the JS side of your code, and manually edit it to be == because the autotranslate will translate it to === from Python.