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

[BUG] allen_cord_20um meshes are not centered #330

Closed
adamltyson opened this issue Jul 24, 2024 · 4 comments
Closed

[BUG] allen_cord_20um meshes are not centered #330

adamltyson opened this issue Jul 24, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@adamltyson
Copy link
Member

This image.sc issue led me to do some digging, and it looks like:

  • The allen cord atlas is (nearly) symmetrical
  • The annotations and reference image (nearly) align properly with the generated hemispheres image

However, the meshes don't seem be centered. I'm not 100% sure what that means TBH, as I don't know exactly what the coordinate system is that they're in. However, when the meshes are cut down the midline by vedo (via brainrender), you don't get exactly half. To reproduce:

from brainrender import Scene
from brainrender import settings
settings.SHADER_STYLE = "plastic"
scene = Scene(atlas_name="allen_cord_20um")
scene.add_brain_region("WM", hemisphere="left")
scene.render()

Gives:
Screenshot 2024-07-24 at 10 21 04

This then seems to cause the downstream issues in brainrender-heatmap. Not sure if other atlas have this issue.

@adamltyson adamltyson added the bug Something isn't working label Jul 24, 2024
@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/allen-spinal-cord-atlas-is-off-axis/99539/2

@IgorTatarnikov IgorTatarnikov self-assigned this Aug 8, 2024
@IgorTatarnikov
Copy link
Member

Currently, the left/right split is done by calculating the center_of_mass in for the root mesh in brainrender and taking that as the midpoint. Not sure why that's the case for this specific atlas. As far as I can tell it's symmetric.

See:
https://github.com/brainglobe/brainrender/blob/9cd07c8ad33fcbed0c8a5e396f9b330a5634603e/brainrender/scene.py#L287-L312

For some reason the center_of_mass doesn't align with the geometric? center. I can correct this by just taking the centre of the mesh bounds for the root mesh. That fixes this issue for the spinal cord atlas, and doesn't change the functionality for most of the other atlases.

image

However, this breaks this functionality for the mpin_zfish_1um atlas.

Left hemisphere:
image

Right hemisphere:
image

I noticed that the mpin-zfish_1um atlas is one of the only one that has a hemispheres.tiff. Is that because the hemispheres aren't symmetrical?

Not sure how to proceed, one idea I had was to take the geometric center for atlases that are marked as symmetric and rely on the hemispheres property for the asymmetric atlases.

@adamltyson
Copy link
Member Author

I noticed that the mpin-zfish_1um atlas is one of the only one that has a hemispheres.tiff. Is that because the hemispheres aren't symmetrical?

Yep, if they're symmetrical we programmatically generate the hemisphere image, otherwise it's packaged along with the atlas. TBH I don't know if that's correct for this atlas though.

@adamltyson
Copy link
Member Author

This specific issue has been closed by brainglobe/brainrender#375, and these issues have been raised to fix specific atlases:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants