API Overview#
NAVis has grown a lot! Last I looked, there were over 120 functions and classes exposed at top level (e.g. navis.plot3d
) and easily another 100 available via submodules (e.g. navis.transforms.AffineTransform
). This can be a bit daunting at first - especially if you don't exactly know what you are looking for!
This document provides a curated, high-level summary. I recommend you either just have a browse, use the search field (upper right) or simply search in page (CONTROL/CMD-F). Failing that, please feel free to open a thread on Github Discussions with your question.
This API reference is a more or less complete account of the primary functions:
- Neuron- and NeuronList functions and methods
- Functions for visualization
- Manipulate or analyze neuron morphology
- Transforming and mirroring data
- Analyze connectivity
- Import/Export
- Utility functions
- Which functions work with which neuron types?
In addition NAVis has interfaces to various external datasets and tools:
- NEURON simulator
- Neuromorpho
- neuPrint
- InsectBrain DB
- Blender 3D
- Cytoscape
- Allen MICrONS datasets
- R and the natverse libraries
Most of these functions include examples of how to use them. Click on them to learn more!
Neurons & NeuronLists#
TreeNeurons
, MeshNeurons
, VoxelNeurons
and Dotprops
are neuron classes. NeuronLists
are containers thereof.
Class | Description |
---|---|
navis.TreeNeuron | Skeleton representation of a neuron. |
navis.MeshNeuron | Meshes with vertices and faces. |
navis.VoxelNeuron | 3D images (e.g. from confocal stacks). |
navis.Dotprops | Point cloud + vector representations, used for NBLAST. |
navis.NeuronList | Containers for neurons. |
General Neuron methods#
Despite being fundamentally different data types, all neurons share some common methods (i.e. functions) which they inherit from their abstract parent class BaseNeurons
.
Method | Description |
---|---|
Neuron.copy() | Return a copy of the neuron. |
Neuron.plot3d() | Plot neuron using navis.plot3d . |
Neuron.plot2d() | Plot neuron using navis.plot2d . |
Neuron.summary() | Get a summary of this neuron. |
Neuron.convert_units() | Convert coordinates to different unit. |
Neuron.map_units() | Convert units to match neuron space. |
Neuron.memory_usage() | Return estimated memory usage of this neuron. |
In addition to methods, neurons also have properties. These properties common to all neurons:
General Neuron properties#
Property | Description |
---|---|
Neuron.connectors | Connector table. If none, will return None . |
Neuron.postsynapses | Table with postsynapses (filtered from connectors table). |
Neuron.presynapses | Table with presynapses (filtered from connectors table). |
Neuron.datatables | Names of all DataFrames attached to this neuron. |
Neuron.id | ID of the neuron. |
Neuron.name | Neuron name. |
Neuron.units | Units for coordinate space. |
Neuron.type | Neuron type. |
Neuron.soma | The soma of the neuron (if any). |
Neuron.bbox | Bounding box of neuron. |
Note
Neurons can have the above properties but that is not guaranteed. For example, a neuron might not have any associated synapses in which case Neuron.connectors
will be None
.
Skeletons#
A navis.TreeNeuron
represents a skeleton. These are class methods available specific for this neuron type. Note that most of them are simply short-hands for the other NAVis functions:
Method | Description |
---|---|
TreeNeuron.convert_units() | Convert coordinates to different unit. |
TreeNeuron.cell_body_fiber() | Prune neuron to its cell body fiber. |
TreeNeuron.downsample() | Downsample the neuron by given factor. |
TreeNeuron.get_graph_nx() | Calculate and return networkX representation of neuron. |
TreeNeuron.get_igraph() | Calculate and return iGraph representation of neuron. |
TreeNeuron.prune_by_longest_neurite() | Prune neuron down to the longest neurite. |
TreeNeuron.prune_by_strahler() | Prune neuron based on Strahler order. |
TreeNeuron.prune_by_volume() | Prune neuron by intersection with given volume(s). |
TreeNeuron.prune_distal_to() | Cut off nodes distal to given nodes. |
TreeNeuron.prune_proximal_to() | Remove nodes proximal to given node. Reroots neuron to cut node. |
TreeNeuron.prune_twigs() | Prune terminal twigs under a given size. |
TreeNeuron.reload() | Reload neuron. Must have filepath as .origin as attribute. |
TreeNeuron.reroot() | Reroot neuron to given node ID or node tag. |
TreeNeuron.resample() | Resample neuron to given resolution. |
TreeNeuron.snap() | Snap xyz location(s) to closest node or synapse. |
In addition, a navis.TreeNeuron
has a range of different properties:
Method | Description |
---|---|
TreeNeuron.adjacency_matrix | Adjacency matrix of the skeleton. |
TreeNeuron.cable_length | Cable length. |
TreeNeuron.cycles | Cycles in neuron (if any). |
TreeNeuron.downsample | Downsample the neuron by given factor. |
TreeNeuron.edges | Edges between nodes. |
TreeNeuron.edge_coords | Coordinates of edges between nodes. |
TreeNeuron.igraph | iGraph representation of this neuron. |
TreeNeuron.is_tree | Whether neuron is a tree. |
TreeNeuron.n_branches | Number of branch points. |
TreeNeuron.n_leafs | Number of leaf nodes. |
TreeNeuron.n_skeletons | Number of seperate skeletons in this neuron. |
TreeNeuron.n_trees | Count number of connected trees in this neuron. |
TreeNeuron.nodes | Node table. |
TreeNeuron.root | Root node(s). |
TreeNeuron.sampling_resolution | Average cable length between child -> parent nodes. |
TreeNeuron.segments | Neuron broken down into linear segments (see also .small_segments ). |
TreeNeuron.simple | Simplified representation consisting only of root, branch points and leafs. |
TreeNeuron.soma_pos | Search for soma and return its position. |
TreeNeuron.subtrees | List of subtrees. Sorted by size as sets of node IDs. |
TreeNeuron.vertices | Vertices of the skeleton. |
TreeNeuron.volume | Radius-based volume. |
Skeleton utility functions#
Function | Description |
---|---|
navis.rewire_skeleton() | Rewire neuron from graph. |
navis.insert_nodes() | Insert new nodes between existing nodes. |
navis.remove_nodes() | Drop nodes from neuron without disconnecting it. |
navis.graph.simplify_graph() | Simplify skeleton graph (networkX or igraph). |
navis.graph.skeleton_adjacency_matrix() | Generate adjacency matrix for a skeleton. |
Mesh neurons#
Properties specific to navis.MeshNeuron
:
Property | Description |
---|---|
MeshNeuron.faces | Faces making up the neuron. |
MeshNeuron.vertices | Vertices making up the neuron. |
MeshNeuron.trimesh | Trimesh representation of the neuron. |
MeshNeuron.volume | Volume of the neuron. |
MeshNeuron.sampling_resolution | Average distance between vertices. |
Methods specific to navis.MeshNeuron
:
Method | Description |
---|---|
MeshNeuron.skeletonize() | Skeletonize mesh. |
MeshNeuron.snap() | Snap xyz location(s) to closest vertex or synapse. |
MeshNeuron.validate() | Use trimesh to try and fix some common mesh issues. |
Voxel neurons#
VoxelNeurons (e.g. from confocal image stacks) are a relatively recet addition to NAVis and the interface might still change.
These are methods and properties specific to VoxelNeurons:
Property | Description |
---|---|
VoxelNeuron.density | Fraction of filled voxels. |
VoxelNeuron.grid | Voxel grid representation. |
VoxelNeuron.max | Maximum value (excludes zeros). |
VoxelNeuron.min | Minimum value (excludes zeros). |
VoxelNeuron.nnz | Number of non-zero voxels. |
VoxelNeuron.offset | Offset (in voxels). |
VoxelNeuron.shape | Shape of voxel grid. |
VoxelNeuron.strip() | Strip empty voxels (leading/trailing planes of zeros). |
VoxelNeuron.threshold() | Drop below-threshold voxels. |
VoxelNeuron.voxels | Voxels making up the neuron. |
Dotprops#
navis.Dotprops
are typically indirectly generated from e.g. skeletons or point clouds using navis.make_dotprops()
.
These are methods and properties specific to Dotprops:
Function | Description |
---|---|
Dotprops.points | Center of tangent vectors. |
Dotprops.vect | Tangent vectors. |
Dotprops.alpha | Alpha value for tangent vectors (optional). |
Dotprops.to_skeleton() | Turn Dotprop into a TreeNeuron. |
Dotprops.snap() | Snap xyz location(s) to closest point or synapse. |
Converting between types#
These functions will let you convert between neuron types:
Function | Description |
---|---|
navis.make_dotprops() | Produce dotprops from neurons or point clouds. |
navis.skeletonize() | Turn neuron into skeleton. |
navis.mesh() | Generate mesh from object(s). |
navis.voxelize() | Turn neuron into voxels. |
navis.conversion.voxels2mesh() | Generate mesh from voxels using marching cubes. |
navis.conversion.tree2meshneuron() | Convert TreeNeuron to MeshNeuron. |
See also Utility for functions to convert to/from basic data types.
NeuronList methods#
NeuronLists
let you access all the properties and methods of the neurons they contain. In addition there are a few NeuronList
-specific methods and properties.
Methods:
Method | Description |
---|---|
NeuronList.apply() | Apply function across all neurons in this NeuronList. |
NeuronList.head() | Return summary for top N neurons. |
NeuronList.itertuples() | Helper to mimic pandas.DataFrame.itertuples() . |
NeuronList.mean() | Return mean numeric and boolean values over all neurons. |
NeuronList.remove_duplicates() | Remove duplicate neurons from list. |
NeuronList.sum() | Return sum numeric and boolean values over all neurons. |
NeuronList.summary() | Get summary over all neurons in this NeuronList. |
NeuronList.tail() | Return summary for bottom N neurons. |
NeuronList.unmix() | Split into NeuronLists of the same neuron type. |
Properties:
Property | Description |
---|---|
NeuronList.bbox | Bounding box across all neurons in the list. |
NeuronList.empty | Return True if NeuronList is empty. |
[NeuronList.id ][navis.NeuronList.id] | An array with the IDs of the neurons contained in the list. |
[NeuronList.idx ][navis.NeuronList.idx] | An indexer similar to pandas' iloc that accepts neuron IDs. |
NeuronList.is_degenerated | Return True if contains neurons with non-unique IDs. |
NeuronList.is_mixed | Return True if contains more than one type of neuron. |
NeuronList.shape | Shape of NeuronList (N, ). |
NeuronList.types | Return neuron types present in this list. |
Please see the tutorial on NeuronList
for more information, including how to index them.
Visualization#
Various functions for plotting neurons and volumes.
Function | Description |
---|---|
navis.plot3d() | Generate interactive 3D plot. |
navis.plot2d() | Generate 2D plots of neurons and neuropils. |
navis.plot1d() | Plot neuron topology in 1D according to Cuntz et al. (2010). |
navis.plot_flat() | Plot neuron as flat diagrams. |
navis.clear3d() | Clear viewer 3D canvas. |
navis.close3d() | Close existing 3D viewer (wipes memory). |
navis.pop3d() | Remove the last item added to the 3D canvas. |
navis.get_viewer() | Grab active 3D viewer. |
Plotting Volumes/Meshes#
To plot meshes, you can pass trimesh.Trimesh
objects directly to plot3d()
or plot2d()
. However, NAVis has a custom class to represent meshes that has some useful perks: navis.Volume
.
Class | Description |
---|---|
navis.Volume | Mesh consisting of vertices and faces. |
navis.Volume.combine | Merge multiple volumes into a single object. |
navis.Volume.plot3d | Plot volume using navis.plot3d . |
navis.Volume.validate | Use trimesh to try and fix issues (holes/normals). |
navis.Volume.resize | Resize volume. |
Vispy 3D viewer#
Using navis.plot3d()
with backend="vispy"
from a terminal will spawn a Vispy 3D viewer object which has a bunch of useful methods. Note that this requires one of navis' vispy-*
extras to be installed, so that vispy has a backend.
Function | Description |
---|---|
navis.Viewer | Vispy 3D viewer. |
navis.Viewer.add() | Add objects to canvas. |
navis.Viewer.clear() | Clear canvas. |
navis.Viewer.close() | Close viewer. |
`navis.Viewer.colorize() | Colorize neurons using a seaborn color palette. |
navis.Viewer.set_colors() | Set neuron color. |
navis.Viewer.hide_neurons() | Hide given neuron(s). |
navis.Viewer.unhide_neurons() | Unhide given neuron(s). |
navis.Viewer.screenshot() | Save a screenshot of this viewer. |
navis.Viewer.show() | Show viewer. |
navis.Viewer.toggle_bounds() | Toggle bounding box. |
Octarine 3D viewer#
Using navis.plot3d()
with backend="octarine"
from a terminal will return an octarine.Viewer
3D viewer. Please see the Octarine
documentation for details about the viewer.
Neuron Morphology#
Collection of functions to analyze and manipulate neuronal morphology.
Analyse#
Functions to analyze morphology.
Function | Description |
---|---|
navis.find_main_branchpoint() | Find main branch point of unipolar (e.g. insect) neurons. |
navis.form_factor() | Calculate form factor for given neuron. |
navis.persistence_points() | Calculate points for a persistence diagram. |
navis.persistence_vectors() | Produce vectors from persistence points. |
navis.strahler_index() | Calculate Strahler Index (SI). |
navis.segment_analysis() | Calculate morphometric properties a neuron's segments. |
navis.ivscc_features() | Calculate IVSCC features for neuron(s). |
navis.sholl_analysis() | Run Sholl analysis for given neuron(s). |
navis.tortuosity() | Calculate tortuosity of a neuron. |
navis.betweeness_centrality() | Calculate vertex/node betweenness. |
Manipulate#
Functions to edit morphology:
Function | Description |
---|---|
navis.average_skeletons() | Compute an average from a list of skeletons. |
navis.break_fragments() | Break neuron into its connected components. |
navis.despike_skeleton() | Remove spikes in skeleton (e.g. from jumps in image data). |
navis.drop_fluff() | Remove small disconnected pieces of "fluff". |
navis.cell_body_fiber() | Prune neuron to its cell body fiber. |
navis.combine_neurons() | Combine multiple neurons into one. |
navis.cut_skeleton() | Split skeleton at given point and returns two new neurons. |
navis.guess_radius() | Guess radii for skeleton nodes. |
navis.heal_skeleton() | Heal fragmented skeleton(s). |
navis.longest_neurite() | Return a neuron consisting of only the longest neurite(s). |
navis.prune_by_strahler() | Prune neuron based on Strahler order. |
navis.prune_twigs() | Prune terminal twigs under a given size. |
navis.prune_at_depth() | Prune all neurites past a given distance from a source. |
navis.reroot_skeleton() | Reroot neuron to new root. |
navis.split_axon_dendrite() | Split a neuron into axon and dendrite. |
navis.split_into_fragments() | Split neuron into fragments. |
navis.stitch_skeletons() | Stitch multiple skeletons together. |
navis.subset_neuron() | Subset a neuron to a given set of nodes/vertices. |
navis.smooth_skeleton() | Smooth skeleton(s) using rolling windows. |
navis.smooth_mesh() | Smooth meshes (TriMesh, MeshNeuron, Volume). |
navis.smooth_voxels() | Smooth voxel(s) using a Gaussian filter. |
navis.thin_voxels() | Skeletonize image data to single voxel width. |
Resampling#
Functions to down- or resample neurons.
Function | Description |
---|---|
navis.resample_skeleton() | Resample skeleton(s) to given resolution. |
navis.resample_along_axis() | Resample neuron such that nodes lie exactly on given 1d grid. |
navis.downsample_neuron() | Downsample neuron(s) by a given factor. |
navis.simplify_mesh() | Simplify meshes (TriMesh, MeshNeuron, Volume). |
Comparing morphology#
NBLAST and related functions:
Module | Description |
---|---|
navis.nblast | NBLAST query against target neurons. |
navis.nblast_smart | Smart(er) NBLAST query against target neurons. |
navis.nblast_allbyall | All-by-all NBLAST of inputs neurons. |
navis.nblast_align | Run NBLAST on pairwise-aligned neurons. |
navis.synblast | Synapsed-based variant of NBLAST. |
navis.persistence_distances | Calculate morphological similarity using persistence diagrams. |
Utilities for creating your own score matrices for NBLAST:#
Function | Description |
---|---|
navis.nbl.smat.Lookup2d | Convenience class inheriting from LookupNd for the common 2D float case. |
navis.nbl.smat.Digitizer | Class converting continuous values into discrete indices. |
navis.nbl.smat.LookupDistDotBuilder | Class for building a 2-dimensional score lookup for NBLAST. |
Utilities for NBLAST#
Function | Description |
---|---|
navis.nbl.make_clusters() | Form flat clusters. |
navis.nbl.update_scores() | Update score matrix by running only new query->target pairs. |
navis.nbl.compress_scores() | Compress scores. |
navis.nbl.extract_matches() | Extract top matches from score matrix. |
[navis.nbl.nblast_prime() ][navis.nbl.nblast_prime] | Error finding docstring for navis.nbl.nblast_prime: module 'navis.nbl' has no attribute 'nblast_prime' |
Polarity metrics#
Function | Description |
---|---|
navis.bending_flow() | Calculate synapse "bending" flow. |
navis.flow_centrality() | Calculate flow between leaf nodes. |
navis.synapse_flow_centrality() | Calculate synapse flow centrality (SFC). |
navis.arbor_segregation_index() | Per arbor seggregation index (SI). |
navis.segregation_index() | Calculate segregation index (SI). |
Distances#
Functions to calculate Euclidean and geodesic ("along-the-arbor") distances.
Function | Description |
---|---|
navis.cable_overlap() | Calculate the amount of cable of neuron A within distance of neuron B. |
navis.distal_to() | Check if nodes A are distal to nodes B. |
navis.dist_between() | Get the geodesic distance between nodes in nanometers. |
navis.dist_to_root() | Calculate distance to root for each node. |
navis.geodesic_matrix() | Generate geodesic ("along-the-arbor") distance matrix between nodes/vertices. |
navis.segment_length() | Get length of a linear segment. |
Intersection#
Functions to intersect points and neurons with volumes. For example, if you'd like to know which part of a neuron is inside a certain brain region.
Function | Description |
---|---|
navis.in_volume() | Test if points/neurons are within a given volume. |
navis.intersection_matrix() | Compute intersection matrix between a set of neurons and volumes. |
Transforming and Mirroring#
Functions to transform spatial data, e.g. move neurons from one brain space to another. Check out the tutorials for examples on how to use them.
High-level functions:
Function | Description |
---|---|
navis.xform() | Apply transform(s) to data. |
navis.xform_brain() | Transform 3D data between template brains. |
navis.symmetrize_brain() | Symmetrize 3D object (neuron, coordinates). |
navis.mirror_brain() | Mirror 3D object (neuron, coordinates) about given axis. |
navis.transforms.mirror() | |
navis.align.align_rigid() | Align neurons using a rigid registration. |
navis.align.align_deform() | Align neurons using a deformable registration. |
navis.align.align_pca() | Align neurons along their first principal components. |
navis.align.align_pairwise() | Run a pairwise alignment between given neurons. |
NAVis supports several types of transforms:
Class | Description |
---|---|
navis.transforms.AffineTransform | Affine transformation of 3D spatial data. |
navis.transforms.ElastixTransform | Elastix transforms of 3D spatial data. |
navis.transforms.CMTKtransform | CMTK transforms of 3D spatial data. |
navis.transforms.H5transform | Hdf5 transform of 3D spatial data. |
navis.transforms.TPStransform | Thin Plate Spline transforms of 3D spatial data. |
navis.transforms.AliasTransform | Helper transform that simply passes points through. |
navis.transforms.MovingLeastSquaresTransform | Error finding docstring for navis.transforms.MovingLeastSquaresTransform: 'NoneType' object has no attribute 'split' |
The TemplateRegistry
keeps track of template brains, transforms and such:
Class | Description |
---|---|
navis.transforms.templates.TemplateRegistry | Tracks template brains, available transforms and produces bridging sequences. |
The relevant instance of this class is navis.transforms.registry
. So to register and use a new transform you would look something like this:
>>> transform = navis.transforms.AffineTransform(...)
>>> navis.transforms.registry.register_transform(transform,
... source='brainA',
... target='brainB')
>>> xf = navis.xform_brain(data, 'brainA', 'brainB')
You can check which transforms are registered like so:
>>> navis.transforms.registry.summary() # this outputs a dataframe
These are the methods and properties of registry
:
Method | Description |
---|---|
TemplateRegistry.register_transform() | Register a transform. |
TemplateRegistry.register_transformfile() | Parse and register a transform file. |
TemplateRegistry.register_templatebrain() | Register a template brain. |
TemplateRegistry.register_path() | Register path(s) to scan for transforms. |
TemplateRegistry.scan_paths() | Scan registered paths for transforms and add to registry. |
TemplateRegistry.plot_bridging_graph() | Draw bridging graph using networkX. |
TemplateRegistry.find_mirror_reg() | Search for a mirror transformation for given template. |
TemplateRegistry.find_bridging_path() | Find bridging path from source to target. |
TemplateRegistry.shortest_bridging_seq() | Find shortest bridging sequence to get from source to target. |
TemplateRegistry.clear_caches() | Clear caches of all cached functions. |
TemplateRegistry.summary() | Generate summary of available transforms. |
TemplateRegistry.transforms() | Registered transforms (bridging + mirror). |
TemplateRegistry.mirrors() | Registered mirror transforms. |
TemplateRegistry.bridges() | Registered bridging transforms. |
Connectivity#
Collection of functions to work with graphs and adjacency matrices.
Function | Description |
---|---|
navis.NeuronConnector | Class which creates a connectivity graph from a set of neurons. |
Connectivity metrics#
Functions to analyse/cluster neurons based on connectivity.
Function | Description |
---|---|
navis.connectivity_similarity() | Calculate connectivity similarity. |
navis.connectivity_sparseness() | Calculate sparseness. |
navis.cable_overlap() | Calculate the amount of cable of neuron A within distance of neuron B. |
navis.synapse_similarity() | Cluster neurons based on their synapse placement. |
Import/Export#
Functions to import neurons.
Function | Description |
---|---|
navis.read_swc() | Create Neuron/List from SWC file. |
navis.read_nrrd() | Create Neuron/List from NRRD file. |
navis.read_mesh() | Load mesh file into Neuron/List. |
navis.read_tiff() | Create Neuron/List from TIFF file. |
navis.read_nmx() | Read NMX files into Neuron/Lists. |
navis.read_nml() | Read xml-based NML files into Neuron/Lists. |
navis.read_rda() | Read objects from nat R data (.rda) file. |
navis.read_json() | Load neuron from JSON (file or string). |
navis.read_precomputed() | Read skeletons and meshes from neuroglancer's precomputed format. |
navis.read_parquet() | Read parquet file into Neuron/List. |
navis.scan_parquet() | Scan parquet file. |
Functions to export neurons.
Function | Description |
---|---|
navis.write_swc() | Write TreeNeuron(s) to SWC. |
navis.write_nrrd() | Write VoxelNeurons or Dotprops to NRRD file(s). |
navis.write_mesh() | Export meshes (MeshNeurons, Volumes, Trimeshes) to disk. |
navis.write_json() | Save neuron(s) to json-formatted file. |
navis.write_precomputed() | Export skeletons or meshes to neuroglancer's (legacy) precomputed format. |
navis.write_parquet() | Write TreeNeuron(s) or Dotprops to parquet file. |
Utility#
Various utility functions.
Function | Description |
---|---|
navis.health_check() | Run a health check on TreeNeurons and flag potential issues. |
navis.set_pbars() | Set global progress bar behaviors. |
navis.set_loggers() | Set levels for all associated module loggers. |
navis.set_default_connector_colors() | Set/update default connector colors. |
navis.config.remove_log_handlers() | Remove all handlers from the navis logger. |
navis.patch_cloudvolume() | Monkey patch cloud-volume to return navis neurons. |
navis.example_neurons() | Load example neuron(s). |
navis.example_volume() | Load an example volume. |
Conversion#
Functions to convert between data types.
Function | Description |
---|---|
navis.neuron2nx() | Turn Tree-, Mesh- or VoxelNeuron into an NetworkX graph. |
navis.neuron2igraph() | Turn Tree-, Mesh- or VoxelNeuron(s) into an iGraph graph. |
navis.neuron2KDTree() | Turn neuron into scipy KDTree. |
navis.neuron2tangents() | Turn skeleton(s) into points + tangent vectors. |
navis.network2nx() | Generate NetworkX graph from edge list or adjacency. |
navis.network2igraph() | Generate iGraph graph from edge list or adjacency. |
navis.nx2neuron() | Create TreeNeuron from NetworkX Graph. |
navis.edges2neuron() | Create TreeNeuron from edges and (optional) vertex coordinates. |
Network Models#
NAVis comes with a simple network traversal model (used in Schlegel, Bates et al., 2021).
Not imported at top level! Must be imported explicitly:
from navis import models
Class | Description |
---|---|
navis.models.TraversalModel | Model for traversing a network starting with given seed nodes. |
navis.models.BayesianTraversalModel | Model for traversing a network starting with given seed nodes. |
Interfaces#
Interfaces with various external tools/websites. These modules have to be imported explicitly as they are not imported at top level.
NEURON simulator#
Functions to facilitate creating models of neurons/networks. Please see the tutorials for examples.
Not imported at top level! Must be imported explicitly:
import navis.interfaces.neuron as nrn
Compartment models#
A single-neuron compartment model is represented by CompartmentModel
:
Class | Description |
---|---|
CompartmentModel | Compartment model representing a single neuron in NEURON. |
DrosophilaPN | Compartment model of an olfactory projection neuron in Drosophila. |
The DrosophilaPN
class is a subclass of CompartmentModel
with pre-defined properties from Tobin et al. (2017).
Method | Description |
---|---|
CompartmentModel.add_current_record() | Add current recording to model. |
CompartmentModel.add_spike_detector() | Add a spike detector at given node(s). |
CompartmentModel.add_synaptic_current() | Add synaptic current(s) (AlphaSynapse) to model. |
CompartmentModel.add_synaptic_input() | Add synaptic input to model. |
CompartmentModel.add_voltage_record() | Add voltage recording to model. |
CompartmentModel.clear_records() | Clear records. |
CompartmentModel.clear_stimuli() | Clear stimuli. |
CompartmentModel.connect() | Connect object to model. |
CompartmentModel.get_node_section() | Return section(s) for given node(s). |
CompartmentModel.get_node_segment() | Return segment(s) for given node(s). |
CompartmentModel.inject_current_pulse() | Add current injection (IClamp) stimulation to model. |
CompartmentModel.plot_results() | Plot results. |
CompartmentModel.insert() | Insert biophysical mechanism for model. |
CompartmentModel.uninsert() | Remove biophysical mechanism from model. |
Attribute | Description |
---|---|
CompartmentModel.Ra | Axial resistance [Ohm * cm] of all sections. |
CompartmentModel.cm | Membran capacity [micro Farads / cm^2] of all sections. |
CompartmentModel.label | Name/label of the neuron. |
CompartmentModel.n_records | Number of records (across all types) active on this model. |
CompartmentModel.n_sections | Number of sections in this model. |
CompartmentModel.n_stimuli | Number of stimuli active on this model. |
CompartmentModel.nodes | Node table of the skeleton. |
CompartmentModel.records | Return mapping of node ID(s) to recordings. |
CompartmentModel.sections | List of sections making up this model. |
CompartmentModel.stimuli | Return mapping of node ID(s) to stimuli. |
CompartmentModel.synapses | Return mapping of node ID(s) to synapses. |
CompartmentModel.t | The global time. Should be the same for all neurons. |
Network models#
A network of point-processes is represented by PointNetwork
:
Class | Description |
---|---|
PointNetwork | A Network of Leaky-Integrate-and-Fire (LIF) point processes. |
Methods | Description |
---|---|
PointNetwork.add_background_noise() | Add background noise to given neurons. |
PointNetwork.add_neurons() | Add neurons to network. |
PointNetwork.add_stimulus() | Add stimulus to given neurons. |
PointNetwork.connect() | Connect two neurons. |
PointNetwork.from_edge_list() | Generate network from edge list. |
PointNetwork.get_spike_counts() | Get matrix of spike counts. |
PointNetwork.plot_raster() | Raster plot of spike timings. |
PointNetwork.plot_traces() | Plot mean firing rate. |
PointNetwork.run_simulation() | Run the simulation. |
PointNetwork.set_labels() | Set labels for neurons. |
Attributes | Description |
---|---|
PointNetwork.edges | Edges between nodes of the network. |
PointNetwork.ids | IDs of neurons in the network. |
PointNetwork.labels | Labels of neurons in the network. |
PointNetwork.neurons | Neurons in the network. |
NeuroMorpho API#
Set of functions to grab data from NeuroMorpho which hosts thousands of neurons (see tutorials).
Not imported at top level! Must be imported explicitly:
from navis.interfaces import neuromorpho
Function | Description |
---|---|
neuromorpho.get_neuron_info() | Fetch neuron info by ID or by name. |
neuromorpho.get_neuron() | Fetch neuron by ID or by name. |
neuromorpho.get_neuron_fields() | List all available neuron fields. |
neuromorpho.get_available_field_values() | List all possible values for given neuron field. |
neuPrint API#
NAVis wraps neuprint-python
and adds a few navis-specific functions. You must have neuprint-python
installed for this to work:
pip install neuprint-python -U
You can then import neuprint from NAVis like so:
from navis.interfaces import neuprint
These are the additional functions added by NAVis:
Function | Description |
---|---|
neuprint.fetch_roi() | Fetch given ROI. |
neuprint.fetch_skeletons() | Fetch neuron skeletons as navis.TreeNeurons. |
neuprint.fetch_mesh_neuron() | Fetch neuron meshes as navis.MeshNeuron. |
Please also check out the tutorials for examples of how to fetch and work with data from neuPrint.
InsectBrain DB API#
Set of functions to grab data from InsectBrain which hosts some neurons and standard brains (see tutorials).
Not imported at top level! Must be imported explicitly:
from navis.interfaces import insectbrain_db
Function | Description |
---|---|
insectbrain_db.authenticate() | Authenticate against Insect Brain DB. |
insectbrain_db.get_brain_meshes() | Fetch brain meshes for given species. |
[insectbrain_db.get_species_info() ][navis.interfaces.insectbrain_db.get_species_info] | Get all info for given species. |
[insectbrain_db.get_available_species() ][navis.interfaces.insectbrain_db.get_available_species] | Get all info for given species. |
insectbrain_db.get_skeletons() | Fetch skeletons for given neuron(s). |
insectbrain_db.get_skeletons_species() | Fetch all skeletons for given species. |
insectbrain_db.search_neurons() | Search for neurons matching given parameters. |
Blender API#
Functions to be run inside Blender 3D and import CATMAID data (see Examples). Please note that this requires Blender >2.8 as earlier versions are shipped with older Python versions not supported by NAVis. See the tutorials for an introduction of how to use NAVis in Blender.
Not imported at top level! Must be imported explicitly:
from navis.interfaces import blender
The interface is realised through a navis.interfaces.blender.Handler
object. It is used to import objects and facilitate working with them programmatically once they are imported.
Class | Description |
---|---|
blender.Handler | Class that interfaces with scene in Blender. |
Objects#
Method | Description |
---|---|
blender.Handler.add() | Add neuron(s) to scene. |
blender.Handler.clear() | Clear all neurons |
blender.Handler.select() | Select given neurons. |
blender.Handler.hide() | Hide all neuron-related objects. |
blender.Handler.unhide() | Unide all neuron-related objects. |
Materials#
Properties | Description |
---|---|
blender.Handler.color() | Assign color to all neurons. |
blender.Handler.colorize() | Randomly colorize ALL neurons. |
blender.Handler.emit() | Change emit value. |
blender.Handler.use_transparency() | Change transparency (True/False). |
blender.Handler.alpha() | Change alpha (0-1). |
blender.Handler.bevel() | Change bevel of ALL neurons. |
Selections#
You can use Handler.select()
to select a group of neurons e.g. by type. That method then returns ObjectList
which can be used to modify just the selected objects:
Methods | Description |
---|---|
blender.Handler.select() | Select given neurons. |
blender.ObjectList.select() | Select objects in 3D viewer |
blender.ObjectList.color() | Assign color to all objects in the list. |
blender.ObjectList.colorize() | Assign colors across the color spectrum. |
blender.ObjectList.emit() | Change emit value. |
blender.ObjectList.use_transparency() | Change transparency (True/False). |
blender.ObjectList.alpha() | Change alpha (0-1). |
blender.ObjectList.bevel() | Change bevel radius of objects. |
blender.ObjectList.hide() | Hide objects. |
blender.ObjectList.unhide() | Unhide objects. |
blender.ObjectList.hide_others() | Hide everything BUT these objects. |
blender.ObjectList.delete() | Delete neurons in the selection. |
Cytoscape API#
Warning
The Cytoscape API is depcrecated and will be removed in a future version of NAVis.
Functions to use Cytoscape via the cyREST API.
Not imported at top level! Must be imported explicitly:
from navis.interfaces import cytoscape
Function | Description |
---|---|
[cytoscape.generate_network() ][navis.interfaces.cytoscape.generate_network] | Error finding docstring for navis.interfaces.cytoscapecytoscape.generate_network: module 'navis.interfaces' has no attribute 'cytoscapecytoscape' |
[cytoscape.get_client() ][navis.interfaces.cytoscape.get_client] | Error finding docstring for navis.interfaces.cytoscapecytoscape.get_client: module 'navis.interfaces' has no attribute 'cytoscapecytoscape' |
Allen MICrONS datasets#
Functions to fetch neurons (including synapses) from the Allen Institute's MICrONS EM datasets.
Requires caveclient
and cloud-volume
as additional dependencies:
pip3 install caveclient cloud-volume -U
Please see caveclient's docs for details on how to retrieve and set credentials.
Not imported at top level! Must be imported explicitly:
from navis.interfaces import microns
Function | Description |
---|---|
microns.get_cave_client() | Get caveclient for given datastack. |
microns.fetch_neurons() | Fetch neuron meshes. |
[microns.get_somas() ][navis.interfaces.microns.get_somas] | Error finding docstring for navis.interfaces.microns.get_somas: module 'navis.interfaces.microns' has no attribute 'get_somas' |
Please also see the MICrONS tutorial.
H01 dataset#
Functions to fetch neurons (including synapses) from the H01 connectome dataset.
Requires caveclient
and cloud-volume
as additional dependencies:
pip3 install caveclient cloud-volume -U
Not imported at top level! Must be imported explicitly:
from navis.interfaces import h01
Function | Description |
---|---|
h01.get_cave_client() | Get caveclient for H01 dataset. |
h01.fetch_neurons() | Fetch neuron meshes. |
[h01.get_somas() ][navis.interfaces.h01.get_somas] | Error finding docstring for navis.interfaces.h01.get_somas: module 'navis.interfaces.h01' has no attribute 'get_somas' |
Please also see the H01 tutorial.
R interface#
Bundle of functions to use R natverse libraries.
Not imported at top level! Must be imported explicitly:
from navis.interfaces import r
Function | Description |
---|---|
[r.data2py() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.data2py: module 'navis.interfaces' has no attribute 'r' |
[r.get_neuropil() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.get_neuropil: module 'navis.interfaces' has no attribute 'r' |
[r.init_rcatmaid() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.init_rcatmaid: module 'navis.interfaces' has no attribute 'r' |
[r.load_rda() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.load_rda: module 'navis.interfaces' has no attribute 'r' |
[r.nblast() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.nblast: module 'navis.interfaces' has no attribute 'r' |
[r.nblast_allbyall() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.nblast_allbyall: module 'navis.interfaces' has no attribute 'r' |
[r.NBLASTresults() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.NBLASTresults: module 'navis.interfaces' has no attribute 'r' |
[r.neuron2py() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.neuron2py: module 'navis.interfaces' has no attribute 'r' |
[r.neuron2r() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.neuron2r: module 'navis.interfaces' has no attribute 'r' |
[r.xform_brain() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.xform_brain: module 'navis.interfaces' has no attribute 'r' |
[r.mirror_brain() ][navis.interfaces.r.data2py] | Error finding docstring for navis.interfaces.r.mirror_brain: module 'navis.interfaces' has no attribute 'r' |
Neuron types and functions#
As you can imagine not all functions will work on all neuron types. For example it is currently not possible to find the longest neurite via longest_neurite()
for a VoxelNeuron
. Conversely, some functionality like "smoothing" makes sense for multiple neuron types but the application is so vastly different between e.g. meshes and skeletons that there are specicialized functions for every neuron type.
Below table has an overview for which functions work with which neuron types:
TreeNeuron | MeshNeuron | VoxelNeuron | Dotprops | |
---|---|---|---|---|
navis.plot2d | yes | yes | limited | yes |
navis.plot3d | yes | yes | see backend | yes |
navis.plot1d | yes | no | no | no |
navis.plot_flat | yes | no | no | no |
navis.subset_neuron | yes | yes | yes | yes |
navis.in_volume | yes | yes | yes | yes |
smoothing | navis.smooth_skeleton | navis.smooth_mesh | navis.smooth_voxels | no |
navis.downsample_neuron | yes | yes | yes | yes |
resampling (e.g. navis.resample_skeleton ) | yes | no | no | no |
navis.make_dotprops | yes | yes | yes | yes |
NBLAST (navis.nblast , etc.) | no1 | no1 | no1 | yes |
navis.xform_brain | yes | yes | yes (slow!) | yes |
navis.mirror_brain | yes | yes | no | yes |
navis.skeletonize | no | yes | no | no |
navis.mesh | yes | no | yes | no |
navis.voxelize | yes | yes | no | yes |
navis.drop_fluff | yes | yes | no | no |
navis.break_fragments | yes | yes | no | no |
-
Use
navis.make_dotprops
to turn these neurons intonavis.Dotprops
. ↩↩↩