Skip to content
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

Fix hemisphere bug in check_orientation #207

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions brainreg/napari/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,11 @@ def check_orientation(event=None):
atlas = BrainGlobeAtlas(widget.atlas_key.value.name)
if brain_geometry.value == "hemisphere_l":
atlas.reference[
atlas.hemispheres == atlas.left_hemisphere_value
atlas.hemispheres == atlas.right_hemisphere_value
] = 0
elif brain_geometry.value == "hemisphere_r":
atlas.reference[
atlas.hemispheres == atlas.right_hemisphere_value
atlas.hemispheres == atlas.left_hemisphere_value
] = 0
input_orientation = getattr(widget, "data_orientation").value
data = getattr(widget, "img_layer").value.data
Expand Down
16 changes: 16 additions & 0 deletions tests/test_brainreg_napari.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@ def test_orientation_check(
# run again and check previous output was deleted properly
run_and_check_orientation_check(widget, viewer, brain_layer, atlas)

# "allen_mouse_50um" orientation is ASR
# so S-I projection will have origin AR
# so the columns 0 to half should be filled with zeros
# if we only want to register to the left hemisphere
# LR axis is 228
widget.brain_geometry.value = widget.brain_geometry.annotation[
"Left hemisphere"
]
run_and_check_orientation_check(widget, viewer, brain_layer, atlas)
ar_projection = viewer.layers["Ref. proj. 1"].data
import numpy as np

assert ar_projection.shape[1] // 2 == 114
assert np.all(ar_projection[:, 114] == 0)
assert not np.all(ar_projection[:, 115] == 0)


def run_and_check_orientation_check(widget, viewer, brain_layer, atlas):
widget.check_orientation_button.clicked()
Expand Down
Loading