If this template helps then use it. If not then just delete and start from scratch.
OS (e.g. Win10):
PsychoPy version (2022.2.5):
What are you trying to achieve?:
For my study, participants will detect a target and I would like to have a longer duration feedback msg whenever they miss detecting the target. And they will see Incorrect… Automation Recalibrating screen longer than the Correct! screen. I am not familiar with python or coding in general, and was wondering if there was a code to add the condition of delaying before moving onto the next stimuli when they get it wrong.
This is what I have so far:
Hi, so you would just need to add another variable after line 3 and line 6 that controls the duration of the text or textbox component. For example:
if XrayKBRespA50.corr:
msg = "Correct!"
msgColor = "green"
msgDuration = "2" # screen will last 2 seconds
else:
msg = "Incorrect..."
msgColor = "red"
msgDuration = "5" # screen will last 5 seconds
And then use this msgDuration
variable in the duration field of your message component
I added the code after line 3 and 6, and added $msgDuration to the duration field in the message component; however, it just exits the session after applying the keyboard response and doesn’t show the feedback screen.
Do you mean that the experiment crashed or did it just proceed to the next trial without the feedback screen?
If it crashed, would you mind sharing the error message? You can find this at the stdout window on the runner view window.
If it didn’t crash, would you mind sharing your psyexp file with me?
The experiment crashed after responding to the first image.
Traceback (most recent call last):
File “F:\AutoVizExperiments\Condition A\VizAutoExpAB_lastrun.py”, line 529, in
if frameN >= (TrialFB.frameNStart + msgDuration):
TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’
################ Experiment ended with exit code 1 [pid:17384] #################
61.9495 EXP Imported A50BStimuliList.xlsx as conditions, 60 conditions, 5 params
61.9602 EXP Imported A70BStimuliList.xlsx as conditions, 60 conditions, 5 params
61.9704 EXP Imported A90BStimuliList.xlsx as conditions, 60 conditions, 5 params
61.9705 WARNING duplicate variable names: AI_Classify, CorrAns, Block, Trial_Type, Image_File
61.9723 INFO Loaded monitor calibration from [‘2023_03_28 15:16’]
Yes so your task has crashed. Would you mind sending me your psyexp file?
Update: I figured it out, and excluded " " for the seconds.
if XrayKBRespA50.corr:
msg = “Correct!”
msgColor = “green”
msgDuration = 2 # screen will last 2 seconds
else:
msg = “Incorrect…”
msgColor = “red”
msgDuration = 5 # screen will last 5 seconds
1 Like