-
Notifications
You must be signed in to change notification settings - Fork 0
Task/normalize behavior name resolution #56
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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 normalizes behavior name handling to bridge differences between annotation labels (e.g., "rearing (unsupported)") and prediction keys (e.g., "Rearing_unsupported").
Changes:
- Added
normalize_behavior_name()andresolve_behavior_key()helper functions to standardize behavior name matching - Updated
BoutTable.from_jabs_annotation_file()andPrediction.generate_bout_table()to use normalized behavior matching - Added comprehensive unit tests for normalization, resolution, and integration with existing methods
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/utils/test_behavior_normalization.py | Adds unit tests covering normalization rules, resolution logic, and integration with annotation/prediction parsing |
| src/jabs_postprocess/utils/project_utils.py | Implements normalization helpers and updates behavior matching logic in existing methods |
| pyproject.toml | Bumps version from 0.5.3 to 0.5.4 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return normalized.lower() | ||
|
|
||
|
|
||
| def resolve_behavior_key(behavior: str, available_behaviors: List[str]) -> str | None: |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function returns None when multiple matches are found (ambiguous case), but this is indistinguishable from the case where no matches are found. Consider returning a more informative result (e.g., raising an exception for ambiguous matches or returning a tuple indicating the error type) to help callers differentiate between these scenarios.
| behavior_key = resolve_behavior_key(settings.behavior, available_keys) | ||
| if behavior_key is None: |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When behavior_key is None, the error message doesn't indicate whether the issue was ambiguous matching or no match found. Consider updating the error handling to provide a more specific message based on the resolution failure reason.
|
jabs-behavior-classifier has a function that normalizes behavior names before using them as filenames. I think it's called to_safe_name or something like that. I don't remember exactly what it does, but we should probably do the same thing here and there (and eventually when we merge the repos use the same code) |
Normalized behavior names to bridge differences between annotation labels and prediction keys (e.g., rearing (unsupported) vs Rearing_unsupported).
Added helper functions to resolve behavior keys consistently and applied them when parsing JABS annotation JSON and prediction HDF5 files. Added unit tests covering normalization, resolution, annotation matching, and prediction lookup.