# Algorithms for Calculation of Distances Between Spike
Trains

## Toolkit

Download the Spike Train Analysis Toolkit, a user-friendly implementation from the
Laboratory of Neuroinformatics
that includes algorithms for information estimation via the
direct method,
the
binless method,
and the
metric space method, open-source, written in c.
This was developed by David H. Goldberg, Jonathan D. Victor, and Daniel Gardner, with funding
provided by the Human Brain Project-Neuroinformatics initiative via
MH068012 from NIMH, NINDS, NIA, NIBIB, and NSF with additional support from MH/NS057153 from NIMH and NINDS.

The algorithms below differ substantially in memory requirements and overhead. You are encouraged to try different variants on pilot data to determine relative performance, and
feedback to Jonathan D. Victor is welcome.

## Single-neuron spike time metric

### Basic algorithm

Fortran code for spike time metric D^{spike}[*q*] and spike interval metric D^{interval}[*q*]

Matlab code for spike time metric D^{spike}[*q*] courtesy of
Daniel Reich

Matlab code for normalized spike time metric D^{spike}[*q*] courtesy of
Laureline Logiaco

c/MEX code for spike time metric D^{spike}[*q*] courtesy of
Daniel Reich

### Vectorization

This implementations improve on the basic algorithm through the use of vectorized Matlab code. Abstractly, the algorithm is the same as the basic algorithm above. For a moderate number of values of *q*, this is faster than "algorithmic parallelization." The breakeven point will depend on the efficiency with which hardware makes use of Matlab vectorization.

Vectorized Matlab code for spike time metric D^{spike}[*q*] courtesy of Thomas Kreuz

### Algorithmic parallelization

This approach makes use of the fact that the metric distance is a piecewise linear function of *q*, and effectively calculates the cutpoints. Once this intermediate calculation is done, then the values of the metric distances can be rapidly read out for any value of *q*. It is thus the most efficient algorithm when the number of values of *q*
is very large.

Matlab code for spike time metric D^{spike}[*q*] parallel in *q*

## Multi-neuron (labeled) spike time metric

##

### Basic algorithm

Download paper describing the algorithm

Legacy:
Matlab code for multineuronal spike time metric D^{spike}[*q*,*k*].
This has an error concerning whether to swap the spike trains, and is not recommended.

For comparison purposes:
Matlab code for multineuronal spike time metric D^{spike}[*q*,*k*] courtesy of
Thomas Kreuz. This fixes an error concerning whether to swap the spike trains, but does not include any of the improvements below.

Matlab code
for multineuronal spike time metric D^{spike}[*q*,*k*] courtesy of Thomas Kreuz.
This fixes an error concerning whether to swap the spike trains, and also has an improved main calculation loop.

### Vectorization

These implementations improve on the basic algorithm through the use of vectorized Matlab code. See above comments regarding vectorization.

Vectorized Matlab code
for multineuronal spike time metric D^{spike}[*q*,*k*], courtesy of
Thomas Kreuz.

Vectorized Matlab code
for multineuronal spike time metric D^{spike}[*q*,*k*], courtesy of
Thomas Kreuz.
This is algorithmically the same as the above routine, but has improved memory management, allowing calculations for larger spike trains.

### Algorithmic parallelization

abstract and download of paper describing the algorithm for calculations parallel in *q* and *k*

Legacy: Matlab code for multineuronal spike time metric D^{spike}[*q*,*k*], parallel in
*q* and *k*.

Matlab code for multineuronal spike time metric D^{spike}[*q*,*k*], parallel in
*q* and *k*, optimized by John Zollweg, Cornell Theory Center.

## Single-neuron spike interval metric

##

### Basic algorithm

Matlab code for spike interval metric D^{interval}[*q*] courtesy of
Christina Behrend

Matlab code for spike interval metric D^{interval}[*q*], optimized, courtesy of
Christina Behrend and Jim Hokanson

#### original developers

Jonathan D. Victor: jdvicto@med.cornell.edu

Keith P. Purpura: kpurpura@med.cornell.edu

Dmitriy Aronov: aronov@mit.edu

Download related article ("Case Study") from
Cornell Theory Center

return to main cost-based metrics page

Last revised: 01/05/16