Add minimum trial threshold to bias intervention - #160
Conversation
…rly interventions (issue #174)
There was a problem hiding this comment.
Pull request overview
This PR introduces an optional “minimum trial threshold” gate for anti-bias interventions so that corrections don’t trigger until enough trials have elapsed, then propagates the new field through schemas/generated code and updates tests accordingly.
Changes:
- Add
trial_thresholdtoBiasInterventionParametersand enforce it inare_antibias_conditions_met(...). - Pass session trial count into bias-intervention checks from the block-based trial generator.
- Regenerate schemas / generated bindings and extend unit tests for the new threshold behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/aind_behavior_dynamic_foraging/task_logic/interventions/bias_intervention.py |
Adds trial_threshold parameter and gates intervention triggering based on n_trials. |
src/aind_behavior_dynamic_foraging/task_logic/trial_generators/block_based_trial_generator.py |
Passes len(outcome_history) into are_antibias_conditions_met(...) to supply n_trials. |
tests/test_interventions/test_bias_intervention.py |
Updates call sites to pass n_trials and adds explicit tests for trial_threshold. |
tests/trial_generators/test_block_based_trial_generator.py |
Extends test helper to pass trial_threshold into parameters; updates some tests to override it. |
src/Extensions/AindBehaviorDynamicForaging.Generated.cs |
Regenerated C# model includes TrialThreshold property and printing. |
schema/aind_behavior_dynamic_foraging.json |
Regenerated JSON schema includes trial_threshold. |
schema/uncoupled.json |
Regenerated example/config includes trial_threshold. |
schema/uncoupled_baiting.json |
Regenerated example/config includes trial_threshold. |
schema/coupled_baiting.json |
Regenerated example/config includes trial_threshold. |
Suppressed comments (1)
src/aind_behavior_dynamic_foraging/task_logic/interventions/bias_intervention.py:81
- Docstring references a non-existent parameter name (parameters.min_trials_for_bias_intervention). The actual field added is parameters.trial_threshold, so this documentation is misleading and will confuse future maintenance.
Intervention is only considered once ``n_trials`` has reached
``parameters.min_trials_for_bias_intervention`` and
``trials_in_bias_intervention`` exceeds ``parameters.intervention_interval``.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| intervention_interval: int = 10, | ||
| total_offset: float = 0.0, | ||
| threshold: BiasThreshold = BiasThreshold(upper=0.7, lower=0.3), | ||
| trial_threshold: int = 100, |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
tests/trial_generators/test_block_based_trial_generator.py:77
- The anti-bias generator test helper now defaults
trial_thresholdto 100, but these tests don't populategen.outcome_history, son_trialspassed fromlen(self.outcome_history)is 0 and anti-bias interventions won't actually trigger. This can make assertions pass vacuously (e.g.,is_auto_reward_rightstaysNone). Consider defaulting this helper'strial_thresholdto 0 (tests that specifically cover the threshold are already intests/test_interventions/test_bias_intervention.py).
trial_threshold: int = 100,
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Add minimum trial threshold to bias interventions, regenerates all of the schemas, and updates and adds tests. Default is 100. Relevant file changes at src\aind_behavior_dynamic_foraging\task_logic\interventions\bias_intervention.py. Fixes #174