brainglobe / brainrender

a python based software for visualization of neuroanatomical and morphological data.
https://brainglobe.info/documentation/brainrender/index.html
BSD 3-Clause "New" or "Revised" License
538 stars 75 forks source link

Update hemisphere slicing #375

Closed IgorTatarnikov closed 3 weeks ago

IgorTatarnikov commented 3 weeks ago

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 the discussion in https://github.com/brainglobe/brainglobe-atlasapi/issues/330

What does this PR do? If the atlas is marked as symmetrical in the metadata the midpoint is now calculated by taking the mean of the root mesh bounds for each axis. If the atlas isn't marked as symmetrical the previous behaviour is maintained.

References

https://github.com/brainglobe/brainglobe-atlasapi/issues/330

How has this PR been tested?

Tested locally by visual inspection. For an asymmetric atlas:

scene = Scene(atlas_name="mpin_zfish_1um")
scene.add_brain_region("hindbrain", hemisphere="right")
scene.add_brain_region("forebrain", hemisphere="left")
scene.render()

For symmetric atlases:

scene = Scene(atlas_name="allen_cord_20um")
scene.add_brain_region("WM", hemisphere="left")
scene.render()
scene = Scene(atlas_name="allen_mouse_25um")
scene.add_brain_region("CTX", hemisphere="left")
scene.render()

Is this a breaking change?

No

Checklist:

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.06%. Comparing base (9cd07c8) to head (89ffcaf). Report is 1 commits behind head on main.

Files Patch % Lines
brainrender/scene.py 80.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #375 +/- ## ========================================== - Coverage 88.13% 88.06% -0.08% ========================================== Files 27 27 Lines 1214 1215 +1 ========================================== Hits 1070 1070 - Misses 144 145 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

adamltyson commented 3 weeks ago

Thanks @IgorTatarnikov! This looks good to me, but I won't review until it's marked as "ready for review".

I checked, and it also fixes this image.sc issue.

IgorTatarnikov commented 3 weeks ago

I unmarked it because this approach fails with the new axolotl atlas, so I was going to do some more investigating!

IgorTatarnikov commented 3 weeks ago

This fix works appropriately if the axolotl and other asymmetric atlases have the correct metadata tag. I've opened https://github.com/brainglobe/brainglobe-atlasapi/issues/359 to track this issue. However, I believe this PR is ready to go in.

adamltyson commented 3 weeks ago

Great, thanks @IgorTatarnikov. I'll merge this then release.