Controlling the frequence of calibration/validation routines

OS (e.g. Win10): Windows 10
PsychoPy version (e.g. 1.84.x): v2021.2.3
Standard Standalone? (y/n) : Yes
**What are you trying to achieve?: I’m trying to insert calibration routines inside my experiment. My experiment is basically a big psychopy loop, searching for different items in the excel files for each routine. I would like to insert in this loop something like :

Each N repeat, run the calibration routine.

However, I can’t put code in the eyetracking builder modules, for they are not alike the other ones. It seems to be a routine of its own, and cannot have additionnal components.

In my experiments, I have sentences that you have to read, and after some sentences, but not all, a comprehension question is asked. To have it so that the Question routine doesn’t run when there are no questions, I have added a bit of code in the Question routine that goes like this :

if questionPresent == 0:
continueRoutine = False

questionPresent being an additionnal column that I added to my excel file. So the routine can be skipped anytime I say so in the excel file, wich is what I want. I can’t do that for the calibration code, however, since I cannot add a code module into my calibration routine.

So, I tried to link my questions, for wich I can control the appearances, with the calibrations, using a loop. I’ve created a Loop containing the Question routine and the Calibration routine. The problem is that when I skip the question routine with continueRoutine = False, the rest of the loop, so the Calibration routine, does not skip. I’ve tried adding to my condition NameOfLoop.finished = True, or trials.finished = True, thinking it will skip the rest of the loop, including the calibration routine, but it didn’t. I think it only stop the loop from repeating, but does not end the rest of the routines included in the loop.

Is there a way to add code in an Eyetracking routine?
Is there a way to add a calibration procedure as a stimuli of a routine, instead of as a whole routine?
Is there a way to interrupt the whole loop with a bit of code that I could add to the already existing code of my Question routine?

If the answers to those questions is all “no”, I ask this : Is there a way to control, without having to unfold my loop into 150 routines, the frequency at wich the calibration routine appears?

Thank you very much for the time invested in answering my question.


Ok, so I think I found a solution, but it implies going out of the builder and directly into the code. If I enter in the python version of my experiment, I can put the calibration routine into an if loop, and apply my conditions there. What I don’t like about it is that I can’t save other changes from the builder without overwriting my changes directly in the code, so this will have to be my last modification before testing subjects with my experiment.