FAQ: How can I control the frequency of actions (e.g. Drift Checks) with modulo
#1
Summary
When creating tasks in Experiment Builder,  the ‘%’ (modulo) operator can be used to control when actions occur, for example, only completing a drift-check action every 10 trials. The modulo operator returns the remainder value after division, for example, 10%10 returns no remainder (0), 12%10 returns 2, 24%6 returns 0 etc.

Implementing a modulo operator within a Conditional Trigger
The modulo operator is particularly useful within Conditional Triggers, as you can input the modulo equation as the attribute, e.g. =trial_iteration.value%2, and set the comparator to EQUALS and the value to 0 (for no remainders) - i.e.=trial_iteration.value%2 == 0 will be true on every second trial. When the remainder of the modulo equation is 0, the conditional trigger is True - so the experimental flow follows the True (tick) path to drift check, when the remainder is not 0 the conditional evaluates to false (x) and the drift-check is skipped.

The example below uses the modulo operator in a Conditional Trigger to return the remainder value when the Trial sequence iteration number (the current trial number)-1 is divided by 10. If there is no remainder (it returns 0) the true path of the trigger leads to a Drift Check,  the false path links straight to the Recording Sequence. The trial iteration number -1 is used as these drift-check trials begin after 10 completed trials (so at the beginning of the 11th, 21st, the 31st  trial etc.).