neurodsp.sim.sim_bursty_oscillation

neurodsp.sim.sim_bursty_oscillation(n_seconds, fs, freq, burst_def='prob', burst_params=None, cycle='sine', phase=0, **cycle_params)[source]

Simulate a bursty oscillation.

Parameters
n_secondsfloat

Simulation time, in seconds.

fsfloat

Sampling rate of simulated signal, in Hz.

freqfloat

Oscillation frequency, in Hz.

burst_def{‘prob’, ‘durations’} or 1d array

Which approach to take to define the bursts:

  • ‘prob’ : simulate bursts based on probabilities of entering and leaving bursts states.

  • ‘durations’ : simulate bursts based on lengths of bursts and inter-burst periods.

  • 1d array: use the given array as a definition of the bursts

burst_paramsdict

Parameters for the burst definition approach.

For the prob approach:

enter_burstfloat, optional, default: 0.2

Probability of a cycle being oscillating given the last cycle is not oscillating.

leave_burstfloat, optional, default: 0.2

Probability of a cycle not being oscillating given the last cycle is oscillating.

For the durations approach:

n_cycles_burstint

The number of cycles within each burst.

n_cycles_off

The number of non-bursting cycles, between bursts.

cycle{‘sine’, ‘asine’, ‘sawtooth’, ‘gaussian’, ‘exp’, ‘2exp’, ‘exp_cos’, ‘asym_harmonic’}

What type of oscillation cycle to simulate. See sim_cycle for details on cycle types and parameters.

phasefloat or {‘min’, ‘max’}, optional, default: 0

If non-zero, applies a phase shift to the oscillation by rotating the cycle. If a float, the shift is defined as a relative proportion of cycle, between [0, 1]. If ‘min’ or ‘max’, the cycle is shifted to start at it’s minima or maxima.

**cycle_params

Parameters for the simulated oscillation cycle.

Returns
sig1d array

Simulated bursty oscillation.

Notes

This function takes a ‘tiled’ approach to simulating cycles, with evenly spaced and consistent cycles across the whole signal, that are either oscillating or not.

If the cycle length does not fit evenly into the simulated data length, then the last few samples will be non-oscillating.

Examples

Simulate a probabilistic bursty oscillation, with a low probability of bursting:

>>> sig = sim_bursty_oscillation(n_seconds=10, fs=500, freq=5,
...                              burst_params={'enter_burst' : 0.2, 'leave_burst' : 0.8})

Simulate a probabilistic bursty sawtooth oscillation, with a high probability of bursting:

>>> sig = sim_bursty_oscillation(n_seconds=10, fs=500, freq=5, burst_def='prob',
...                              burst_params = {'enter_burst' : 0.8, 'leave_burst' : 0.4},
...                              cycle='sawtooth', width=0.3)

Simulate a bursty oscillation, with specified durations:

>>> sig = sim_bursty_oscillation(n_seconds=10, fs=500, freq=10, burst_def='durations',
...                              burst_params={'n_cycles_burst' : 3, 'n_cycles_off' : 3})

Examples using neurodsp.sim.sim_bursty_oscillation

Simulating Periodic Signals

Simulating Periodic Signals