- navis.rewire_skeleton(x, g, root=None, inplace=False)¶
Rewire neuron from graph.
This function takes a graph representation of a neuron and rewires its node table accordingly. This is useful if we made changes to the graph (i.e. adding or removing edges) and want those to propagate to the node table.
x (TreeNeuron) – Neuron to be rewired.
g (networkx.Graph) – Graph to use for rewiring. Please note that directionality (if present) is not taken into account. Nodes not included in the graph will be disconnected (i.e. won’t have a parent). Nodes in the graph but not in the table are ignored!
root (int) – Node ID for the new root. If not given, will try to use the current root.
inplace (bool) – If True, will rewire the neuron inplace. If False, will return a rewired copy of the neuron.
- Return type:
>>> import navis >>> n = navis.example_neurons(1) >>> n.n_trees 1 >>> # Drop one edge from graph >>> g = n.graph.copy() >>> g.remove_edge(310, 309) >>> # Rewire neuron >>> n2 = navis.rewire_skeleton(n, g, inplace=False) >>> n2.n_trees 2