[][src]Crate nblast

Implementation of the NBLAST algorithm for quantifying neurons' morphological similarity. Originally published in Costa et al. (2016) and implemented as part of the NeuroAnatomy Toolbox.

Algorithm

Each neuron is passed in as a point cloud sample (the links between the points are not required). A tangent vector is calculated for each point, based on its location and that of its 4 nearest neighbors. To query the similarity of neuron Q to neuron T:

  • Take a point and its associated tangent in Q
    • Find the nearest point in T, and its associated tangent
    • Compute the distance between the two points
    • Compute the absolute dot product of the two tangents
    • Apply some empirically-derived function to the (distance, dot_product) tuple
      • As published, this is the log probabity ratio of any pair belonging to closely related or unrelated neurons
  • Repeat for all points, summing the results

The result is not easily comparable: it is highly dependent on the size of the point cloud and is not commutative, i.e. f(Q, T) != f(T, Q).

To make queries between two pairs of neurons comparable, the result can be normalized by the "self-hit" score of the query, i.e. f(Q, Q).

To make the result commutative, the forward f(Q, T) and backward f(T, Q) scores can be combined in some way. This library supports several means (arithmetic, harmonic, and geometric), the minimum, and the maximum. The choice will depend on the application. This can be applied after the scores are normalized.

More information on the algorithm can be found here.

Usage

The QueryNeuron and TargetNeuron traits define types which can be compared with NBLAST. All TargetNeurons are also QueryNeurons.

QueryPointTangents and RStarPointTangents implement these, respectively. Both can be created with pre-calculated tangents, or calculate them on instantiation.

The NblastArena contains a collection of TargetNeurons and a function to apply to pointwise (distance, absolute dot product) pairs to generate a score for that point match, for convenient many-to-many comparisons. A pre-calculated table of point match scores can be converted into a function with table_to_fn.

Re-exports

pub use nalgebra;

Structs

DistDot

The result of comparing two (point, tangent) tuples. Contains the Euclidean distance between the points, and the absolute dot product of the (unit) tangents, i.e. the absolute cosine of the angle between them.

NblastArena

Struct for caching a number of neurons for multiple comparable NBLAST queries.

QueryPointTangents

Minimal struct to use as the query (not the target) of an NBLAST comparison.

RStarPointTangents

Target neuron using an R*-tree for spatial queries.

Enums

Symmetry

Enumeration of methods to ensure that queries are symmetric/ commutative (i.e. f(q, t) = f(t, q)). Specific applications will require different methods. Geometric and harmonic means bound the output to be >= 0.0. Geometric mean may work best with non-normalized queries. Min may work if an unknown one of the query and target is incomplete.

Traits

QueryNeuron

Trait for objects which can be used as queries (not necessarily as targets) with NBLAST. See TargetNeuron.

TargetNeuron

Functions

table_to_fn

Convert an empirically-derived table mapping pointwise distance and tangent absolute dot products to pointwise scores into a function which can be passed to neuron queries. These scores are then summed across all points in the query to give the raw NBLAST score.

Type Definitions

NeuronIdx
Precision

Floating point precision type used internally