Hi!
I have a time-sensitive task in which participants will be presented with a stimulus and two response options on the screen, three tones will be played, and they need to respond with pressing either right or left arrow keys when the third tone is being played.
Three things might happen based on their response timing and accuracy:
-
“too soon”: regardless of response accuracy, the participants press the key quicker than they should (i.e. keytonediff and the 0.1 second tolerance)
-
“too late”: regardless of response accuracy, the participants press the key slower than they should (i.e. keytonediff and the 0.1 second tolerance)
-
“on time” : the participants press the key the exact same time as than they should (i.e. keytonediff and the 0.1 second tolerance) so the code will check the response accuracy and enables the outcome loops (i.e. correctloop or incorrect loop) based on it.
Below is the python code that I use on Psychopy locally and it does what I want it to do:
if rightleft_choice_training.keys:
keyToneDiff = 1.2-t
keypressTime = tThisFlipGlobal
keyPressed = rightleft_choice_training.keys
rightleft_choice_training.keys = []
rightleft_choice_training.status = FINISHED
continueTxt.status = FINISHED
continueKey.status = FINISHED
if keyPressed == CorrResp:
trialCorrect = 1
else:
trialCorrect = 0
if keyToneDiff >= (0.1+frameTolerance):
feedbackTxt = "Too soon!"
timeFeedback.setAutoDraw(True)
timeFeedback.status == STARTED
timeFeedback.tStartRefresh = tThisFlipGlobal
elif keyToneDiff <= (-0.1-frameTolerance):
feedbackTxt = "Too late!"
timeFeedback.color = 'red'
timeFeedback.setAutoDraw(True)
timeFeedback.status == STARTED
timeFeedback.tStartRefresh = tThisFlipGlobal
else:
feedbackTxt = "On time!"
timeFeedback.color = "green"
timeFeedback.setAutoDraw(True)
timeFeedback.status == STARTED
timeFeedback.tStartRefresh = tThisFlipGlobal
if trialCorrect == 1:
correctReps = 1
points = points + 95
else:
incorrectReps = 1
points = points - 5
My JS code (with the explanation of the issue below):
if (rightleft_choice_training.keys) {
keyToneDiff = (1.2 - t);
keypressTime = globalClock.getTime();
keyPressed = rightleft_choice_training.keys;
rightleft_choice_training.keys = [];
rightleft_choice_training.status = PsychoJS.Status.FINISHED;
continueTxt.status = PsychoJS.Status.FINISHED;
continueKey.status = PsychoJS.Status.FINISHED;
if ((keyPressed === CorrResp)) {
trialCorrect = 1;
} else {
trialCorrect = 0;
}
if (keyToneDiff >= 0.1) {
feedbackTxt = "Too soon!";
timeFeedback.color = "red";
timeFeedback_Dev.setAutoDraw(true);
timeFeedback_Dev.status === PsychoJS.Status.STARTED;
timeFeedback_Dev.tStartRefresh = globalClock.getTime();
} else if (keyToneDiff <= -0.1) {
feedbackTxt = "Too late!";
timeFeedback.color = "red";
timeFeedback.setAutoDraw(true);
timeFeedback.status === PsychoJS.Status.STARTED;
timeFeedback.tStartRefresh = globalClock.getTime();
} else {
feedbackTxt = "On time!";
timeFeedback.color = "green";
timeFeedback.setAutoDraw(true);
timeFeedback.status === PsychoJS.Status.STARTED;
timeFeedback.tStartRefresh = globalClock.getTime();
if (trialCorrect === 1) {
correctReps = 1;
points = points + 95;
} else {
incorrectReps = 1;
points = points - 5;
}
}
}
Problem on Pavlovia:
I get overlapping and chaotic feedback texts on screen “on time” and “too late” at the same time regardless of my response accuracy and my key responses are not being evaluated correctly (also, despite responding correctly and seeing the message “on time!”, it doesn’t lead me to the correct_loop). I think something should be wrong with the timings, especially after I removed frameTolerance from my JS code since it was causing an error on Pavlovia (not on Psychopy).
I just set my project to public (internal) for you to kindly take a look ( (IMPORTANT: please check RL_Task_cost.psyexp not the old one)
https://gitlab.pavlovia.org/Parnianrafei/rl_task
URL of experiment:
https://run.pavlovia.org/Parnianrafei/rl_task/?__pilotToken=70efdf2ec9b086079795c442636b55fb&__oauthToken=12f71e2f405ccb6cf54b617a56a056743ef66f3b5207985d3c2ab29d4dd7c6fb
I would be more than grateful if someone with more experience can take a look and help me – THANKS!