In my task, one of two tones (e.g. 440 and 3523 hz) are sequentially
presented. Participants have to react only on high tone with the button “h” (no
reaction should take place when the other tones is presented).
For correct answers participants should get no feedback, when they
missed to react to a high tone they should get a “Missed” feedback and when
they pressed the “h” button in all the other trials they should get a “False
alarm” feedback.
My Excel table looks like this:
Hz corrAns
440 h
440 h
523
440 h
523
I implemented the following code in the “each frame” window which does not work:
if resp.corr:
msg = ""
elif resp.keys is not None and "h" in resp.keys and int(Hz) == 440:
msg = "False alarm"
else:
msg = "Missed"
However, the tones (150 ms duration) are sometimes longer or shorter. Additionally, the feedback (150 ms) is presented about 1 trial to late. Do I have to pay attention to something specific when tones and feedback are presented so shortly?
The code component must be above the text component so that the text component gets access to the current value of msg (i.e. the one set in code for this trial). Otherwise, it will still be using the value from the previous trial.
Thank you very much m-macaskill, it works!
May I ask you another question concerning my task.
How can I set a fixed time for responses. In my task, immediately after my response the next tone is presented. How can I tell PsychoPy that it should wait before the next tone is presented, even when I made a response?
The easiest thing to do is set a non-zero start time for your audio stimulus, so that it does not play immediately. Or alternatively, insert another routine after the first one which just shows a blank screen, or whatever is on screen on the first routine, for a particular period of time.