-
Notifications
You must be signed in to change notification settings - Fork 0
Feat metadata mapping #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
micahwoodard
wants to merge
37
commits into
main
Choose a base branch
from
feat-metadata-mapping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
eba6406
adds acquisition mapping
micahwoodard 441ad11
adds rig schema
micahwoodard a32a842
adds data description
micahwoodard 3fef59b
updates __init__
micahwoodard 062b917
fixes init
micahwoodard 6d0f998
Merge branch 'feat-adding-curriculum' into feat-metadata-mapping
micahwoodard 6dbe0f0
adds cli for mapping
micahwoodard 91febd4
Merge branch 'feat-adding-curriculum' into feat-metadata-mapping
micahwoodard 79dc6f9
refrences current metrics in mapping
micahwoodard 9e03163
dumps metrics
micahwoodard 963292f
prints json
micahwoodard 062aa2f
removes return
micahwoodard 1f5a2fc
lints
micahwoodard ba96b5f
adds logging
micahwoodard 2f0a446
converts end condition time to seconds
micahwoodard 382ae85
streams logs to stdout
micahwoodard f160fbd
moves logging before import
micahwoodard f1fff6d
log fixes
micahwoodard f7502b1
push fixes for baiting
micahwoodard 37f9c84
add cli
micahwoodard 690982d
adds project script
micahwoodard c9ee84a
updates args
micahwoodard e68fe44
removes suffix
micahwoodard a107aa8
lints
micahwoodard 6ef9ed3
removes data description
micahwoodard 0a7e2f4
configures logger to json and removes cluttered log mesages
micahwoodard 2c411f9
lints
micahwoodard 96ea485
adds name to log schema
micahwoodard 4a305d1
cleans up baiting logic
micahwoodard 80080af
removes test
micahwoodard 0e982ac
merges with main
micahwoodard 7632a11
bumps version
micahwoodard 588e98e
merges with main
micahwoodard f402215
lints
micahwoodard 2509705
lints
micahwoodard 3637f52
Merge branch 'main' into feat-metadata-mapping
micahwoodard 442104a
Merge branch 'main' into feat-metadata-mapping
micahwoodard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import os | ||
| from typing import Optional | ||
|
|
||
| from aind_behavior_dynamic_foraging.data_contract import dataset | ||
| from aind_behavior_dynamic_foraging.task_logic import AindDynamicForagingTaskLogic | ||
|
|
||
|
|
||
| def calculate_consumed_water(session_path: os.PathLike) -> Optional[float]: | ||
| """Calculate the total volume of water consumed during a session. | ||
|
|
||
| Args: | ||
| session_path (os.PathLike): Path to the session directory. | ||
|
|
||
| Returns: | ||
| Optional[float]: Total volume of water consumed in milliliters, or None if unavailable. | ||
| """ | ||
|
|
||
| trial_outcomes = dataset(session_path)["Behavior"]["SoftwareEvents"]["TrialOutcome"].load().data["data"] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can validate this with the TrialOutcome pydantic class to make your life easier |
||
| is_right_choice = [to["is_right_choice"] for to in trial_outcomes] | ||
| is_rewarded = [to["is_rewarded"] for to in trial_outcomes] | ||
|
|
||
| task_logic_data = dataset(session_path)["Behavior"]["InputSchemas"]["TaskLogic"].load().data | ||
| task_logic = AindDynamicForagingTaskLogic.model_validate(task_logic_data) | ||
| right_reward_size = task_logic.task_parameters.reward_size.right_value_volume | ||
| left_reward_size = task_logic.task_parameters.reward_size.left_value_volume | ||
|
|
||
| total = 0 | ||
| for choice, rewarded in zip(is_right_choice, is_rewarded): | ||
| if rewarded: | ||
| if choice is True: | ||
| total += right_reward_size * 1e-3 | ||
| if choice is False: | ||
| total += left_reward_size * 1e-3 | ||
| return total | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
78 changes: 78 additions & 0 deletions
78
workspace/aind_behavior_dynamic_foraging_metadata_mapper/pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| [build-system] | ||
| requires = ["uv_build>=0.8.22"] | ||
| build-backend = "uv_build" | ||
|
|
||
| [project] | ||
| name = "aind-behavior-dynamic-foraging-metadata-mapper" | ||
| description = "A library of mapping for the Dynamic Foraging task." | ||
| authors = [ | ||
| {name = "Bruno Cruz", email = "bruno.cruz@alleninstitute.org"}, | ||
| {name = "Micah Woodard", email = "micah.woodard@alleninstitute.org"} | ||
| ] | ||
| license = "MIT" | ||
| version = "0.0.1" | ||
| requires-python = ">=3.11" | ||
| classifiers = [ | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| "Operating System :: Microsoft :: Windows", | ||
| ] | ||
| readme = {file = "README.md", content-type = "text/markdown"} | ||
|
|
||
| dependencies = [ | ||
| "numpy>=2.4.2", | ||
| "pydantic-settings", | ||
| "aind-behavior-dynamic-foraging==0.0.2rc30", | ||
| "aind-data-schema>=2.6.0", | ||
| "cyclopts>=4.10.0" | ||
| ] | ||
|
|
||
| [tool.uv.sources] | ||
| aind-behavior-dynamic-foraging = { workspace = true } | ||
|
|
||
| [dependency-groups] | ||
|
|
||
| dev = [ | ||
| 'ruff', | ||
| 'pytest', | ||
| 'pytest-cov', | ||
| 'codespell', | ||
| ] | ||
|
|
||
| docs = [ | ||
| 'mkdocs', | ||
| 'mkdocs-material', | ||
| 'mkdocstrings[python]', | ||
| 'pymdown-extensions', | ||
| 'ruff', | ||
| ] | ||
|
|
||
| [tool.uv] | ||
| default-groups = ['dev'] | ||
|
|
||
| [tool.ruff] | ||
| line-length = 120 | ||
| target-version = 'py311' | ||
|
|
||
| [tool.ruff.lint] | ||
| extend-select = ['Q', 'RUF100', 'C90', 'I'] | ||
| extend-ignore = [] | ||
| mccabe = { max-complexity = 14 } | ||
| pydocstyle = { convention = 'google' } | ||
|
|
||
| [tool.codespell] | ||
| skip = '.git,*.pdf,*.svg,uv.lock' | ||
| ignore-words-list = 'nd' | ||
|
|
||
| [tool.pytest.ini_options] | ||
| addopts = "--strict-markers --tb=short --cov=src --cov-report=term-missing --cov-fail-under=70" | ||
| testpaths = ["tests"] | ||
| python_files = ["test_*.py"] | ||
| python_classes = ["Test*"] | ||
| python_functions = ["test_*"] | ||
|
|
||
| [project.scripts] | ||
| acquisition = "aind_behavior_dynamic_foraging_metadata_mapper.acquisition:app" | ||
| instrument = "aind_behavior_dynamic_foraging_metadata_mapper.instrument:app" | ||
| mapper = "aind_behavior_dynamic_foraging_metadata_mapper.cli:main" |
7 changes: 7 additions & 0 deletions
7
...c_foraging_metadata_mapper/src/aind_behavior_dynamic_foraging_metadata_mapper/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from .acquisition import acqusition_from_dataset | ||
| from .instrument import instrument_from_dataset | ||
|
|
||
| __all__ = [ | ||
| "acqusition_from_dataset", | ||
| "instrument_from_dataset", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.