Skip to content


BF: Save data when calling loop.finished in nested loop
Browse files Browse the repository at this point in the history
In a nested loop, with the outerloop isTrials is False, and the
inner loop isTrials is True, a participant ending their inner loop
on the first iteration, but has repeating inner loop n times based on number
of trials in the outerloop, will not have data saved. This is because
breaking the inner loop on the first iteration does not call nextExtry(),
and the outer loop where isTrials is False does not call nextEntry().
Calling at the end of the task will only write the last trial recorded.
This fix calls nextEntry in endLoopIteration() when currentLoop
 is true and orphan data exists.
  • Loading branch information
dvbridges authored and peircej committed Jul 3, 2019
1 parent e1bca1b commit 8b7fda8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions psychopy/experiment/components/settings/
Expand Up @@ -794,6 +794,10 @@ def writeEndCodeJS(self, buff):
" return function () {\n"
" // ------Check if user ended loop early------\n"
" if (currentLoop.finished) {\n"
" // Check for and save orphaned data\n"
" if (Object.keys(psychoJS.experiment._thisEntry).length > 0) {\n"
" psychoJS.experiment.nextEntry();\n"
" }\n"
" thisScheduler.stop();\n"
" } else if (typeof thisTrial === 'undefined' || !('isTrials' in thisTrial) || thisTrial.isTrials) {\n"
" psychoJS.experiment.nextEntry();\n"
Expand Down

0 comments on commit 8b7fda8

Please sign in to comment.