elephant.spike_train_dissimilarity.van_rossum_distance

elephant.spike_train_dissimilarity.van_rossum_distance(spiketrains, time_constant=array(1.) * s, sort=True)[source]

Calculates the van Rossum distance (Rossum, 2001), defined as Euclidean distance of the spike trains convolved with a causal decaying exponential smoothing filter.

The implementation is normalized to yield a distance of 1.0 for the distance between an empty spike train and a spike train with a single spike. Divide the result by sqrt(2.0) to get the normalization used in the paper.

Given \(N\) spike trains with \(n\) spikes on average the run-time complexity of this function is \(O(N^2 n)\).

Parameters:
spiketrainsSequence of neo.core.SpikeTrain objects of

which the van Rossum distance will be calculated pairwise.

time_constantQuantity scalar

Decay rate of the exponential function as time scalar. Controls for which time scale the metric will be sensitive. Denoted as \(t_c\) in (Rossum, 2001). This parameter will be ignored if kernel is not None. May also be scipy.inf which will lead to only measuring differences in spike count. Default: 1.0 * pq.s

sortbool

Spike trains with sorted spike times might be needed for the calculation. You can set sort to False if you know that your spike trains are already sorted to decrease calculation time. Default: True

Returns:
np.ndarray

2-D Matrix containing the van Rossum distances for all pairs of spike trains.

Examples

>>> from elephant.spike_train_dissimilarity import van_rossum_distance
>>> tau = 10.0 * pq.ms
>>> st_a = SpikeTrain([10, 20, 30], units='ms', t_stop= 1000.0)
>>> st_b = SpikeTrain([12, 24, 30], units='ms', t_stop= 1000.0)
>>> vr = van_rossum_distance([st_a, st_b], tau)[0, 1]