neurodsp.sim.cycles.sim_cycle¶
- neurodsp.sim.cycles.sim_cycle(n_seconds, fs, cycle_type, phase=0, **cycle_params)[source]¶
Simulate a single cycle of a periodic pattern.
- Parameters
- n_secondsfloat
Length of cycle window in seconds. This is NOT the period of the cycle, but the length of the returned array of the cycle.
- fsfloat
Sampling frequency of the cycle simulation.
- cycle_typestr or callable
What type of cycle to simulate. String label options include:
sine: a sine wave cycle
asine: an asymmetric sine cycle
sawtooth: a sawtooth cycle
gaussian: a gaussian cycle
skewed_gaussian: a skewed gaussian cycle
exp: a cycle with exponential decay
2exp: a cycle with exponential rise and decay
exp_cos: an exponential cosine cycle
asym_harmonic: an asymmetric cycle made as a sum of harmonics
ap: an action potential
- phasefloat or {‘min’, ‘max’}, optional, default: 0
If non-zero, applies a phase shift 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
Keyword arguments for parameters of the cycle, all as float:
sine: None
asine: rdsym, rise-decay symmetry, from 0-1
sawtooth: width, width of the rising ramp as a proportion of the total cycle
gaussian: std, standard deviation of the gaussian kernel, in seconds
skewed_gaussian: center, std, alpha, height
exp: tau_d, decay time, in seconds
2exp: tau_r & tau_d rise time, and decay time, in seconds
exp_cos: exp, scale, shift
asym_harmonic: phi, the phase at each harmonic and n_harmonics
ap: centers, stds, alphas, heights
- Returns
- cycle1d array
Simulated cycle.
Notes
Any function defined in sim.cycles as sim_label_cycle(n_seconds, fs, **params), is accessible by this function. The cycle_type input must match the label.
Examples
Simulate a half second sinusoid, corresponding to a 2 Hz cycle (frequency=1/n_seconds):
>>> cycle = sim_cycle(n_seconds=0.5, fs=500, cycle_type='sine')
Simulate a sawtooth cycle, corresponding to a 10 Hz cycle:
>>> cycle = sim_cycle(n_seconds=0.1, fs=500, cycle_type='sawtooth', width=0.3)