Ensure volume is calculated for right hemisphere#266
Merged
IgorTatarnikov merged 5 commits intomainfrom Jan 8, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where volume calculation failed when registering only the right hemisphere, resulting in an empty volumes.csv file. The issue occurred because the code only iterated over structures present in the left hemisphere.
Key Changes:
- Fixed volume calculation to include structures from both hemispheres by using a union of unique values from left and right hemispheres
- Corrected default hemisphere value parameters to match BrainGlobe atlas standards (left=1, right=2)
- Added
brain_geometryparameter passing from napari widget to properly filter warning messages
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
brainreg/napari/register.py |
Added brain_geometry parameter when calling calculate_volumes from the napari widget |
brainreg/core/utils/volume.py |
Fixed hemisphere value defaults, created union of unique values from both hemispheres for iteration, improved warning logic for hemisphere-specific registrations, and corrected a spelling error |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/allen-atlas-not-matching-structures-file/118265/4 |
adamltyson
previously approved these changes
Jan 8, 2026
Member
adamltyson
left a comment
There was a problem hiding this comment.
LGTM. Thanks @IgorTatarnikov!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Before submitting a pull request (PR), please read the contributing guide.
Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)
Description
What is this PR
Why is this PR needed?
See #265
What does this PR do?
Creates a union from the unique right and left values to loop over when calculating volumes.
Correct default parameters such that
left_hemisphere_value=1andright_hemisphere_value=2.Ensure the brain geometry value is passed back from the
napariwidget when calculating region volumes.References
Closes #265
Please reference any existing issues/PRs that relate to this PR.
How has this PR been tested?
Tested:
Registering left hemisphere ->
right_volume_mm3is always 0 andtotal_volume_mm3==left_volume_mm3Registering right hemisphere ->
left_volume_mm3is always 0 andtotal_volume_mm3==right_volume_mm3Registering full brain ->
left_volume_mm3!= 0,right_volume_mm3!= 0,total_volume_mm3== (right_volume_mm3+left_volume_mm3)Is this a breaking change?
No
Does this PR require an update to the documentation?
No
Checklist: