Summary
Add adaptive / continuous DSS support to mne_denoise.dss.DSS, enabling the denoiser to handle non-stationary artifacts by processing data in segments with automatic component selection.
Motivation
Real EEG/MEG data often contains artifacts whose spatial or spectral characteristics change over time (e.g., line noise amplitude drifts, electrode impedance changes). A single global DSS fit can under- or over-remove components in different time regions. Adaptive DSS addresses this by:
- Segmenting continuous data into stationary chunks
- Fitting a separate DSS per segment
- Automatically selecting how many components to remove per segment
- Optionally smoothing data before DSS to separate slow drifts from the artifact subspace
New features
Segmentation (segmented=True)
FixedWindowSegmenter: fixed-length windows with trailing merge
CovarianceSegmenter: covariance-stationarity boundary detection (generalised from ZapLine-plus)
Auto-selection (n_select='outlier'|'ratio'|'max_gap'|'combined')
iterative_outlier_removal: iterative mean + sigma threshold (NoiseTools-style)
eigenvalue_ratio_selection: scree-test ratio method
max_gap_selection: largest eigenvalue gap method
Smoothing (smooth=int)
- Low-rank SVD smoothing decomposition: separates slow trends from residual before DSS projection
Adaptive caps/floors
max_prop_remove: cap on proportion of channels removed per segment
min_select: floor on minimum components removed
Files changed
mne_denoise/dss/linear.py – core DSS class extended with segmented mode, auto-select, smoothing
mne_denoise/dss/utils/segmentation.py – new segmenter classes
mne_denoise/dss/utils/selection.py – new selection utilities
mne_denoise/dss/variants/narrowband.py – guard against segmented=True in narrowband_scan
tests/test_linear_dss.py – 29 new adaptive DSS tests
tests/utils/test_segmentation.py – 11 segmenter tests
tests/utils/test_selection.py – 18 selection utility tests
Design note
The adaptive pathway is implemented as a single generic mechanism inside the core DSS class, so all DSS-based denoisers (ZapLine, narrowband, spectral, etc.) can leverage it via segmented=True without duplicating code.
Summary
Add adaptive / continuous DSS support to
mne_denoise.dss.DSS, enabling the denoiser to handle non-stationary artifacts by processing data in segments with automatic component selection.Motivation
Real EEG/MEG data often contains artifacts whose spatial or spectral characteristics change over time (e.g., line noise amplitude drifts, electrode impedance changes). A single global DSS fit can under- or over-remove components in different time regions. Adaptive DSS addresses this by:
New features
Segmentation (
segmented=True)FixedWindowSegmenter: fixed-length windows with trailing mergeCovarianceSegmenter: covariance-stationarity boundary detection (generalised from ZapLine-plus)Auto-selection (
n_select='outlier'|'ratio'|'max_gap'|'combined')iterative_outlier_removal: iterative mean + sigma threshold (NoiseTools-style)eigenvalue_ratio_selection: scree-test ratio methodmax_gap_selection: largest eigenvalue gap methodSmoothing (
smooth=int)Adaptive caps/floors
max_prop_remove: cap on proportion of channels removed per segmentmin_select: floor on minimum components removedFiles changed
mne_denoise/dss/linear.py– core DSS class extended with segmented mode, auto-select, smoothingmne_denoise/dss/utils/segmentation.py– new segmenter classesmne_denoise/dss/utils/selection.py– new selection utilitiesmne_denoise/dss/variants/narrowband.py– guard againstsegmented=Trueinnarrowband_scantests/test_linear_dss.py– 29 new adaptive DSS teststests/utils/test_segmentation.py– 11 segmenter teststests/utils/test_selection.py– 18 selection utility testsDesign note
The adaptive pathway is implemented as a single generic mechanism inside the core
DSSclass, so all DSS-based denoisers (ZapLine, narrowband, spectral, etc.) can leverage it viasegmented=Truewithout duplicating code.