elephant.spike_train_surrogates.jitter_spikes¶
- elephant.spike_train_surrogates.jitter_spikes(spiketrain, bin_size, n_surrogates=1)[source]¶
Generates surrogates of a spike train by spike jittering.
The surrogates are obtained by defining adjacent time bins spanning the spiketrain range, and randomly re-positioning (independently for each surrogate) each spike in the time bin it falls into.
The surrogates retain the spiketrain.t_start and spiketrain.t_stop. Note that within each time bin the surrogate spike trains are locally Poissonian (the inter-spike-intervals are exponentially distributed).
- Parameters:
- spiketrainneo.SpikeTrain
The spike train from which to generate the surrogates.
- bin_sizepq.Quantity
Size of the time bins within which to randomize the spike times. Note: the last bin lasts until spiketrain.t_stop and might have width different from bin_size.
- n_surrogatesint, optional
Number of surrogates to be generated. Default: 1
- Returns:
- list of neo.SpikeTrain
Each surrogate spike train obtained independently from spiketrain by randomly replacing its spikes within bins of user-defined width. The time range of the surrogate spike trains is the same as in spiketrain.
Examples
>>> import quantities as pq >>> import neo ... >>> st = neo.SpikeTrain([80, 150, 320, 480] * pq.ms, t_stop=1 * pq.s) # noqa >>> print(jitter_spikes(st, bin_size=100 * pq.ms)) [<SpikeTrain(array([ 98.82898293, 178.45805954, 346.93993867, 461.34268507]) * ms, [0.0 ms, 1000.0 ms])>] >>> print(jitter_spikes(st, bin_size=100 * pq.ms, n_surrogates=2)) [<SpikeTrain(array([ 97.15720041, 199.06945744, 397.51928207, 402.40065162]) * ms, [0.0 ms, 1000.0 ms])>, <SpikeTrain(array([ 80.74513157, 173.69371317, 338.05860962, 495.48869981]) * ms, [0.0 ms, 1000.0 ms])>] >>> print(jitter_spikes(st, bin_size=100 * pq.ms)) [<SpikeTrain(array([ 4.55064897e-01, 1.31927046e+02, 3.57846265e+02, 4.69370604e+02]) * ms, [0.0 ms, 1000.0 ms])>]