neurodsp.sim.utils.modulate_signal¶
- neurodsp.sim.utils.modulate_signal(sig, modulation, fs=None, mod_params=None)[source]¶
Apply amplitude modulation to a signal.
- Parameters
- sig1d array
A signal to modulate.
- modulation1d array or str
Modulation to apply to the signal. If array, the modulating signal to apply directly to the signal. If str, a function name to use to simulate the modulating signal that will be applied.
- fsfloat, optional
Signal sampling rate, in Hz. Only needed if modulation is a callable.
- mod_paramsdictionary, optional
Parameters for the modulation function. Only needed if modulation is a callable.
- Returns
- msig1d array
Amplitude modulated signal.
Examples
Amplitude modulate a sinusoidal signal with a lower frequency, passing in a function label:
>>> from neurodsp.sim import sim_oscillation >>> fs = 500 >>> sig = sim_oscillation(n_seconds=10, fs=fs, freq=10) >>> msig = modulate_signal(sig, 'sim_oscillation', fs, {'freq' : 1})
Amplitude modulate a sinusoidal signal with precomputed 1/f signal:
>>> from neurodsp.sim import sim_oscillation, sim_powerlaw >>> n_seconds = 10 >>> fs = 500 >>> sig = sim_oscillation(n_seconds, fs, freq=10) >>> mod = sim_powerlaw(n_seconds, fs, exponent=-1) >>> msig = modulate_signal(sig, mod)
Examples using neurodsp.sim.utils.modulate_signal
¶
Modulating Signals