Skip to content

Adds explicit metadata for bias intervention#130

Merged
micahwoodard merged 1 commit into
mainfrom
feat-add-bias-intervention-metadata
Jul 8, 2026
Merged

Adds explicit metadata for bias intervention#130
micahwoodard merged 1 commit into
mainfrom
feat-add-bias-intervention-metadata

Conversation

@micahwoodard

Copy link
Copy Markdown
Collaborator

Adds explicit metadata for bias intervention to make it easier to determine autowater vs bias reward

@bruno-f-cruz

Copy link
Copy Markdown
Member

I don't quite understand the meaning of these variables, so I will leave it up to you and the team to decide if this makes sense to implement and maintain or not.

From a technical implementation point of view, this looks great and follows the pattern we engineered. The only small note that I would have is: is there a world where you store the value of the manipulation as Optional[T], instead of a boolean flag? I am afraid that you will also need the value itself, in which case you may as well bite the bullet now.

@bruno-f-cruz bruno-f-cruz removed their request for review July 7, 2026 19:55
@micahwoodard

Copy link
Copy Markdown
Collaborator Author

@alexpiet do these variable and types make sense to you? I added them only for data analysis purposes so I can implement whatever makes the most sense and is easiest for you to use

@alexpiet alexpiet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, looks good. Thanks for adding it.

As an aside, I don't like the walrus operator (:=), but I'll leave that to you

@alexpiet

alexpiet commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

From a technical implementation point of view, this looks great and follows the pattern we engineered. The only small note that I would have is: is there a world where you store the value of the manipulation as Optional[T], instead of a boolean flag? I am afraid that you will also need the value itself, in which case you may as well bite the bullet now.

I can't think of a reason you would want the bias intervention as optional. You are either doing an intervention, or you are not.

@bruno-f-cruz

Copy link
Copy Markdown
Member

From a technical implementation point of view, this looks great and follows the pattern we engineered. The only small note that I would have is: is there a world where you store the value of the manipulation as Optional[T], instead of a boolean flag? I am afraid that you will also need the value itself, in which case you may as well bite the bullet now.

I can't think of a reason you would want the bias intervention as optional. You are either doing an intervention, or you are not.

I may be misunderstanding on kind of information you would want here. The manipulation has a corresponding value to it (T) (e.g., the distance you moved the spout, the probability you changed the reward by, etc...). A boolean will tell you that an intervention was made, but not the value of the intervention. If that is sufficient, then keep it. I am just trying to avoid a future scenario where this field will become two fields: has_value: bool and value: T.

@alexpiet

alexpiet commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Oh sorry, I misunderstood your question. Yes, we will want access to the value of the manipulation for the moving the stage (direction, distance). There isn't an associated value with the water delivery.

I dont know any details of how the trial generator versus how those bias intervention values are being saved, so I can't comment on how to structure these classes. I just will want access to the values and know which trial they occurred on in the trials table

@micahwoodard

micahwoodard commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator Author

@alexpiet You'll have access to how much the stage moved from the trial.lickspout_offset_delta. If we anticipate other interventions that will move the stage beside bias interventions, it could be worth it to expose distance moved in metadata. Seems a little superfluous to me though. The main goal of these adds was to differentiate autowater vs bias interventions rewards

Trial(
         p_reward_left=1 if (self.is_left_baited or is_auto_reward_right is False) else self.block.p_left_reward,
         p_reward_right=1 if (self.is_right_baited or is_auto_reward_right) else self.block.p_right_reward,
         reward_consumption_duration=self.spec.reward_consumption_duration,
         response_deadline_duration=self.spec.response_duration,
         quiescence_period_duration=quiescent,
         inter_trial_interval_duration=iti,
         lickspout_offset_delta=lickspout_offset_delta,
         is_auto_reward_right=is_auto_reward_right,
         metadata=Metadata(
             p_reward_left=self.block.p_left_reward,
             p_reward_right=self.block.p_right_reward,
              extra=BlockBasedTrialMetadata(
                    is_autowater=is_autowater and not is_bias_intervention,
                    is_bias_water_intervention=is_bias_intervention and is_auto_reward_right is not None,
                    is_bias_stage_intervention=is_bias_intervention and lickspout_offset_delta != 0,)

@alexpiet

alexpiet commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

That works for me

@micahwoodard micahwoodard merged commit a5d32bf into main Jul 8, 2026
4 checks passed
@micahwoodard micahwoodard deleted the feat-add-bias-intervention-metadata branch July 8, 2026 21:35
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