Replies: 2 comments 1 reply
-
Hi! The For the brain meshes it's easiest to demonstrate with a couple code examples: >>> import navis
>>> import flybrains
>>> # Inspect a template brain
>>> flybrains.FCWB
Template brain
--------------
Name: FlyCircuit Whole Brain
Short Name: FCWB
Type: Average
Sex: Intersex
Dimensions: 1769 x 1026 x 108 voxels
Voxel size:
x = 0.3189673076923077 microns
y = 0.3184270243902439 microns
z = 1.0 microns
Bounding box (microns):
x = 0.0, y = 0.0, z = 0.0,
x = 563.9342, y = 326.3877, z = 107.0,
Description: An intersex averaged brain formed from 17 female and 9 male brains from the FlyCircuit dataset.
DOI: 10.5281/zenodo.10568
>>> # Access the mesh
>>> mesh = flybrains.FCWB.mesh
>>> mesh
<trimesh.Trimesh(vertices.shape=(8859, 3), faces.shape=(17886, 3))>
>>> # The mesh is a simple trimesh.Trimesh object
>>> # If you want to convert this to navis Volume
>>> # (the object can be anything that has .vertices and .faces, like our trimesh)
>>> vol = navis.Volume.from_object(mesh, name='FCWB')
<navis.Volume(name=FCWB, color=(0.85, 0.85, 0.85, 0.2), vertices.shape=(8859, 3), faces.shape=(17886, 3))>
>>> # Note though that navis.Volume is just a trimesh.Trimesh with a couple extras (like a "name")
>>> # navis functions that accept a Volume should also accept a Trimesh and vice versa (let me know if it doesn't)
>>> # In fact, some navis functions know how to deal with the template brain itself (i.e. no need to reference the mesh):
>>> navis.plot3d(flybrains.FCWB) On a more general note: if you have any sort of mesh file such the >>> import trimesh as tm
>>> mesh = tm.load('JFRCtemplate2010_complex_smoothed.obj')
>>> mesh
<trimesh.Trimesh(vertices.shape=(8859, 3), faces.shape=(17886, 3))>
>>> # Alternatively, load directly from Github
>>> import requests
>>> import io
>>> r = requests.get('https://github.com/VirtualFlyBrain/DrosAdultBRAINdomains/raw/master/template/JFRCtemplate2010_complex_smoothed.obj')
>>> mesh = tm.load(r.content.decode(), file_type='obj')
>>> mesh
<trimesh.Trimesh(vertices.shape=(8859, 3), faces.shape=(17886, 3))> From NRRD (i.e. image files) things are a bit more tricky but it eventually comes down to using some marching cubes implementation to generate a surface mesh. Hope that the above is helpful. Feel free to follow up! Best, |
Beta Was this translation helpful? Give feedback.
-
PS: the brain surface meshes for |
Beta Was this translation helpful? Give feedback.
-
The nat.flybrains R package ships with surface models (in the JFRC2, IS2, and FCWB coordinate spaces) for the Ito et al. neuropil segmentation. However, it seems (?) that these surface models are not included with navis-flybrains. Is there a simple way to import the label fields as navis.Volume objects from the original Amira mesh file (or the nrrd raster version)?
Beta Was this translation helpful? Give feedback.
All reactions