Skip to content

Commit 8b7fda8

Browse files
dvbridgespeircej
authored andcommitted
BF: Save data when calling loop.finished in nested loop
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.
1 parent e1bca1b commit 8b7fda8

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎psychopy/experiment/components/settings/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,10 @@ def writeEndCodeJS(self, buff):
794794
" return function () {\n"
795795
" // ------Check if user ended loop early------\n"
796796
" if (currentLoop.finished) {\n"
797+
" // Check for and save orphaned data\n"
798+
" if (Object.keys(psychoJS.experiment._thisEntry).length > 0) {\n"
799+
" psychoJS.experiment.nextEntry();\n"
800+
" }\n"
797801
" thisScheduler.stop();\n"
798802
" } else if (typeof thisTrial === 'undefined' || !('isTrials' in thisTrial) || thisTrial.isTrials) {\n"
799803
" psychoJS.experiment.nextEntry();\n"

0 commit comments

Comments
 (0)