poisson_noise#

syncopy.synthdata.poisson_noise(nTrials=10, nSpikes=10000, nChannels=3, nUnits=10, intensity=0.1, samplerate=10000, seed=None)[source]#

Poisson (Shot-)noise generator

The expected trial length in samples is given by:

nSpikes / (intensity * nTrials)

Dividing again by the ``samplerate` gives the expected trial length in seconds.

Individual trial lengths get randomly shortened by up to 10% of this expected length.

The trigger offsets are also randomized between 5% and 20% of the shortest trial length.

Lastly, the distribution of the Poisson intensity along channels and units has uniformly randomized weights, meaning that typically you get very active channels/units and some which are almost quiet.

The parameters listed below can be provided as is or a via a cfg configuration ‘structure’, see Notes for details.

Parameters:
  • nTrials (int) – Number of trials

  • nSpikes (int) – The total number of spikes over all trials to generate

  • nChannels (int) – Number of channels

  • nUnits (int) – Number of units

  • intensity (int) – Expected number of spikes per sampling interval

  • samplerate (float) – Sampling rate in Hz

  • seed (None or int, passed on to np.random.default_rng.) – Set to an int to get reproducible results.

Returns:

sdata – The generated spike data

Return type:

SpikeData

Notes

This function can be either called providing its input arguments directly or via a cfg configuration ‘structure’. For instance, the following function calls are equivalent

>>> spy.poisson_noise(nTrials, nTrials=...)
>>> cfg = spy.StructDict()
>>> cfg.nTrials = ...
>>> spy.poisson_noise(cfg, nTrials)
>>> cfg.nTrials = nTrials
>>> spy.poisson_noise(cfg)

Please refer to Syncopy for FieldTrip Users for further details.

Originally conceived by Alejandro Tlaie Boria https://github.com/atlaie_

Examples

With nSpikes=20_000, samplerate=10_000, nTrials=10 and the default intensity=0.1 we can expect a trial length of about 2 seconds:

>>> spike_data = poisson_noise(nTrials=10, nSpikes=20_000, samplerate=10_000)

Example output of the 1st trial [start, end] in seconds:

>>> spike_data.trialintervals[0]
>>> array([-0.3004, 1.6459])

Which is close to 2 seconds.