Skip to content

Adds uncoupled trial generator#71

Open
micahwoodard wants to merge 19 commits intomainfrom
feat-uncoupled-trial-generator
Open

Adds uncoupled trial generator#71
micahwoodard wants to merge 19 commits intomainfrom
feat-uncoupled-trial-generator

Conversation

@micahwoodard
Copy link
Copy Markdown
Collaborator

Adds uncoupled trial generator based on https://github.com/AllenNeuralDynamics/dynamic-foraging-task/blob/develop/src/foraging_gui/reward_schedules/uncoupled_block.py. Updated base class to be used by both coupled and uncoupled and added coupled base class to be used by both warmup and coupled class.

@micahwoodard
Copy link
Copy Markdown
Collaborator Author

resolves #53

Comment thread examples/uncoupled_trial_generator.py Outdated
self.reward_history.append(outcome.is_rewarded)

if self.spec.is_baiting:
if outcome.is_right_choice:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Consider adding the "else" to have the complete pattern matching just in case. Even a else: pass with a comment describing why we are handling it that way would be great.

self.is_right_baited = self.block.p_right_reward > random_numbers[1] or self.is_right_baited
logger.debug(f"Right baited: {self.is_right_baited}")
logger.debug("Right baited: %s" % self.is_right_baited)
else:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you ended up adding this clause in the wrong place. See https://github.com/AllenNeuralDynamics/Aind.Behavior.DynamicForaging/pull/71/changes#r3134922037 as the comment I made was not address.

block_length: Distribution = Field(
default=UniformDistribution(
distribution_parameters=UniformDistributionParameters(min=20, max=60),
truncation_parameters=TruncationParameters(min=20, max=60),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need for truncation here since the Uniform is already guaranteed to draw between min a max

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I defined them so I can calculate the block stagger with the truncation parameters and use with other distributions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

uhmm this feels like a super leaky abstraction. Because users may pass a non-truncated distribution and your logic will crash during runtime. If the min and the max are really necessary for you inner logic, then sure go ahead and move them again to the top level. I thought the logic was decoupled enough that you would not need access to these parameters only the drawn number.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah that block stagger calculation relies on the min and max which is why I originally constrained it to uniform. I'll revert back to that unless that's not what you're suggesting here?

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.

2 participants