API Reference

navis has grown a lot! Last I looked, there were ~110 functions exposed at top level (e.g. navis.plot3d) and easily another 100 secondary functions available via submodules (e.g. navis.morpho.find_soma). This can be a bit daunting at first - especially if you don’t exactly know what you are looking for.

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 an issue on the Github repo with your question.

This API reference is a more or less complete account of the primary functions:

  1. Neuron- and NeuronList functions and methods

  2. Functions for visualization

  3. Manipulate or analyze neuron morphology

  4. Transforming and mirroring data

  5. Analyze connectivity

  6. Import/Export

  7. Utility functions

  8. Which functions work with which neuron types?

In addition navis has interfaces to various external datasets and tools:

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.

navis.TreeNeuron(x[, units])

Neuron represented as hierarchical tree (i.e. a skeleton).

navis.MeshNeuron(x[, units, process, validate])

Neuron represented as mesh with vertices and faces.

navis.VoxelNeuron(x[, offset, cache, units])

Neuron represented as voxels.

navis.Dotprops(points, k[, vect, alpha, units])

Neuron represented as points + local vectors.

navis.NeuronList(x[, make_copy, make_using, ...])

Collection of 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.

copy([deepcopy])

Return a copy of the neuron.

plot3d(**kwargs)

Plot neuron using navis.plot3d().

plot2d(**kwargs)

Plot neuron using navis.plot2d().

summary([add_props])

Get a summary of this neuron.

convert_units(to[, inplace])

Convert coordinates to different unit.

map_units(units[, on_error])

Convert units to match neuron space.

memory_usage([deep, estimate])

Return estimated memory usage of this neuron.

In addition to methods, neurons also have properties. These properties common to all neurons:

connectors

Connector table.

postsynapses

Table with postsynapses (filtered from connectors table).

presynapses

Table with presynapses (filtered from connectors table).

datatables

Names of all DataFrames attached to this neuron.

id

ID of the neuron.

name

Neuron name.

units

Unit space for this neuron.

type

Neuron type.

TreeNeurons

A navis.TreeNeuron is a skeletons. These are class methods available specific for this neuron type. Note that most of them are simply short-hands for the other navis functions:

convert_units(to[, inplace])

Convert coordinates to different unit.

cell_body_fiber([reroot_soma, inplace])

Prune neuron to its cell body fiber.

downsample([factor, inplace])

Downsample the neuron by given factor.

get_graph_nx()

Calculate and return networkX representation of neuron.

get_igraph()

Calculate and return iGraph representation of neuron.

prune_by_longest_neurite([n, reroot_soma, ...])

Prune neuron down to the longest neurite.

prune_by_strahler(to_prune[, inplace])

Prune neuron based on Strahler order.

prune_by_volume(v[, mode, ...])

Prune neuron by intersection with given volume(s).

prune_distal_to(node[, inplace])

Cut off nodes distal to given nodes.

prune_proximal_to(node[, inplace])

Remove nodes proximal to given node.

prune_twigs(size[, inplace, recursive])

Prune terminal twigs under a given size.

reload([inplace])

Reload neuron.

reroot(new_root[, inplace])

Reroot neuron to given node ID or node tag.

resample(resample_to[, inplace])

Resample neuron to given resolution.

snap(locs[, to])

Snap xyz location(s) to closest node or synapse.

In addition, a navis.TreeNeuron has a range of different properties:

cable_length

Cable length.

cycles

Cycles in neuron (if any).

downsample([factor, inplace])

Downsample the neuron by given factor.

igraph

iGraph representation of this neuron.

is_tree

Whether neuron is a tree.

n_branches

Number of branch points.

n_leafs

Number of leaf nodes.

n_skeletons

Number of seperate skeletons in this neuron.

n_trees

Count number of connected trees in this neuron.

nodes

Node table.

root

Root node(s).

sampling_resolution

Average cable length between child -> parent nodes.

segments

Neuron broken down into linear segments (see also .small_segments).

simple

Simplified representation consisting only of root, branch points and leafs.

soma_pos

Search for soma and return its position.

subtrees

List of subtrees.

volume

Radius-based volume.

MeshNeurons

Properties specific to navis.MeshNeuron:

faces

Faces making up the neuron.

vertices

Vertices making up the neuron.

trimesh

Trimesh representation of the neuron.

volume

Volume of the neuron.

sampling_resolution

Average distance between vertices.

Methods specific to navis.MeshNeuron:

skeletonize([method, heal, inv_dist])

Skeletonize mesh.

snap(locs[, to])

Snap xyz location(s) to closest vertex or synapse.

validate([inplace])

Use trimesh to try and fix some common mesh issues.

VoxelNeurons

navis.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:

grid

Voxel grid representation.

voxels

(N, 3) array of x/y/z voxels locations

shape

Shape of voxel grid.

strip([inplace])

Strip empty voxels (leading/trailing planes of zeros).

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:

points

Center of tangent vectors.

vect

Tangent vectors.

alpha

Alpha value for tangent vectors (optional).

to_skeleton([scale_vec])

Turn dotprops into a skeleton.

snap(locs[, to])

Snap xyz location(s) to closest point or synapse.

Conversion

There are a couple functions to convert from one neuron type to another:

navis.make_dotprops(x[, k, resample, threshold])

Produce dotprops from neurons or x/y/z points.

navis.skeletonize(x, **kwargs)

Turn neuron into skeleton.

navis.mesh(x, **kwargs)

Generate mesh from object(s).

navis.voxelize(x, pitch[, bounds, counts, ...])

Turn neuron into voxels.

navis.conversion.voxels2mesh(vox[, spacing, ...])

Generate mesh from voxels using marching cubes.

navis.conversion.tree2meshneuron(x[, ...])

Convert TreeNeuron to MeshNeuron.

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:

apply(func, *[, parallel, n_cores, ...])

Apply function across all neurons in this NeuronList.

head([N])

Return summary for top N neurons.

itertuples()

Helper to mimic pandas.DataFrame.itertuples().

mean()

Return mean numeric and boolean values over all neurons.

remove_duplicates([key, keep, inplace])

Remove duplicate neurons from list.

sum()

Return sum numeric and boolean values over all neurons.

summary([N, add_props, progress])

Get summary over all neurons in this NeuronList.

tail([N])

Return summary for bottom N neurons.

unmix()

Split into NeuronLists of the same neuron type.

Properties:

bbox

Bounding box across all neurons in the list.

empty

Return True if NeuronList is empty.

is_degenerated

Return True if contains neurons with non-unique IDs.

is_mixed

Return True if contains more than one type of neuron.

shape

Shape of NeuronList (N, ).

types

Return neuron types present in this list.

Please see the ref:tutorial<neuron_overview> on NeuronLists for more information, including how to index them.

Visualization

Various functions for plotting neurons and volumes.

navis.plot3d(x, **kwargs)

Generate 3D plot.

navis.plot2d(x[, method])

Generate 2D plots of neurons and neuropils.

navis.plot1d(x[, ax, color, color_by, palette])

Plot neuron topology in 1D according to Cuntz et al. (2010).

navis.plot_flat(x[, layout, connectors, ...])

Plot neuron as flat diagrams.

navis.clear3d()

Clear viewer 3D canvas.

navis.close3d()

Close existing vispy 3D canvas (wipes memory).

navis.pop3d()

Remove the last item added to the 3D canvas.

navis.get_viewer()

Grab active 3D viewer.

navis.screenshot([file, alpha])

Save a screenshot of active vispy 3D canvas.

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.

navis.Volume(vertices[, faces, name, color, id])

Mesh consisting of vertices and faces.

navis.Volume.combine(x[, name, color])

Merge multiple volumes into a single object.

navis.Volume.plot3d(**kwargs)

Plot volume using navis.plot3d().

navis.Volume.validate()

Use trimesh to try and fix issues (holes/normals).

navis.Volume.resize(x[, method, inplace])

Resize volume.

Vispy 3D viewer

Using navis.plot3d() 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.

navis.Viewer([picking])

Vispy 3D viewer.

navis.Viewer.add(x[, center, clear, combine])

Add objects to canvas.

navis.Viewer.clear()

Clear canvas.

navis.Viewer.close()

Close viewer.

navis.Viewer.colorize([palette, ...])

Colorize neurons using a seaborn color palette.

navis.Viewer.set_colors(c[, include_connectors])

Set neuron color.

navis.Viewer.hide_neurons(n)

Hide given neuron(s).

navis.Viewer.unhide_neurons([n, check_alpha])

Unhide given neuron(s).

navis.Viewer.screenshot([filename, ...])

Save a screenshot of this viewer.

navis.Viewer.show()

Show viewer.

navis.Viewer.toggle_bounds()

Toggle bounding box.

Neuron Morphology

Collection of functions to analyze and manipulate neuronal morphology.

Manipulation

Functions to edit morphology:

navis.average_skeletons(x[, limit, base_neuron])

Compute an average from a list of skeletons.

navis.break_fragments(x[, labels_only, min_size])

Break neuron into its connected components.

navis.despike_skeleton(x[, sigma, ...])

Remove spikes in skeleton (e.g. from jumps in image data).

navis.drop_fluff(x[, keep_size, inplace])

Remove small disconnected pieces of "fluff".

navis.cell_body_fiber(x[, method, ...])

Prune neuron to its cell body fiber.

navis.combine_neurons(*x)

Combine multiple neurons into one.

navis.cut_skeleton(x, where[, ret])

Split skeleton at given point and returns two new neurons.

navis.guess_radius(x[, method, limit, ...])

Guess radii for skeleton nodes.

navis.heal_skeleton(x[, method, max_dist, ...])

Heal fragmented skeleton(s).

navis.longest_neurite(x[, n, reroot_soma, ...])

Return a neuron consisting of only the longest neurite(s).

navis.prune_by_strahler(x, to_prune[, ...])

Prune neuron based on Strahler order.

navis.prune_twigs(x, size[, exact, inplace, ...])

Prune terminal twigs under a given size.

navis.prune_at_depth(x, depth, *[, source, ...])

Prune all neurites past a given distance from a source.

navis.reroot_skeleton(x, new_root[, inplace])

Reroot neuron to new root.

navis.split_axon_dendrite(x[, metric, ...])

Split a neuron into axon and dendrite.

navis.split_into_fragments(x[, n, min_size, ...])

Split neuron into fragments.

navis.stitch_skeletons(*x[, method, master, ...])

Stitch multiple skeletons together.

navis.subset_neuron(x, subset[, inplace, ...])

Subset a neuron to a given set of nodes/vertices.

navis.smooth_skeleton(x[, window, ...])

Smooth skeleton(s) using rolling windows.

navis.smooth_mesh(x[, iterations, L, ...])

Smooth meshes (TriMesh, MeshNeuron, Volume).

navis.smooth_voxels(x[, sigma, inplace])

Smooth voxel(s) using a Gaussian filter.

Resampling

Functions to down- or resample neurons.

navis.resample_skeleton(x, resample_to[, ...])

Resample skeleton(s) to given resolution.

navis.resample_along_axis(x, interval[, ...])

Resample neuron such that nodes lie exactly on given 1d grid.

navis.downsample_neuron(x, downsampling_factor)

Downsample neuron(s) by a given factor.

navis.simplify_mesh(x, F[, backend, inplace])

Simplify meshes (TriMesh, MeshNeuron, Volume).

Morphometrics

Functions to analyze morphology.

navis.find_main_branchpoint(x[, method, ...])

Find main branch point of unipolar (e.g. insect) neurons.

navis.form_factor(x[, start, stop, num, ...])

Calculate form factor for given neuron.

navis.persistence_points(x[, descriptor, ...])

Calculate points for a persistence diagram.

navis.persistence_vectors(x[, threshold, ...])

Produce vectors from persistence points.

navis.strahler_index(x[, method, to_ignore, ...])

Calculate Strahler Index (SI).

navis.segment_analysis(x)

Calculate morphometric properties a neuron's segments.

navis.sholl_analysis(x[, radii, center, ...])

Run Sholl analysis for given neuron(s).

navis.tortuosity(x[, seg_length])

Calculate tortuosity of a neuron.

navis.betweeness_centrality(x[, from_, directed])

Calculate vertex/node betweenness.

Functions to compare morphology.

navis.nblast(query[, target, scores, ...])

NBLAST query against target neurons.

navis.nblast_smart(query[, target, t, ...])

Smart(er) NBLAST query against target neurons.

navis.nblast_allbyall(x[, normalized, ...])

All-by-all NBLAST of inputs neurons.

navis.nblast_align(query[, target, ...])

Run NBLAST on pairwise-aligned neurons.

navis.synblast(query, target[, by_type, ...])

Synapsed-based variant of NBLAST.

navis.persistence_distances(q[, t, augment, ...])

Calculate morphological similarity using persistence diagrams.

Utilities for creating your own score matrices for NBLAST can be found in

navis.nbl.smat.Lookup2d(axis0, axis1, cells)

Convenience class inheriting from LookupNd for the common 2D float case.

navis.nbl.smat.Digitizer(boundaries[, clip, ...])

Class converting continuous values into discrete indices.

navis.nbl.smat.LookupDistDotBuilder(...[, ...])

Utilities for NBLAST

navis.nbl.make_clusters(x, t[, criterion, ...])

Form flat clusters.

navis.nbl.update_scores(queries, targets, ...)

Update score matrix by running only new query->target pairs.

navis.nbl.compress_scores(scores[, ...])

Compress scores.

navis.nbl.extract_matches(scores[, N, ...])

Extract top matches from score matrix.

Polarity metrics

navis.bending_flow(x)

Calculate synapse "bending" flow.

navis.flow_centrality(x)

Calculate flow between leaf nodes.

navis.synapse_flow_centrality(x[, mode])

Calculate synapse flow centrality (SFC).

navis.arbor_segregation_index(x)

Per arbor seggregation index (SI).

navis.segregation_index(x)

Calculate segregation index (SI).

Distances

Functions to calculate Euclidian and geodesic (“along-the-arbor”) distances.

navis.cable_overlap(a, b[, dist, method])

Calculate the amount of cable of neuron A within distance of neuron B.

navis.distal_to(x[, a, b])

Check if nodes A are distal to nodes B.

navis.dist_between(x, a, b)

Get the geodesic distance between nodes in nanometers.

navis.dist_to_root(x[, weight, igraph_indices])

Calculate distance to root for each node.

navis.geodesic_matrix(x[, from_, directed, ...])

Generate geodesic ("along-the-arbor") distance matrix between nodes/vertices.

navis.segment_length(x, segment)

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.

navis.in_volume(x, volume[, mode, backend, ...])

Test if points/neurons are within a given volume.

navis.intersection_matrix(x, volumes[, attr])

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:

navis.xform(x, transform[, affine_fallback, ...])

Apply transform(s) to data.

navis.xform_brain(x, source, target[, via, ...])

Transform 3D data between template brains.

navis.symmetrize_brain(x, template[, via, ...])

Symmetrize 3D object (neuron, coordinates).

navis.mirror_brain(x, template[, ...])

Mirror 3D object (neuron, coordinates) about given axis.

navis.transforms.mirror(points, mirror_axis_size)

Mirror 3D coordinates about given axis.

navis.align.align_rigid(x[, target, scale, ...])

Align neurons using a rigid registration.

navis.align.align_deform(x[, target, ...])

Align neurons using a deformable registration.

navis.align.align_pca(x[, individually])

Align neurons along their first principal components.

navis.align.align_pairwise(x[, y, method, ...])

Run a pairwise alignment between given neurons.

navis supports several types of transforms:

AffineTransform(matrix[, direction])

Affine transformation of 3D spatial data.

ElastixTransform(file[, copy_files])

Elastix transforms of 3D spatial data.

CMTKtransform(regs[, directions, threads])

CMTK transforms of 3D spatial data.

H5transform(f[, direction, level, cache, ...])

Hdf5 transform of 3D spatial data.

TPStransform(landmarks_source, landmarks_target)

Thin Plate Spline transforms of 3D spatial data.

AliasTransform()

Helper transform that simply passes points through.

MovingLeastSquaresTransform(...[, direction])

Moving Least Squares transforms of 3D spatial data.

The TemplateRegistry keeps track of template brains, transforms and such:

TemplateRegistry([scan_paths])

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 do this for example:

>>> transform = navis.transforms.AffineTransform(...)
>>> navis.transforms.registry.register_transform(transform,
...                                              source='brainA',
...                                              target='brainB')
>>> xf = navis.xform_brain(data, 'brainA', 'brainB')

These are the methods and properties of registry:

register_transform(transform, source, ...[, ...])

Register a transform.

register_transformfile(path, **kwargs)

Parse and register a transform file.

register_templatebrain(template[, skip_existing])

Register a template brain.

register_path(paths[, trigger_scan])

Register path(s) to scan for transforms.

scan_paths([extra_paths])

Scan registered paths for transforms and add to registry.

plot_bridging_graph(**kwargs)

Draw bridging graph using networkX.

find_mirror_reg(template[, non_found])

Search for a mirror transformation for given template.

find_bridging_path(source, target[, via, ...])

Find bridging path from source to target.

shortest_bridging_seq(source, target[, via, ...])

Find shortest bridging sequence to get from source to target.

clear_caches()

Clear caches of all cached functions.

summary()

Generate summary of available transforms.

transforms

Registered transforms (bridging + mirror).

mirrors

Registered mirror transforms.

bridges

Registered bridging transforms.

Connectivity

Collection of functions to work with graphs and adjacency matrices.

navis.NeuronConnector([nrns])

Class which creates a connectivity graph from a set of neurons.

Graphs

Functions to convert between neurons graph representation (networkx or iGraph).

navis.neuron2nx(x)

Turn Tree-, Mesh- or VoxelNeuron into an NetworkX graph.

navis.neuron2igraph(x[, connectivity, ...])

Turn Tree-, Mesh- or VoxelNeuron(s) into an iGraph graph.

navis.neuron2KDTree(x[, tree_type, data])

Turn neuron into scipy KDTree.

navis.network2nx(x[, threshold, group_by])

Generate NetworkX graph from edge list or adjacency.

navis.network2igraph(x[, threshold])

Generate iGraph graph from edge list or adjacency.

navis.rewire_skeleton(x, g[, root, inplace])

Rewire neuron from graph.

navis.insert_nodes(x, where[, coords, ...])

Insert new nodes between existing nodes.

navis.remove_nodes(x, which[, inplace])

Drop nodes from neuron without disconnecting it.

Connectivity metrics

Functions to analyse/cluster neurons based on connectivity.

navis.connectivity_similarity(adjacency[, ...])

Calculate connectivity similarity.

navis.connectivity_sparseness(x[, which])

Calculate sparseness.

navis.cable_overlap(a, b[, dist, method])

Calculate the amount of cable of neuron A within distance of neuron B.

navis.synapse_similarity(x, sigma, omega[, ...])

Cluster neurons based on their synapse placement.

Import/Export

Functions to import/export neurons.

navis.read_swc(f[, connector_labels, ...])

Create Neuron/List from SWC file.

navis.write_swc(x, filepath[, header, ...])

Write TreeNeuron(s) to SWC.

navis.read_nrrd(f[, threshold, ...])

Create Neuron/List from NRRD file.

navis.write_nrrd(x, filepath[, ...])

Write VoxelNeurons or Dotprops to NRRD file(s).

navis.read_mesh(f[, include_subdirs, ...])

Create Neuron/List from mesh.

navis.write_mesh(x[, filepath, filetype])

Export meshes (MeshNeurons, Volumes, Trimeshes) to disk.

navis.read_tiff(f[, channel, threshold, ...])

Create Neuron/List from TIFF file.

navis.read_nmx(f[, include_subdirs, ...])

Read NMX files into Neuron/Lists.

navis.read_nml(f[, include_subdirs, ...])

Read xml-based NML files into Neuron/Lists.

navis.read_rda(f[, combine, neurons_only])

Read objects from nat R data (.rda) file.

navis.read_json(s, **kwargs)

Load neuron from JSON (file or string).

navis.write_json(x, filepath, **kwargs)

Save neuron(s) to json-formatted file.

navis.write_precomputed(x[, filepath, ...])

Export skeletons or meshes to neuroglancer's (legacy) precomputed format.

navis.read_precomputed(f[, datatype, ...])

Read skeletons and meshes from neuroglancer's precomputed format.

navis.read_parquet(f[, read_meta, limit, ...])

Read parquet file into Neuron/List.

navis.write_parquet(x, filepath[, write_meta])

Write TreeNeuron(s) or Dotprops to parquet file.

navis.scan_parquet(file)

Scan parquet file.

Utility

Various utility functions.

navis.health_check(x[, verbose])

Run a health check on TreeNeurons and flag potential issues.

navis.set_pbars([hide, leave, jupyter])

Set global progress bar behaviors.

navis.set_loggers([level])

Set levels for all associated module loggers.

navis.set_default_connector_colors(x)

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([n, kind, synapses, ...])

Load example neuron(s).

navis.example_volume(name)

Load an example volume.

Interfaces

Interfaces with various external tools/websites. These modules have to be imported explicitly as they are not imported at top level.

Network Models

Navis comes with a simple network traversal model (see Schlegel, Bates et al., 2021).

navis.models.network_models.TraversalModel(...)

Model for traversing a network starting with given seed nodes.

navis.models.network_models.BayesianTraversalModel(*args)

Model for traversing a network starting with given seed nodes.

NEURON simulator

Functions to facilitate creating models of neurons/networks. Please see the tutorials for details.

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:

navis.interfaces.neuron.comp.CompartmentModel(x)

Compartment model representing a single neuron in NEURON.

navis.interfaces.neuron.comp.DrosophilaPN(x)

Compartment model of an olfactory projection neuron in Drosophila.

The DrosophilaPN class is a subclass of CompartmentModel with properties used from Tobin et al.

Class methods

add_current_record(where[, label])

Add current recording to model.

add_spike_detector(where[, threshold, label])

Add a spike detector at given node(s).

add_synaptic_current(where[, start, tau, ...])

Add synaptic current(s) (AlphaSynapse) to model.

add_synaptic_input(where[, start, spike_no, ...])

Add synaptic input to model.

add_voltage_record(where[, label])

Add voltage recording to model.

clear_records()

Clear records.

clear_stimuli()

Clear stimuli.

connect(pre, where[, syn_tau1, syn_tau2, ...])

Connect object to model.

get_node_section(node_ids)

Return section(s) for given node(s).

get_node_segment(node_ids)

Return segment(s) for given node(s).

inject_current_pulse(where[, start, ...])

Add current injection (IClamp) stimulation to model.

plot_results([axes])

Plot results.

insert(mechanism[, subset])

Insert biophysical mechanism for model.

uninsert(mechanism[, subset])

Remove biophysical mechanism from model.

Class attributes

Ra

Axial resistance [Ohm * cm] of all sections.

cm

Membran capacity [micro Farads / cm^2] of all sections.

label

Name/label of the neuron.

n_records

Number of records (across all types) active on this model.

n_sections

Number of sections in this model.

n_stimuli

Number of stimuli active on this model.

nodes

Node table of the skeleton.

records

Return mapping of node ID(s) to recordings.

sections

List of sections making up this model.

stimuli

Return mapping of node ID(s) to stimuli.

synapses

Return mapping of node ID(s) to synapses.

Network models

A network of point-processes is represented by PointNetwork:

navis.interfaces.neuron.network.PointNetwork()

A Network of Leaky-Integrate-and-Fire (LIF) point processes.

Class methods

__init__()

add_background_noise(ids, frequency[, ...])

Add background noise to given neurons.

add_neurons(ids[, model, labels, skip_existing])

Add neurons to network.

add_stimulus(ids, start, frequency[, stop, ...])

Add stimulus to given neurons.

connect(source, target, weight[, delay])

Connect two neurons.

from_edge_list(edges[, model, source_col, ...])

Generate network from edge list.

get_spike_counts([bin_size, subset, ...])

Get matrix of spike counts.

plot_raster([subset, group, stimuli, ax, ...])

Raster plot of spike timings.

plot_traces([bin_size, subset, ...])

Plot mean firing rate.

run_simulation([duration, v_init])

Run the simulation.

set_labels(labels)

Set labels for neurons.

Class attributes

edges

Edges between nodes of the network.

ids

IDs of neurons in the network.

labels

Labels of neurons in the network.

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

neuromorpho.get_neuron_info(x)

Fetch neuron info by ID or by name.

neuromorpho.get_neuron(x[, parallel, ...])

Fetch neuron by ID or by name.

neuromorpho.get_neuron_fields()

List all available neuron fields.

neuromorpho.get_available_field_values(field)

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

You can then import neuprint from navis like so:

from navis.interfaces import neuprint

These are the additional functions added by navis:

neuprint.fetch_roi(roi, *[, client])

Fetch given ROI.

neuprint.fetch_skeletons(x, *[, ...])

Construct navis.TreeNeuron/List from neuprint neurons.

neuprint.fetch_mesh_neuron(x, *[, lod, ...])

Fetch mesh neuron.

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

insectbrain_db.authenticate([username, ...])

Authenticate against Insect Brain DB.

insectbrain_db.get_brain_meshes(species[, ...])

Fetch brain meshes for given species.

insectbrain_db.get_species_info(species)

Get all info for given species.

insectbrain_db.get_available_species()

Get all info for given species.

insectbrain_db.get_skeletons(x[, max_threads])

Fetch skeletons for given neuron(s).

insectbrain_db.get_skeletons_species(species)

Fetch all skeletons for given species.

insectbrain_db.search_neurons([name, ...])

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 Python <3.6. 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 Handler object. It is used to import objects and facilitate working with them programmatically once they are imported.

blender.Handler([scaling, axes_order, ...])

Class that interfaces with scene in Blender.

Objects

blender.Handler.add(x[, neurites, soma, ...])

Add neuron(s) to scene.

blender.Handler.clear()

Clear all neurons

blender.Handler.select(x, *args)

Select given neurons.

blender.Handler.hide()

Hide all neuron-related objects.

blender.Handler.unhide()

Unide all neuron-related objects.

Materials

blender.Handler.color(r, g, b)

Assign color to all neurons.

blender.Handler.colorize()

Randomly colorize ALL neurons.

blender.Handler.emit(v)

Change emit value.

blender.Handler.use_transparency(v)

Change transparency (True/False).

blender.Handler.alpha(v)

Change alpha (0-1).

blender.Handler.bevel(r)

Change bevel of ALL neurons.

Selections

blender.Handler.select(x, *args)

Select given neurons.

blender.ObjectList.select([unselect_others])

Select objects in 3D viewer

blender.ObjectList.color(r, g, b[, a])

Assign color to all objects in the list.

blender.ObjectList.colorize([groups, palette])

Assign colors across the color spectrum.

blender.ObjectList.emit(e)

Change emit value.

blender.ObjectList.use_transparency(t)

Change transparency (True/False).

blender.ObjectList.alpha(a)

Change alpha (0-1).

blender.ObjectList.bevel(r)

Change bevel radius of objects.

blender.ObjectList.hide([viewport, render])

Hide objects.

blender.ObjectList.unhide([viewport, render])

Unhide objects.

blender.ObjectList.hide_others()

Hide everything BUT these objects.

blender.ObjectList.delete()

Delete neurons in the selection.

Cytoscape API

Functions to use Cytoscape via the cyREST API.

Not imported at top level! Must be imported explicitly:

from navis.interfaces import cytoscape

cytoscape.generate_network(x[, layout, ...])

Load network into Cytoscape.

cytoscape.get_client()

Initialises connection with Cytoscape and returns client.

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

microns.fetch_neurons(x, *[, lod, ...])

Fetch neuron meshes.

microns.get_somas(root_ids[, table, datastack])

Fetch somas based on nuclei segmentation for given neuron(s).

Please also see the MICrONS 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

r.data2py(data, **kwargs)

Convert data from rcatmaid (e.g. catmaidneuron from read.neuron.catmaid) and converts into Python Data.

r.get_neuropil(x[, template])

Fetch given neuropil from nat.flybrains, flycircuit or elmr.

r.init_rcatmaid(**kwargs)

Initialize the R Catmaid package.

r.load_rda(fp[, convert])

Load and convert R data file (.rda).

r.nblast(query[, target, scores, n_cores, ...])

NBLAST using R's nat.nblast::nblast.

r.nblast_allbyall(x[, normalized, k, ...])

All-by-all NBLAST using R's nat.nblast::nblast_allbyall.

r.NBLASTresults(results, sc, scr, query, ...)

Class holding NBLAST results and wrappers that allow easy plotting.

r.neuron2py(x)

Convert R neuron objects (dotprops, neurons, etc) to navis Neuron/Lists.

r.neuron2r(x[, unit_conversion, add_metadata])

Convert Neuron/List to corresponding R neuron/neuronlist object.

r.xform_brain(x, source, target[, fallback, ...])

Transform 3D data between template brains.

r.mirror_brain(x, template[, mirror_axis, ...])

Mirror 3D object along given axixs.

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 navis.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.

Description

TreeNeuron

MeshNeuron

VoxelNeuron

Dotprops

navis.plot2d()

yes

yes

limited

yes

navis.plot3d()

yes

yes

limited

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

NBLAST (e.g. navis.nblast())

no

no

no

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