brainglobe-atlasapi
brainglobe-atlasapi copied to clipboard
[BUG] Spinal cord mesh rotated at 90 degrees in meshio/napari
Describe the bug
The allen_cord_20um
mesh behaves differently to the other meshes. I don't think it's because it's anisotropic. Could also be a meshio
(or a napari
) bug (but it doesn't happen with other atlases AFAIT)?
To Reproduce
- make a copy of
250.obj
andannotations.tiff
in a local folder - rename the copies to
mesh_0.obj
andimage_0.tiff
- copy the python script below to the same local folder.
from pathlib import Path
import napari
import meshio
from tifffile import imread
viewer = napari.Viewer()
scales = [
[10,10,20], # image 0 has anisotropic scale
]
for i in range(1):
image_path = Path(__file__).parent / f"image_{i}.tiff"
image = imread(image_path)
image = viewer.add_image(image, scale=scales[i], colormap='hsv')
mesh_path = Path(__file__).parent / f"mesh_{i}.obj"
mesh = meshio.read(mesh_path)
points = mesh.points
cells = mesh.cells[0].data
surface = viewer.add_surface((points, cells), opacity=0.4)
print(f"image {i}:")
print(image.extent.world)
print(surface.extent.world)
if __name__ == "__main__":
napari.run()
- run the python script in a conda env with napari installed
- switch napari to 3d view
- the mesh and the image are at 90 degrees to each other
Expected behaviour The mesh and the image should align with each other.
Log file
Screenshots If applicable, add screenshots to help explain your problem.
But in paraview it looks reasonable (note the transform in the screenshot is the same as the scale in the example script here) Computer used (please complete the following information):
- OS: macOS Ventura 13.4.1 (22F82) (Apple M2 chip), 16GB RAM
Additional context
I expect running the script above on any other annotation+root mesh combo works fine (I've tested only on allen_mouse_100um
though), because the script is a simplification of what I added in https://github.com/brainglobe/brainglobe-napari/pull/31
and that is extensively tested on various (but not all) atlases. Maybe the .obj
has some metadata that meshio
ignores that the other obj
s don't, and paraview knows how to deal with that?
Maybe the spinal cord's obj is somehow special