-
Notifications
You must be signed in to change notification settings - Fork 25
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
Skeleton to a networkx graph conversion #19
Comments
Yeah. Each skeleton has a >>> n = navis.example_neurons()
>>> n.graph
<networkx.classes.digraph.DiGraph at 0x162849f10> It is automatically regenerated when the neuron is changed. The distance between nodes is used as weights: >>> n.graph.edges[(2, 1)]
{'weight': 34.64101615137755} There are also explicit methods to (re-)generate the graph: >>> n.get_graph_nx()
<networkx.classes.digraph.DiGraph at 0x1474c4050>
>>> navis.neuron2nx(n)
<networkx.classes.digraph.DiGraph at 0x162a5bf50> For the record: the same exists for igraph as |
omg, this is a lifesaver! Thank you very much for the quick response! |
@schlegelp Sorry I closed this issue prematurely! I am able to see the graph in |
Can you give a minimal code example? I have no clue what |
Sure, so sorry for the ambiguity!
The STL file can be downloaded from: https://drive.google.com/file/d/1YzNwCBoZ4l0L7E_ht0NOMVXqsSiG7PgR/view?usp=sharing Thank you! |
Bottom line: you have to convert your n = navis.TreeNeuron(skeleton.swc)
G = n.graph
|
Apologies: I just realised that I misread your earlier question/thought I was in a different repo 🤦 (in my defence: it was fairly late in the evening). To clarify: I'm talking about navis which I typically use to further process skeletons. So what I am recommending is install navis and then do this: import navis
n = navis.TreeNeuron(skeleton.swc)
G = n.graph |
Thank you for the clarification.
No problem, thank you for the help! I will be sure to check out |
Hi @schlegelp !
I am trying to convert a skeleton to a
networkx
graph upon which I can then use many graph-based algorithms such as shortest path (by assigning the distance between nodes as edge-weights), etc.Before, I dig deep into this, I wanted to know if this is already done or is there a straightforward way within
skeletor
to convert a skeleton to anetworkx
graph? Any input will be very helpful.I am really enjoying this library by the way!
Thanks!
The text was updated successfully, but these errors were encountered: