neurodsp.sim.sim_variable_oscillation¶
- neurodsp.sim.sim_variable_oscillation(n_seconds, fs, freqs, cycle='sine', phase=0, **cycle_params)[source]¶
Simulate an oscillation that varies in frequency and cycle parameters.
- Parameters
- n_secondsfloat or None
Simulation time, in seconds. If None, the simulation time is based on freqs and the length of cycle_params. If a float, the signal may be truncated or contain trailing zeros if not exact.
- fsfloat
Signal sampling rate, in Hz.
- freqsfloat or list
Oscillation frequencies.
- cycle{‘sine’, ‘asine’, ‘sawtooth’, ‘gaussian’, ‘exp’, ‘2exp’} or callable
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
Parameter floats or variable lists for each cycle.
- Returns
- sig1d array
Simulated bursty oscillation.
Examples
Simulate one second of an oscillation with a varying center frequency:
>>> freqs = np.tile([10, 11, 10, 9], 5) >>> sig = sim_variable_oscillation(1, 1000, freqs)
Simulate an oscillation with varying frequency and parameters for a given number of cycles:
>>> freqs = [ 5, 10, 15, 20] >>> rdsyms = [.2, .4, .6, .8] >>> sig = sim_variable_oscillation(None, 1000, freqs, cycle='asine', rdsym=rdsyms)