ezmsg.simbiophys.line_noise#
Additive mains (line) noise with slow frequency drift.
Adds a sinusoidal 50/60 Hz interference component to every channel of a signal,
emulating power-line pickup on a recording. The peak frequency wanders slowly
(a bounded random walk) to mimic drift of the recording device’s clock relative
to the mains. When freq is None the stage is a pass-through.
The drifting sinusoid is generated by phase accumulation (see
ezmsg.simbiophys.oscillator.advance_drifting_sine()) so it stays
continuous across chunks and as the frequency changes.
Classes
- class LineNoiseSettings(freq=None, amp=1.0, drift_rate=0.002, drift_bound=1.5, seed=None)[source]#
Bases:
Settings- Parameters:
- freq: float | None = None#
Mains frequency in Hz (typically 50.0 or 60.0). None disables the stage (pass-through).
- amp: float = 1.0#
Amplitude of the added sinusoid (same units as the input signal), shared across all channels.
- class LineNoiseState[source]#
Bases:
object- ang_freq: ndarray[tuple[Any, ...], dtype[float64]] | None = None#
Base angular frequency
2*pi*freq, shape (1, 1).
- phase: ndarray[tuple[Any, ...], dtype[float64]] | None = None#
Accumulated phase carried across chunks, shape (1, 1).
- class LineNoiseTransformer(*args, **kwargs)[source]#
Bases:
BaseStatefulTransformer[LineNoiseSettings,AxisArray,AxisArray,LineNoiseState]Add a slowly frequency-drifting mains sinusoid to every channel.
The same single-frequency component is added to all channels (mains pickup is a common source). Timing (sample rate) is taken from the input; the number of channels may vary. When
freqis None the input passes through unchanged.
- class LineNoiseUnit(*args, settings=None, **kwargs)[source]#
Bases:
BaseTransformerUnit[LineNoiseSettings,AxisArray,AxisArray,LineNoiseTransformer]Unit wrapper for LineNoiseTransformer.
- Parameters:
settings (Settings | None)
- SETTINGS#
alias of
LineNoiseSettings