Our lab is implementing an experiment using eye-tracking in PsychoPy builder version 2023.1.3 on macOS Sonoma 14.3.1. We are running into the problem that sometimes the eye-tracking validation routine fails to find any points and a ZeroDivisionError
is thrown. The specific error message we get is:
“/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/iohub/client/eyetracker/validation/procedure.py”, line 626, in _createValidationResults
mean_error = summed_error / point_count
ZeroDivisionError: float division by zero
################ Experiment ended with exit code 1 [pid:77355] ################
As far as we know, we believe that this error is unrecoverable. This error is very annoying, since when we use an eye-tracking validation routine in the middle of our experiment, and the experiment crashes, we lose all the resources we spent running the first half of the experiment. Our principal goal is to implement a loop around the eye-tracking validation routine so that an experimenter can redo the validation until they get a good enough result.
The two main questions we have are:
1. Is there a way to recover from this error and continue the experiment in PsychoPy builder version 2023.1.3? (We detail our reasoning for why it’s an unrecoverable error below.)
2. If not, is this bug fixed in a more up-to-date version of the PsychoPy builder?
We believe that this error is unrecoverable due to the following two reasons. First, the eye-tracking validation component compiles to code that is separate from the code location and scoping that we get from a custom code block. This means that we cannot use a custom code block to place a try/catch statement before or after the eye-tracking validation routine.
Second, manually placing a try/catch statement around the offending line (which happens to be validation.run()
) is highly nontrivial due to the fragility of the scheduling produced by the builder’s compiling process. We tried placing a loop around the validation routine, with a custom code block before and after the validation routine, and manually inserted a try/catch statement around one of the validation.run()
lines. We were able to catch the ZeroDivisionError, but this led to a program crash later. We hypothesize the later crash happened due to the program trying to do something with the uninitialized validation result, such as recording it in the experiment output data.
Thanks so much for your help,
Tal