myogen.simulator.IntramuscularEMG.add_noise#
- IntramuscularEMG.add_noise(
- snr__dB: float,
- noise_type: str = 'gaussian',
- *,
- spectral_slope: float = -0.5,
- excess_kurtosis: float = 3.0,
- powerline_hz: float = 50.0,
- powerline_amplitude: float = 0.1,
- powerline_harmonic_ratios: list[float] | None = None,
- powerline_frequency_drift_hz: float = 0.3,
- powerline_amplitude_modulation_depth: float = 0.15,
- peak_hz: float = 1000.0,
- analog_hpf_hz: float = 10.0,
- baseline_drift_rms_uv: float = 0.0,
- baseline_drift_alpha: float = 1.75,
- baseline_drift_low_hz: float | None = None,
- baseline_drift_high_hz: float = 1.0,
Add noise to the electrode array.
Two noise models are available:
"gaussian"– white Gaussian noise (legacy default). Each electrode channel gets independent normal noise scaled to hit the requested per-channel SNR."realistic"– spectrally colored noise calibrated against real bipolar fine-wire iEMG recordings (TEP / Synergy studies). 1/f-like base, mid-band spectral emphasis from electrode–amplifier bandwidth, heavy tails from cross-talk artifacts, and additive 50/60 Hz powerline interference with harmonics. Seemyogen.utils.emg_noisefor the math.
Per-channel SNR is preserved across both modes: each electrode’s noise RMS is computed from that channel’s own signal RMS so electrodes with different amplitudes get appropriately scaled noise.
- Parameters:
snr__dB (float) – Signal-to-noise ratio in dB. Higher values result in cleaner signals. Typical intramuscular EMG has SNR ranging from 15–50 dB. Applied independently to each electrode channel.
noise_type ({"gaussian", "realistic"}, default="gaussian") – Noise model to use.
"realistic"activates the colored noise pipeline; the remaining keyword-only parameters then apply.spectral_slope (float, default=-0.5) – PSD slope in log–log space for the colored-noise base.
0= white,-1= pink. Real iEMG: -0.4 to -0.8. Ignored whennoise_type="gaussian".excess_kurtosis (float, default=3.0) – Target excess kurtosis (
0= Gaussian). Controlled isometric iEMG: 1–6. Dynamic tasks: higher. Ignored whennoise_type="gaussian".powerline_hz (float, default=50.0) – Powerline interference frequency. Use
60.0for North America,0.0to disable. Ignored whennoise_type="gaussian".powerline_amplitude (float, default=0.1) – Powerline fundamental amplitude as a fraction of noise RMS. Set to
0(orpowerline_hz=0) to disable. Ignored whennoise_type="gaussian".powerline_harmonic_ratios (list of float, optional) – Per-harmonic amplitude ratios relative to the fundamental.
Noneuses the default[1.0, 0.5, 0.3, 0.15, 0.08](fundamental + 4 harmonics). Ignored whennoise_type="gaussian".powerline_frequency_drift_hz (float, default=0.3) – Standard deviation (Hz) of the slow random walk of the mains instantaneous frequency. Broadens each line peak from a delta into a ~2-5 Hz FWHM bump (typical of real recordings). Set to 0 for a pure-tone powerline. Ignored when
noise_type="gaussian".powerline_amplitude_modulation_depth (float, default=0.15) – Fractional AM depth (±15% by default) applied to each powerline harmonic — adds narrow sidebands within ±2 Hz of every line. Set to 0 to disable. Ignored when
noise_type="gaussian".peak_hz (float, default=1000.0) – Center frequency of the mid-band spectral emphasis from electrode–amplifier bandwidth interaction. Ignored when
noise_type="gaussian".baseline_drift_rms_uv (float, default=0.0) – Target RMS (post-HPF) of a band-limited 1/f^α baseline drift representing electrode/interface noise (Huigen 2002, Gondran 1996). Same units as the EMG block. Set to 0 (the default) to disable, preserving legacy behaviour. The spectral form is paper-constrained; the amplitude defaults are not validated for intramuscular EMG — calibrate against real recordings via
myogen.utils.calibrate_baseline_drift_profile(). Broadband movement artifacts (0–20 Hz, De Luca 2010) are a separate phenomenon out of scope here. Ignored whennoise_type="gaussian".baseline_drift_alpha (float, default=1.75) – Drift PSD slope α (PSD ∝ 1/f^α). Midpoint of the [1.5, 2.0] electrode-noise regime. Must be > 0. Ignored when
noise_type="gaussian".baseline_drift_low_hz (float or None, default=None) – Lower edge of the drift band, in Hz.
Noneresolves to the lowest nonzero FFT bin available for the simulation length. Ignored whennoise_type="gaussian".baseline_drift_high_hz (float, default=1.0) – Upper edge of the drift band, in Hz. Default keeps the knob scoped to sub-1 Hz baseline wander. Ignored when
noise_type="gaussian".analog_hpf_hz (float)
- Returns:
Noisy intramuscular EMG signals for the electrode array as a
neo.Block. Results are also stored onnoisy_intramuscular_emg__Block.- Return type:
- Raises:
ValueError – If intramuscular EMG has not been simulated (call
simulate_intramuscular_emg()first) ornoise_typeis unrecognized.