OS: Win11 Pro PsychoPy version: 2021.2.3 Standard Standalone? : yes What are you trying to achieve?: go/no-go experiment
What did you try to make it work?: I show a fractal, then a target image (containing left/right targets), and based on these information, participant presses a key. Based on these three (fractal, target and key press), I should show a feedback image. The feedback is probabilistic and has many different conditions, so I have coded it.
I have defined a function that should create a window and based on the if loops, show the correct image using the visual.ImageStim function, for 1 second.
What specifically went wrong when you tried that?: It doesn’t show the feedback images. It It seems like it doesn’t even notice the code component.
Thanks @wakecarter, did so, but still doesn’t work.
Here’s my script, I don’t think there’s an error in it, because I ran it in the coder and it works. Maybe it’s because I define a window and want to access the screen on top of the ongoing use of screen in the experiment?
rp = 0.8 # reward probability
positive = 'C:/Users/zahra/Desktop/tasks/gonogo/feedback/positive.jpg'
negative = 'C:/Users/zahra/Desktop/tasks/gonogo/feedback/negative.jpg'
nothing = 'C:/Users/zahra/Desktop/tasks/gonogo/feedback/nothing.jpg'
if fractals == 'gw.png':
if targets == 'right.png':
if Key_Resp.keys == 'right':
if np.random.rand() < rp:
show_feedback(positive)
else:
show_feedback(nothing)
elif Key_Resp.keys == 'left':
show_feedback(negative)
elif Key_Resp.keys == 'None':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(positive)
elif targets == 'left.png':
if Key_Resp.keys == 'right':
show_feedback(negative)
elif Key_Resp.keys == 'None':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(positive)
elif Key_Resp.keys == 'left':
if np.random.rand() < rp:
show_feedback(positive)
else:
show_feedback(nothing)
elif fractals == 'gnl.png':
if targets == 'right.png':
if Key_Resp.keys == 'right':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(negative)
elif Key_Resp.keys == 'left':
show_feedback(negative)
elif Key_Resp.keys == 'None':
if np.random.rand() < rp:
show_feedback(negative)
else:
show_feedback(nothing)
elif targets == 'left.png':
if Key_Resp.keys == 'right':
show_feedback(negative)
elif Key_Resp.keys == 'left':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(negative)
elif Key_Resp.keys == 'None':
if np.random.rand() < rp:
show_feedback(negative)
else:
show_feedback(nothing)
elif fractals == 'ngw.png':
if targets == 'right.png':
if Key_Resp.keys == 'right':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(positive)
elif Key_Resp.keys == 'left':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(positive)
elif Key_Resp.keys == 'None':
if np.random.rand() < rp:
show_feedback(positive)
else:
show_feedback(nothing)
elif targets == 'left.png':
if Key_Resp.keys == 'right':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(positive)
elif Key_Resp.keys == 'left':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(positive)
elif Key_Resp.keys == 'None':
if np.random.rand() < rp:
show_feedback(positive)
else:
show_feedback(nothing)
elif fractals == 'ngnl.png':
if targets == 'right.png':
if Key_Resp.keys == 'right':
if np.random.rand() < rp:
show_feedback(negative)
else:
show_feedback(nothing)
elif Key_Resp.keys == 'left':
if np.random.rand() < rp:
show_feedback(negative)
else:
show_feedback(nothing)
elif Key_Resp.keys == 'None':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(negative)
elif targets == 'left.png':
if Key_Resp.keys == 'right':
if np.random.rand() < rp:
show_feedback(negative)
else:
show_feedback(nothing)
elif Key_Resp.keys == 'left':
if np.random.rand() < rp:
show_feedback(negative)
else:
show_feedback(nothing)
elif Key_Resp.keys == 'None':
if np.random.rand() < rp:
show_feedback(nothing)
else:
show_feedback(negative)
Your code is in Begin Routine, which is before any key will be pressed. If you want to keep checking for a response then it needs to be in Each Frame.
If a key press ends the routine, then you could put the code in End Routine and then have the feedback in the following routine (or your pop-up might work in End Routine).