Skip to content

Add minimum trial threshold to bias intervention - #160

Open
micahwoodard wants to merge 2 commits into
mainfrom
fix-174-min-trials-antibias
Open

Add minimum trial threshold to bias intervention#160
micahwoodard wants to merge 2 commits into
mainfrom
fix-174-min-trials-antibias

Conversation

@micahwoodard

@micahwoodard micahwoodard commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_threshold to BiasInterventionParameters and enforce it in are_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.

Comment on lines +32 to +34
trial_threshold: Optional[int] = Field(
default=None,
ge=0,
Comment on lines +1433 to +1439
/// <summary>
/// Minimum number of trials that must elapse before anti-bias intervention can trigger. Bias is unreliable with few trials, so interventions are suppressed until this threshold is reached. If None, no minimum trial threshold is enforced.
/// </summary>
[Newtonsoft.Json.JsonPropertyAttribute("trial_threshold")]
[System.ComponentModel.DescriptionAttribute("Minimum number of trials that must elapse before anti-bias intervention can trigg" +
"er. Bias is unreliable with few trials, so interventions are suppressed until th" +
"is threshold is reached. If None, no minimum trial threshold is enforced.")]
intervention_interval: int = 10,
total_offset: float = 0.0,
threshold: BiasThreshold = BiasThreshold(upper=0.7, lower=0.3),
trial_threshold: int = 100,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants