Skip to content

feat: Adaptive DSS with segmentation, auto-selection, and smoothing #27

@snesmaeili

Description

@snesmaeili

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:

  1. Segmenting continuous data into stationary chunks
  2. Fitting a separate DSS per segment
  3. Automatically selecting how many components to remove per segment
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions