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 (Wieland et al., 2015) (Eq. 6):
\[\tau_\mathrm{corr} = \int_{-\tau_\mathrm{max}}^{\tau_\mathrm{max}}\ \left[ \frac{\hat{C}(\tau)}{\hat{C}(0)} \right]^2 d\tau\]where \(\hat{C}(\tau) = C(\tau)-\nu\delta(\tau)\) denotes the auto-correlation function excluding the Dirac delta at zero timelag.
- Parameters:
- binned_spiketrainelephant.conversion.BinnedSpikeTrain
A binned spike train containing the spike train to be evaluated.
- max_taupq.Quantity
Maximal integration time \(\tau_{max}\) of the auto-correlation function. It needs to be a multiple of the bin_size of binned_spiketrain.
- Returns:
- timescalepq.Quantity
The 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
\(\tau_\mathrm{max}\) 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 \(d\tau\). 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