mne_rt.tools.simulate_nf_session#
- mne_rt.tools.simulate_nf_session(duration: float = 120.0, sfreq: float = 256.0, n_channels: int = 64, alpha_frange: tuple = (8.0, 13.0), alpha_amplitude: float = 1.5e-05, background_amplitude: float = 5e-06, n_blinks: int = 15, blink_amplitude: float = 0.00015, muscle_rate: float = 0.05, muscle_amplitude: float = 3e-05, drift_amplitude: float = 2e-05, alpha_reactivity: bool = True, nf_epoch_fraction: float = 0.5, rng_seed: int | None = None, verbose: bool | str | None = None) tuple[source]#
Generate a realistic multi-artifact EEG simulation for NF testing.
Produces synthetic EEG with:
1/f background noise (pink noise) on all channels
Alpha-band oscillations with realistic spatial topography (occipital channels have strongest alpha)
Alpha reactivity: alpha power is reduced during simulated NF “active” epochs (mimics ERD during cognitive effort)
Eye-blink artefacts at realistic rate (≈15/min) with frontal topography
Muscle noise bursts as short high-frequency transients
Slow electrode drift (low-frequency random walk)
- Parameters:
- duration
float, default 120.0 Total recording duration in seconds.
- sfreq
float, default 256.0 Sampling rate in Hz.
- n_channels
int, default 64 Number of EEG channels (must be 32, 64, 128, or 256 for standard biosemi/easycap montages).
- alpha_frange
tuple, default (8.0, 13.0) Alpha-band frequency range (Hz).
- alpha_amplitude
float, default 15e-6 Peak alpha oscillation amplitude at occipital electrodes (V).
- background_amplitude
float, default 5e-6 Broadband 1/f noise amplitude (V).
- n_blinks
int, default 15 Number of blink artefacts to inject.
- blink_amplitude
float, default 150e-6 Peak blink amplitude (V) at Fp1/Fp2.
- muscle_rate
float, default 0.05 Fraction of windows contaminated with muscle bursts (0–1).
- muscle_amplitude
float, default 30e-6 Peak muscle burst amplitude (V).
- drift_amplitude
float, default 20e-6 Peak slow-drift amplitude (V).
- alpha_reactivitybool, default
True If True, alpha power is reduced by ~50% during NF epochs.
- nf_epoch_fraction
float, default 0.5 Fraction of total duration where NF-state (reduced alpha) applies.
- rng_seed
int|None, defaultNone Random seed for reproducibility.
- verbosebool |
str|None, defaultNone MNE verbosity.
- duration
- Returns:
- raw
mne.io.RawArray Simulated raw EEG.
- nf_state
ndarray,shape(n_samples,) Boolean mask: True where simulated NF-state (reduced alpha) is active.
- raw
Notes
The function uses a standard biosemi64 montage channel layout. Channels are sorted into occipital (O1, Oz, O2, POz, PO3, PO4, PO7, PO8), frontal (Fp1, Fp2, AF7, AF8), and remaining groups to assign spatially realistic source weights.
References
Niedermeyer, E., & da Silva, F. L. (2005). Electroencephalography: Basic Principles, Clinical Applications, and Related Fields. LWW.
Pfurtscheller, G., & Aranibar, A. (1977). Event-related cortical desynchronisation detected by power measurements of scalp EEG. Electroencephalography and clinical Neurophysiology, 42(6), 817–826.