elephant.spike_train_surrogates.dither_spikes¶
- elephant.spike_train_surrogates.dither_spikes(spiketrain: SpikeTrain, dither: Quantity, n_surrogates: int | None = 1, decimals: int | None = None, edges: bool | None = True, refractory_period: Quantity | None = None) List[SpikeTrain] [source]¶
Generates surrogates of a spike train by spike dithering.
The surrogates are obtained by uniformly dithering times around the original position. The dithering is performed independently for each surrogate.
The surrogates retain the spiketrain.t_start and spiketrain.t_stop. Spikes moved beyond this range are lost or moved to the range’s ends, depending on the parameter edges.
- Parameters:
- spiketrain
neo.core.SpikeTrain
The spike train from which to generate the surrogates.
- ditherpq.Quantity
Amount of dithering. A spike at time t is placed randomly within (t-dither, t+dither).
- 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 at a millisecond level. If None, machine precision is used. Default: None
- edgesbool, optional
For surrogate spikes falling outside the range [spiketrain.t_start, spiketrain.t_stop), whether to drop them out (for edges = True) or set them to the range’s closest end (for edges = False). Default: True
- refractory_periodpq.Quantity or None, optional
The dither range of each spike is adjusted such that the spike can not fall into the refractory_period of the previous or next spike. To account this, the refractory period is estimated as the smallest ISI of the spike train. The given argument refractory_period here is thus an initial estimation. Note, that with this option a spike cannot “jump” over the previous or next spike as it is normally possible. If set to None, no refractoriness is in dithering. Default: None
- spiketrain
- Returns:
- list of
neo.core.SpikeTrain
Each surrogate spike train obtained independently of spiketrain by randomly dithering its spikes. The range of the surrogate spike trains is the same as of spiketrain.
- list of
Examples
>>> import quantities as pq >>> import neo ... >>> st = neo.SpikeTrain([100, 250, 600, 800] * pq.ms, t_stop=1 * pq.s) # noqa >>> print(dither_spikes(st, dither = 20 * pq.ms)) [<SpikeTrain(array([ 96.53801903, 248.57047376, 601.48865767, 815.67209811]) * ms, [0.0 ms, 1000.0 ms])>] >>> print(dither_spikes(st, dither = 20 * pq.ms, n_surrogates=2)) [<SpikeTrain(array([ 104.24942044, 246.0317873 , 584.55938657, 818.84446913]) * ms, [0.0 ms, 1000.0 ms])>, <SpikeTrain(array([ 111.36693058, 235.15750163, 618.87388515, 786.1807108 ]) * ms, [0.0 ms, 1000.0 ms])>] >>> print(dither_spikes(st, dither = 20 * pq.ms, ... decimals=0)) [<SpikeTrain(array([ 81., 242., 595., 799.]) * ms, [0.0 ms, 1000.0 ms])>]