Statistical measures of spike trains (e.g., Fano factor) and functions to estimate firing rates.
elephant.statistics.
complexity_pdf
(spiketrains, binsize)[source]¶Complexity Distribution [1] of a list of neo.SpikeTrain
objects.
Probability density computed from the complexity histogram which is the histogram of the entries of the population histogram of clipped (binary) spike trains computed with a bin width of binsize. It provides for each complexity (== number of active neurons per bin) the number of occurrences. The normalization of that histogram to 1 is the probability density.
Parameters: | spiketrains : List of neo.SpikeTrain objects Spiketrains with a common time axis (same `t_start` and `t_stop`) binsize : quantities.Quantity Width of the histogram’s time bins. |
---|---|
Returns: | time_hist : neo.AnalogSignal A neo.AnalogSignal object containing the histogram values. AnalogSignal[j] is the histogram computed between . |
See also
References
[1]Gruen, S., Abeles, M., & Diesmann, M. (2008). Impact of higher-order correlations on coincidence distributions of massively parallel data. In Dynamic Brain-from Neural Spikes to Behaviors (pp. 96-114). Springer Berlin Heidelberg.
elephant.statistics.
cost_function
(x, N, w, dt)[source]¶The cost function Cn(w) = sum_{i,j} int k(x - x_i) k(x - x_j) dx - 2 sum_{i~=j} k(x_i - x_j)
elephant.statistics.
cv2
(v)[source]¶Calculate the measure of CV2 for a sequence of time intervals between events.
Given a vector v containing a sequence of intervals, the CV2 is defined as:
.math $$ CV2 := frac{1}{N}sum_{i=1}^{N-1}
- frac{2|isi_{i+1}-isi_i|}
- {|isi_{i+1}+isi_i|} $$
The CV2 is typically computed as a substitute for the classical coefficient of variation (CV) for sequences of events which include some (relatively slow) rate fluctuation. As with the CV, CV2=1 for a sequence of intervals generated by a Poisson process.
Parameters: | v : quantity array, numpy array or list
|
---|---|
Returns: | cv2 : float
|
Raises: | AttributeError :
AttributeError :
|
References
..[1] Holt, G. R., Softky, W. R., Koch, C., & Douglas, R. J. (1996). Comparison of discharge variability in vitro and in vivo in cat visual cortex neurons. Journal of neurophysiology, 75(5), 1806-1814.
elephant.statistics.
fanofactor
(spiketrains)[source]¶Evaluates the empirical Fano factor F of the spike counts of a list of neo.core.SpikeTrain objects.
Given the vector v containing the observed spike counts (one per spike train) in the time window [t0, t1], F is defined as:
F := var(v)/mean(v).
The Fano factor is typically computed for spike trains representing the activity of the same neuron over different trials. The higher F, the larger the cross-trial non-stationarity. In theory for a time-stationary Poisson process, F=1.
Parameters: | spiketrains : list of neo.SpikeTrain objects, quantity arrays, numpy arrays or lists
|
---|---|
Returns: | fano : float or nan
|
elephant.statistics.
fftkernel
(x, w)[source]¶Function `fftkernel’ applies the Gauss kernel smoother to an input signal using FFT algorithm.
Input argument x: Sample signal vector. w: Kernel bandwidth (the standard deviation) in unit of the sampling resolution of x.
Output argument y: Smoothed signal.
MAY 5/23, 2012 Author Hideaki Shimazaki RIKEN Brain Science Insitute http://2000.jukuin.keio.ac.jp/shimazaki
Ported to Python: Subhasis Ray, NCBS. Tue Jun 10 10:42:38 IST 2014
elephant.statistics.
instantaneous_rate
(spiketrain, sampling_period, kernel='auto', cutoff=5.0, t_start=None, t_stop=None, trim=False)[source]¶Estimates instantaneous firing rate by kernel convolution.
Parameters: | spiketrain : neo.SpikeTrain or list of neo.SpikeTrain objects
sampling_period : Time Quantity
kernel : string ‘auto’ or callable object of
cutoff : float
t_start : Time Quantity (optional)
t_stop : Time Quantity (optional)
trim : bool
|
---|---|
Returns: | rate : neo.AnalogSignal
|
Raises: | TypeError:
ValueError:
|
References
..[1] H. Shimazaki, S. Shinomoto, J Comput Neurosci (2010) 29:171–182.
elephant.statistics.
isi
(spiketrain, axis=-1)[source]¶Return an array containing the inter-spike intervals of the SpikeTrain.
Accepts a Neo SpikeTrain, a Quantity array, or a plain NumPy array. If either a SpikeTrain or Quantity array is provided, the return value will be a quantities array, otherwise a plain NumPy array. The units of the quantities array will be the same as spiketrain.
Parameters: | spiketrain : Neo SpikeTrain or Quantity array or NumPy ndarray
axis : int, optional
|
---|---|
Returns: | NumPy array or quantities array. |
elephant.statistics.
lv
(v)[source]¶Calculate the measure of local variation LV for a sequence of time intervals between events.
Given a vector v containing a sequence of intervals, the LV is defined as:
.math $$ LV := frac{1}{N}sum_{i=1}^{N-1}
- frac{3(isi_i-isi_{i+1})^2}
- {(isi_i+isi_{i+1})^2} $$
The LV is typically computed as a substitute for the classical coefficient of variation for sequences of events which include some (relatively slow) rate fluctuation. As with the CV, LV=1 for a sequence of intervals generated by a Poisson process.
Parameters: | v : quantity array, numpy array or list
|
---|---|
Returns: | lvar : float
|
Raises: | AttributeError :
ValueError :
|
References
..[1] Shinomoto, S., Shima, K., & Tanji, J. (2003). Differences in spiking patterns among cortical neurons. Neural Computation, 15, 2823–2842.
elephant.statistics.
make_kernel
(form, sigma, sampling_period, direction=1)[source]¶Creates kernel functions for convolution.
Constructs a numeric linear convolution kernel of basic shape to be used for data smoothing (linear low pass filtering) and firing rate estimation from single trial or trial-averaged spike trains.
Exponential and alpha kernels may also be used to represent postynaptic currents / potentials in a linear (current-based) model.
Parameters: | form : {‘BOX’, ‘TRI’, ‘GAU’, ‘EPA’, ‘EXP’, ‘ALP’}
sigma : Quantity
sampling_period : float
direction : {-1, 1}
|
---|---|
Returns: | kernel : numpy.ndarray
norm : float
m_idx : int
|
References
[R3] | Meier R, Egert U, Aertsen A, Nawrot MP, “FIND - a unified framework for neural data analysis”; Neural Netw. 2008 Oct; 21(8):1085-93. |
[R4] | Nawrot M, Aertsen A, Rotter S, “Single-trial estimation of neuronal firing rates - from single neuron spike trains to population activity”; J. Neurosci Meth 94: 81-92; 1999. |
Examples
To obtain single trial rate function of trial one should use:
r = norm * scipy.signal.fftconvolve(sua, kernel)
To obtain trial-averaged spike train one should use:
r_avg = norm * scipy.signal.fftconvolve(sua, np.mean(X,1))
where X is an array of shape (l,n), n is the number of trials and l is the length of each trial.
elephant.statistics.
mean_firing_rate
(spiketrain, t_start=None, t_stop=None, axis=None)[source]¶Return the firing rate of the SpikeTrain.
Accepts a Neo SpikeTrain, a Quantity array, or a plain NumPy array. If either a SpikeTrain or Quantity array is provided, the return value will be a quantities array, otherwise a plain NumPy array. The units of the quantities array will be the inverse of the spiketrain.
The interval over which the firing rate is calculated can be optionally controlled with t_start and t_stop
Parameters: | spiketrain : Neo SpikeTrain or Quantity array or NumPy ndarray
t_start : float or Quantity scalar, optional
t_stop : float or Quantity scalar, optional
axis : int, optional
|
---|---|
Returns: | float, quantities scalar, NumPy array or quantities array. |
Raises: | TypeError
|
Notes
If spiketrain is a Quantity or Neo SpikeTrain and t_start or t_stop are not, t_start and t_stop are assumed to have the same units as spiketrain.
elephant.statistics.
oldfct_instantaneous_rate
(spiketrain, sampling_period, form, sigma='auto', t_start=None, t_stop=None, acausal=True, trim=False)[source]¶Estimate instantaneous firing rate by kernel convolution.
Parameters: | spiketrain: ‘neo.SpikeTrain’
sampling_period : Quantity
form : {‘BOX’, ‘TRI’, ‘GAU’, ‘EPA’, ‘EXP’, ‘ALP’}
sigma : string or Quantity
t_start : Quantity (Optional)
t_stop : Qunatity
acausal : bool
m_idx : int
trim : bool
|
---|---|
Returns: | rate : neo.AnalogSignal
|
Raises: | TypeError:
|
See also
References
..[1] H. Shimazaki, S. Shinomoto, J Comput Neurosci (2010) 29:171–182.
elephant.statistics.
sskernel
(spiketimes, tin=None, w=None, bootstrap=False)[source]¶Calculates optimal fixed kernel bandwidth.
spiketimes: sequence of spike times (sorted to be ascending).
tin: (optional) time points at which the kernel bandwidth is to be estimated.
w: (optional) vector of kernel bandwidths. If specified, optimal bandwidth is selected from this.
bootstrap (optional): whether to calculate the 95% confidence interval. (default False)
Returns
A dictionary containing the following key value pairs:
‘y’: estimated density, ‘t’: points at which estimation was computed, ‘optw’: optimal kernel bandwidth, ‘w’: kernel bandwidths examined, ‘C’: cost functions of w, ‘confb95’: (lower bootstrap confidence level, upper bootstrap confidence level), ‘yb’: bootstrap samples.
Ref: Shimazaki, Hideaki, and Shigeru Shinomoto. 2010. Kernel Bandwidth Optimization in Spike Rate Estimation. Journal of Computational Neuroscience 29 (1-2): 171-82. doi:10.1007/s10827-009-0180-4.
elephant.statistics.
time_histogram
(spiketrains, binsize, t_start=None, t_stop=None, output='counts', binary=False)[source]¶Time Histogram of a list of neo.SpikeTrain
objects.
Parameters: | spiketrains : List of neo.SpikeTrain objects
binsize : quantities.Quantity
t_start, t_stop : Quantity (optional)
output : str (optional)
binary : bool (optional)
|
---|---|
Returns: | time_hist : neo.AnalogSignal
|
See also