pyntbci.eeg.generate_line_noise
- pyntbci.eeg.generate_line_noise(n_trials: int, n_channels: int, n_samples: int, fs: int, freq: float = 50.0, amplitude: float = 1.0, n_harmonics: int = 1, channel_jitter: float = 0.1, random_state: int | Generator = None, dtype: str | dtype = 'float32') NDArray[source]
Generate electrical line noise (e.g., 50 Hz mains interference and its harmonics), shared (with only small gain variations) across channels, with a random phase per trial.
- Parameters:
n_trials (int) – The number of trials to generate.
n_channels (int) – The number of channels to generate.
n_samples (int) – The number of samples per trial.
fs (int) – The sampling frequency in Hz.
freq (float (default: 50.0)) – The line noise frequency in Hz (50 Hz in Europe, 60 Hz in the Americas).
amplitude (float (default: 1.0)) – The amplitude of the fundamental frequency component. Each harmonic h is scaled by amplitude / h.
n_harmonics (int (default: 1)) – The number of harmonics to include (1 means only the fundamental frequency).
channel_jitter (float (default: 0.1)) – The relative per-channel random gain variability, as a fraction of the amplitude.
random_state (int | np.random.Generator (default: None)) – A seed or numpy random number generator to draw the phase and channel gains from. If None, a new one is used.
dtype (str | np.dtype (default: "float32")) – The dtype of the returned array. Computation is always done in float64 internally; this only controls the precision of the final result.
- Returns:
noise – The line noise of shape (n_trials, n_channels, n_samples).
- Return type:
NDArray