navis-fastcore (Python)¶
Python bindings for the fastcore Rust core, built with
PyO3. Functions here are generalized and do not depend on
navis itself, so third-party libraries can
use them without that rather heavy dependency — navis-fastcore's only runtime
requirement is numpy.
Install¶
Pre-compiled wheels are on PyPI:
See the GitHub repo if you want to build from source.
Usage¶
navis will use fastcore automatically where appropriate — you only need this
section if you want to call it directly.
Tree functions take node_ids and parent_ids arrays; the mapping from arbitrary
IDs onto the core's internal indices happens for you.
import navis_fastcore as fastcore
import numpy as np
node_ids = np.array([1, 2, 3, 4, 5])
parent_ids = np.array([-1, 1, 2, 3, 1]) # -1 marks the root
# All-by-all geodesic distances
dists = fastcore.geodesic_matrix(node_ids, parent_ids)
Available functions¶
Operations on rooted trees:
geodesic_matrix: geodesic ("along-the-arbor") distances, either all-by-all or between specific sources and targetsgeodesic_pairs: geodesic distances between given pairs of nodesgeodesic_nearest: distance to the nearest target for each source, without building the full matrixgeodesic_farthest: distance to the farthest target for each source, without building the full matrixdist_to_root: distance from each node to its rootconnected_components: generate the connected componentsclassify_nodes: classify nodes into roots, leaves, branch points and slabssynapse_flow_centrality: synapse flow centrality (Schneider-Mizell, eLife, 2016)strahler_index: calculate Strahler indexsubtree_height: distance from each node down to the farthest leaf below itprune_twigs: remove terminal twigs below a certain sizebreak_segments: break the neuron into the linear segments connecting leafs, branches and rootsgenerate_segments: same asbreak_segmentsbut maximizing segment lengths, i.e. the longest segment goes from the most distal leaf to the root and so onsegment_coords: coordinates per linear segment (useful for plotting)
Repairing fragmented skeletons:
heal_skeleton: reconnect the fragments of a broken skeletonstitch_fragments: find the minimal-length edges that reconnect fragments
Meshes:
mesh_connected_components: connected components of a triangle mesh
nblast/nblast_allbyall: NBLAST (query-vs-target / all-by-all)nblast_smart: two-pass approximate NBLAST for large comparisonssynblast: synapse-based NBLAST
Interop:
wrappers.csgraph: drop-in replacements for somescipy.sparse.csgraphroutines