-
Notifications
You must be signed in to change notification settings - Fork 26
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
How to save the skeleton without the mesh? #36
Comments
Hi. Looks like you asked almost the same question in #4. You seem to have already found the They way to use it would be to run this: skel.save_swc('skeleton.swc') This will create a Whether the SWC format is helpful in your case really depends on what you want to do with the file. I might have other/better suggestions if you tell me a bit more e.g. about what other software you want to load it into. |
Hi, thank you very much for your help, and I'm really sorry for taking so long to reply to your message. My goal is to save the calculated skeleton lines. As you can see the green point (skeleton) in the middle of the figure. And I wonder if there is a solution. |
No problem. The question is not whether there is a way to save the skeleton - there are plenty. The question is rather what you want to do with them downstream because that will determine the format. |
I would like to optimize the skeleton line and calculate the length of the extracted skeleton line. |
Attached is the code.
|
That's fair enough. I might have recommended you use navis for this. It's principally made for analysing neurons but since neurons are also just directed acyclic graphs it works just as well. Importantly, it plays nicely with >>> import skeletor as sk
>>> mesh = sk.example_mesh()
>>> fixed = sk.pre.fix_mesh(mesh, remove_disconnected=5, inplace=False)
>>> skel = sk.skeletonize.by_wavefront(fixed, waves=1, step_size=1)
# Turn skeleton into a navis Neuron
>>> import navis
>>> n = navis.TreeNeuron(skel)
# Some examples of what you can do with it now:
>>> n.cable_length
193260.085048636
>>> s = navis.smooth_skeleton(n, window=5) # Smooth
>>> s.cable_length
209428.27956084194
>>> pr = navis.prune_twigs(n, size=1000) # prune small twigs
>>> pr.cable_length
120032.67049704675
>>> ln = navis.longest_neurite(n, from_root=False) # Extract the longest continuous segment
>>> ln.cable_length
55611.49568331024
I'm not sure what I'm seeing in the plot you've attached but it doesn't seem to match the green points in the earlier rendering. The bottom line is this: If you want to get your skeleton into open3d you could do this: >>> import open3d as o3d
>>> ls = o3d.geometry.LineSet(o3d.utility.Vector3dVector(skel.vertices),
... o3d.utility.Vector2iVector(skel.edges))
>>> open3d.visualization.draw_geometries([ls]) |
Thank you for your help. ❤ |
Hi~ I would like to save the skeleton without the mesh, however I don't know how to do it. Would you please give me some advice? Following are the code I use. Thank you for your kind help.
The text was updated successfully, but these errors were encountered: