URL of experiment: dual-d-detection [PsychoPy]
code: https://gitlab.pavlovia.org/matteo_lab/dual-d-detection
Description of the problem:
Dear all
I am new to psychopy, javascript (and online experiments in general) but, thanks to all the tutorials and useful advice on this forum, I have managed to set up my experiment, which has a relatively complex structure: participants have to make 2 decisions sequentially each trial, with the stimulus for decision 2 being determined by the correctness of the response to decision 1 (similar to this https://www.nature.com/articles/s41562-020-00953-1 but with detection task rather than discrimination).
Overall the experiment works as intended except for for the online adjustment of difficulty.
What it should do is keeping track of the accuracy of responses to the first decision, then every N trials (currently set to N=10) it should increase/decrease the contrast of the stimulus depending on whether the accuracy is below/above a certain range (currently set to 0.65, 0.75).
To achieve that, what I have done is create a routine that every N trials check the accuracy of the last N responses and adjust the contrast parameter (also offers the chance to take a break). In particular the routine has this javascript code:
nTrialsSoFar = psychoJS.experiment._trialsData.length;
nCorr = 0;
eachResp = 0;
for (eachResp=nTrialsSoFar-9; eachResp<nTrialsSoFar; eachResp++)
{
nCorr += psychoJS.experiment._trialsData[eachResp]['key_resp.corr'];
}
acc_current = nCorr/10;
if ((acc_current > 0.75)) {
contrast_lvl = (contrast_lvl - 1);
}
if ((acc_current < 0.65)) {
contrast_lvl = (contrast_lvl + 1);
}
if ((contrast_lvl < 1)) {
contrast_lvl = 1;
}
if ((contrast_lvl > 10)) {
contrast_lvl = 10;
}
where key_resp
is the name of the keyboard component that I want to use to monitor accuracy
While on the one hand it seems to work (I can reach the point in the experiment where I can take a break and continue without problems) however the contrast of the stimulus does not seem to change, regardless of how many errors/correct responses I make.
I am not sure of what I am doing wrong here, any help/advice would be greatly appreciated.
Thanks!