This modules provides functions to calculate correlations between spike trains.
elephant.spike_train_correlation.
cch
(binned_st1, binned_st2, window='full', border_correction=False, binary=False, kernel=None, method='speed', cross_corr_coef=False)¶Computes the cross-correlation histogram (CCH) between two binned spike trains binned_st1 and binned_st2.
Parameters: | binned_st1, binned_st2 : BinnedSpikeTrain
window : string or list (optional)
border_correction : bool (optional)
binary : bool (optional)
kernel : array or None (optional)
method : string (optional)
cross_corr_coef : bool (optional)
|
---|---|
Returns: | cch : AnalogSignal
bin_ids : ndarray of int
|
elephant.spike_train_correlation.
corrcoef
(binned_sts, binary=False)[source]¶Calculate the NxN matrix of pairwise Pearson’s correlation coefficients between all combinations of N binned spike trains.
For each pair of spike trains , the correlation coefficient
is obtained by binning
and
at the
desired bin size. Let
and
denote the binary vectors
and
and
their respective averages. Then
where <..,.> is the scalar product of two vectors.
For an input of n spike trains, a n x n matrix is returned. Each entry in the matrix is a real number ranging between -1 (perfectly anti-correlated spike trains) and +1 (perfectly correlated spike trains).
If binary is True, the binned spike trains are clipped to 0 or 1 before
computing the correlation coefficients, so that the binned vectors
and
are binary.
Parameters: | binned_sts : elephant.conversion.BinnedSpikeTrain
binary : bool, optional
|
---|---|
Returns: | C : ndarrray
|
Notes
Examples
Generate two Poisson spike trains
>>> from elephant.spike_train_generation import homogeneous_poisson_process
>>> st1 = homogeneous_poisson_process(
rate=10.0*Hz, t_start=0.0*s, t_stop=10.0*s)
>>> st2 = homogeneous_poisson_process(
rate=10.0*Hz, t_start=0.0*s, t_stop=10.0*s)
Calculate the correlation matrix.
>>> from elephant.conversion import BinnedSpikeTrain
>>> cc_matrix = corrcoef(BinnedSpikeTrain([st1, st2], binsize=5*ms))
The correlation coefficient between the spike trains is stored in cc_matrix[0,1] (or cc_matrix[1,0]).
elephant.spike_train_correlation.
covariance
(binned_sts, binary=False)[source]¶Calculate the NxN matrix of pairwise covariances between all combinations of N binned spike trains.
For each pair of spike trains , the covariance
is obtained by binning
and
at the desired bin size. Let
and
denote the binary vectors and
and
their respective averages. Then
where <..,.> is the scalar product of two vectors.
For an input of n spike trains, a n x n matrix is returned containing the covariances for each combination of input spike trains.
If binary is True, the binned spike trains are clipped to 0 or 1 before
computing the covariance, so that the binned vectors and
are binary.
Parameters: | binned_sts : elephant.conversion.BinnedSpikeTrain
binary : bool, optional
|
---|---|
Returns: | C : ndarrray
|
Notes
Examples
Generate two Poisson spike trains
>>> from elephant.spike_train_generation import homogeneous_poisson_process
>>> st1 = homogeneous_poisson_process(
rate=10.0*Hz, t_start=0.0*s, t_stop=10.0*s)
>>> st2 = homogeneous_poisson_process(
rate=10.0*Hz, t_start=0.0*s, t_stop=10.0*s)
Calculate the covariance matrix.
>>> from elephant.conversion import BinnedSpikeTrain
>>> cov_matrix = covariance(BinnedSpikeTrain([st1, st2], binsize=5*ms))
The covariance between the spike trains is stored in cc_matrix[0,1] (or cov_matrix[1,0]).
elephant.spike_train_correlation.
cross_correlation_histogram
(binned_st1, binned_st2, window='full', border_correction=False, binary=False, kernel=None, method='speed', cross_corr_coef=False)[source]¶Computes the cross-correlation histogram (CCH) between two binned spike trains binned_st1 and binned_st2.
Parameters: | binned_st1, binned_st2 : BinnedSpikeTrain
window : string or list (optional)
border_correction : bool (optional)
binary : bool (optional)
kernel : array or None (optional)
method : string (optional)
cross_corr_coef : bool (optional)
|
---|---|
Returns: | cch : AnalogSignal
bin_ids : ndarray of int
|
elephant.spike_train_correlation.
spike_time_tiling_coefficient
(spiketrain_1, spiketrain_2, dt=array(0.005) * s)[source]¶Calculates the Spike Time Tiling Coefficient (STTC) as described in (Cutts & Eglen, 2014) following Cutts’ implementation in C. The STTC is a pairwise measure of correlation between spike trains. It has been proposed as a replacement for the correlation index as it presents several advantages (e.g. it’s not confounded by firing rate, appropriately distinguishes lack of correlation from anti-correlation, periods of silence don’t add to the correlation and it’s sensible to firing pattern).
The STTC is calculated as follows:
Where PA is the proportion of spikes from train 1 that lie within [-dt, +dt] of any spike of train 2 divided by the total number of spikes in train 1, PB is the same proportion for the spikes in train 2; TA is the proportion of total recording time within [-dt, +dt] of any spike in train 1, TB is the same propotion for train 2.
This is a Python implementation compatible with the elephant library of the original code by C. Cutts written in C and avaiable at: (https://github.com/CCutts/Detecting_pairwise_correlations_in_spike_trains/blob/master/spike_time_tiling_coefficient.c)
Parameters: | spiketrain_1, spiketrain_2: neo.Spiketrain objects to cross-correlate.
dt: Python Quantity.
|
---|---|
Returns: | index: float
|
References
Cutts, C. S., & Eglen, S. J. (2014). Detecting Pairwise Correlations in Spike Trains: An Objective Comparison of Methods and Application to the Study of Retinal Waves. Journal of Neuroscience, 34(43), 14288–14303.
elephant.spike_train_correlation.
sttc
(spiketrain_1, spiketrain_2, dt=array(0.005) * s)¶Calculates the Spike Time Tiling Coefficient (STTC) as described in (Cutts & Eglen, 2014) following Cutts’ implementation in C. The STTC is a pairwise measure of correlation between spike trains. It has been proposed as a replacement for the correlation index as it presents several advantages (e.g. it’s not confounded by firing rate, appropriately distinguishes lack of correlation from anti-correlation, periods of silence don’t add to the correlation and it’s sensible to firing pattern).
The STTC is calculated as follows:
Where PA is the proportion of spikes from train 1 that lie within [-dt, +dt] of any spike of train 2 divided by the total number of spikes in train 1, PB is the same proportion for the spikes in train 2; TA is the proportion of total recording time within [-dt, +dt] of any spike in train 1, TB is the same propotion for train 2.
This is a Python implementation compatible with the elephant library of the original code by C. Cutts written in C and avaiable at: (https://github.com/CCutts/Detecting_pairwise_correlations_in_spike_trains/blob/master/spike_time_tiling_coefficient.c)
Parameters: | spiketrain_1, spiketrain_2: neo.Spiketrain objects to cross-correlate.
dt: Python Quantity.
|
---|---|
Returns: | index: float
|
References
Cutts, C. S., & Eglen, S. J. (2014). Detecting Pairwise Correlations in Spike Trains: An Objective Comparison of Methods and Application to the Study of Retinal Waves. Journal of Neuroscience, 34(43), 14288–14303.