elephant.spike_train_surrogates.randomise_spikes

elephant.spike_train_surrogates.randomise_spikes(spiketrain, n_surrogates=1, decimals=None)[source]

Generates surrogates of a spike train by spike time randomization.

The surrogates are obtained by keeping the spike count of the original spiketrain, but placing the spikes randomly in the interval [spiketrain.t_start, spiketrain.t_stop]. The generated independent neo.SpikeTrain objects follow Poisson statistics (exponentially distributed inter-spike intervals).

Parameters:
spiketrainneo.SpikeTrain

The spike train from which to generate the surrogates.

n_surrogatesint, optional

Number of surrogates to be generated. Default: 1

decimalsint or None, optional

Number of decimal points for every spike time in the surrogates. If None, machine precision is used. Default: None

Returns:
list of neo.SpikeTrain

Each surrogate spike train obtained independently from spiketrain by randomly distributing its spikes in the interval [spiketrain.t_start, spiketrain.t_stop].

Examples

>>> import quantities as pq
>>> import neo
...
>>> st = neo.SpikeTrain([100, 250, 600, 800] * pq.ms, t_stop=1 * pq.s)
>>> print(randomise_spikes(st))  
    [<SpikeTrain(array([ 131.23574603,  262.05062963,  549.84371387,
                        940.80503832]) * ms, [0.0 ms, 1000.0 ms])>]
>>> print(randomise_spikes(st, n_surrogates=2))  
    [<SpikeTrain(array([  84.53274955,  431.54011743,  733.09605806,
          852.32426583]) * ms, [0.0 ms, 1000.0 ms])>,
     <SpikeTrain(array([ 197.74596726,  528.93517359,  567.44599968,
          775.97843799]) * ms, [0.0 ms, 1000.0 ms])>]
>>> print(randomise_spikes(st, decimals=0))  
    [<SpikeTrain(array([  29.,  667.,  720.,  774.]) * ms,
          [0.0 ms, 1000.0 ms])>]