Open conochur opened 5 months ago
Yes, in theory! In practice it depends a bit on what exactly it is you are after.
The obj
format is (to my knowledge) most commonly used for meshes, i.e. an object with faces and vertices. It's pretty straight forward to convert a skeleton into a tubular mesh. OBJ
appears to also support curve/line objects though. Not sure which of the two option CATMAID is exporting?
Thanks for the response! I'm looking for a mesh file that I can pop into other rendering software. But would like to do it programmatically. Do you have any recommendations for accomplishing that from python using the coordinate and radius data?
That functionality fortunately already exists. Here's a minimal example:
>>> import pymaid
>>> import navis
>>> # Grab your CATMAID skeleton
>>> s = pymaid.get_neuron()
>>> type(s)
pymaid.core.CatmaidNeuron
>>> # Turn the skeleton into a tubular mesh
>>> # You can tune the resolution using `tube_points` parameter
>>> m = navis.conversion.tree2meshneuron(s)
>>> type(m)
navis.core.mesh.MeshNeuron
>>> # Save as OBJ
>>> _ = m.trimesh.export('skeleton_mesh.obj')
Original skeleton in yellow; mesh generated from skeleton in blue.
A couple notes:
>>> s.nodes.loc[s.nodes.radius.fillna(0) <= 0), 'radius'] = 100
I know that there's a feature in the GUI to export skeleton selections as .obj files, but can one do the same using PyMaid?