elephant.spike_train_synchrony.spike_contrast¶

elephant.spike_train_synchrony.
spike_contrast
(spiketrains, t_start=None, t_stop=None, min_bin=array(10.0) * ms, bin_shrink_factor=0.9, return_trace=False)[source]¶ Calculates the synchrony of spike trains, according to [syn1]. The spike trains can have different lengths.
Original implementation by: Philipp Steigerwald [s160857@thab.de]
Parameters:  spiketrainslist of neo.SpikeTrain
A list of input spike trains to calculate the synchrony from.
 t_startpq.Quantity, optional
The beginning of the spike train. If None, it’s taken as the minimum value of `t_start`s of the input spike trains. Default: None
 t_stoppq.Quantity, optional
The end of the spike train. If None, it’s taken as the maximum value of t_stop of the input spike trains. Default: None
 min_binpq.Quantity, optional
Sets the minimum value for the bin_min that is calculated by the algorithm and defines the smallest bin size to compute the histogram of the input spiketrains. Default: 0.01 ms
 bin_shrink_factorfloat, optional
A multiplier to shrink the bin size on each iteration. The value must be in range (0, 1). Default: 0.9
 return_tracebool, optional
If set to True, returns a history of spikecontrast synchrony, computed for a range of different bin sizes, alongside with the maximum value of the synchrony. Default: False
Returns:  synchronyfloat
Returns the synchrony of the input spike trains.
 spike_contrast_tracenamedtuple
If return_trace is set to True, a SpikeContrastTrace namedtuple is returned with the following attributes:
.contrast  the average sum of differences of the number of spikes in subsuequent bins;
.active_spiketrains  the average number of spikes per bin, weighted by the number of spike trains containing at least one spike inside the bin;
.synchrony  the product of contrast and active_spiketrains.
Raises:  ValueError
If bin_shrink_factor is not in (0, 1) range.
If the input spike trains constist of a single spiketrain.
If all input spike trains contain no more than 1 spike.
 TypeError
If the input spike trains is not a list of neo.SpikeTrain objects.
If t_start, t_stop, or min_bin are not time quantities.
Examples
>>> import quantities as pq >>> from elephant.spike_train_generation import homogeneous_poisson_process >>> from elephant.spike_train_synchrony import spike_contrast >>> spiketrain_1 = homogeneous_poisson_process(rate=20*pq.Hz, ... t_stop=1000*pq.ms) >>> spiketrain_2 = homogeneous_poisson_process(rate=20*pq.Hz, ... t_stop=1000*pq.ms) >>> spike_contrast([spiketrain_1, spiketrain_2]) 0.4192546583850932