elephant.spike_train_correlation.spike_train_timescale¶

elephant.spike_train_correlation.spike_train_timescale(binned_spiketrain, max_tau)[source]

Calculates the auto-correlation time of a binned spike train; uses the definition of the auto-correlation time proposed in [cor2] (Eq. 6): where denotes the auto-correlation function excluding the Dirac delta at zero timelag.

Parameters: binned_spiketrainelephant.conversion.BinnedSpikeTrainA binned spike train containing the spike train to be evaluated. max_taupq.QuantityMaximal integration time of the auto-correlation function. It needs to be a multiple of the bin_size of binned_spiketrain. timescalepq.QuantityThe auto-correlation time of the binned spiketrain with the same units as in the input. If binned_spiketrain has less than 2 spikes, a warning is raised and np.nan is returned.

Notes

• is a critical parameter: numerical estimates of the auto-correlation functions are inherently noisy. Due to the square in the definition above, this noise is integrated. Thus, it is necessary to introduce a cutoff for the numerical integration - this cutoff should be neither smaller than the true auto-correlation time nor much bigger.
• The bin size of binned_spiketrain is another critical parameter as it defines the discretization of the integral . If it is too big, the numerical approximation of the integral is inaccurate.

Examples

>>> import neo
>>> import numpy as np
>>> import quantities as pq
>>> from elephant.spike_train_correlation import spike_train_timescale
>>> from elephant.conversion import BinnedSpikeTrain
>>> spiketrain = neo.SpikeTrain([1, 5, 7, 8], units='ms', t_stop=10*pq.ms)
>>> bst = BinnedSpikeTrain(spiketrain, bin_size=1 * pq.ms)
>>> spike_train_timescale(bst, max_tau=5 * pq.ms)
array(14.11111111) * ms