feat(sound, sspsir): SOUND and SSP-SIR forward-model denoisers (#32)#46
feat(sound, sspsir): SOUND and SSP-SIR forward-model denoisers (#32)#46snesmaeili wants to merge 4 commits into
Conversation
…oses #32) Port two leadfield-based M/EEG denoisers by Tuomas Mutanen, previously MATLAB-only, requested in issue #32. - mne_denoise.sound.SOUND (Mutanen et al. 2018): automatic, robust noise suppression. Iteratively estimates each sensor's noise amplitude by predicting it from the other sensors through a forward model, then applies a Wiener filter preserving field-consistent signal. - mne_denoise.sspsir.SSPSIR (Mutanen et al. 2016): suppresses TMS-evoked muscle artifacts by projecting out the high-variance artifact subspace and reconstructing the brain signal through the forward model (source-informed reconstruction), with automatic high-frequency detection or a manual window. - mne_denoise._leadfield.make_spherical_leadfield builds a three-layer spherical lead field from the montage via MNE's forward solver when no individual forward model is supplied; both estimators also accept a custom mne.Forward. Both follow the sklearn fit/transform API and work on Raw/Epochs/Evoked or arrays. Reimplemented from the algorithms in the reference papers and the Sound-Demo-Package / TESA MATLAB sources.
Add tests fitting SOUND and SSP-SIR on plain arrays with a supplied forward, plus the channel-count mismatch and missing-positions error paths.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #46 +/- ##
==========================================
+ Coverage 95.93% 96.06% +0.13%
==========================================
Files 41 46 +5
Lines 4599 4803 +204
Branches 849 872 +23
==========================================
+ Hits 4412 4614 +202
- Misses 88 89 +1
- Partials 99 100 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…d outputs compute_sound and compute_sspsir_operator were verified against the original Mutanen MATLAB (SOUND.m, tesa_sspsir) to machine precision via Octave; Octave is not in CI, so these regression tests lock the validated numerics in.
Reference parity (machine precision), SOUND noise-estimation correlation (0.98) and SSP-SIR topography recovery (CC 0.95 / RE 32%, robust across M) reproducing Mutanen et al. 2016/2018.
Validation against the original papers + reference MATLABI validated the 1. Reference parity (correctness proof)Identical inputs fed to the Python code and to the original MATLAB (
A golden-value regression test ( 2. Simulation reproduction
Caveat: the papers' real-data panels use private TMS-EEG/MEG recordings (HeadIT is defunct), so those exact figures can't be reproduced on identical data — the ground-truth simulations + the machine-precision parity are the rigorous substitute. |


Closes #32.
Adds Python ports of two leadfield-based M/EEG denoisers by Tuomas Mutanen,
previously available only in MATLAB (EEGLAB TESA / the Sound-Demo-Package), as
requested by @matteo-d-m. Both are sklearn-style
fit/transformestimatorsthat work on MNE
Raw/Epochs/Evokedobjects or plain arrays.What's included
mne_denoise.sound.SOUND(Mutanen et al., 2018) — automatic, robust noisesuppression for EEG/MEG. SOUND iteratively estimates every sensor's noise
amplitude by predicting it from all the other sensors through a forward model
(a leave-one-channel-out minimum-norm estimate), then applies a Wiener filter
that suppresses channel-specific noise while preserving field-consistent brain
signal.
mne_denoise.sspsir.SSPSIR(Mutanen et al., 2016) — suppression ofTMS-evoked muscle artifacts. It projects out the high-variance muscle-artifact
subspace (SSP) and reconstructs the brain signal lost to that projection
through the forward model (source-informed reconstruction). Supports automatic
high-frequency artifact detection or a user-specified
art_window, and aninteger PC count or a variance fraction. This is conceptually SSP followed by
the same reconstruction MNE exposes as
proj=\"reconstruct\".mne_denoise._leadfield.make_spherical_leadfield— builds a three-layerspherical lead field from the montage via MNE's forward solver
(
make_sphere_model→setup_volume_source_space→make_forward_solution)when no individual forward model is supplied. Both estimators also accept a
custom
mne.Forward.Implementation notes
MATLAB (
Sound-Demo-Package,tesa_sound.m,tesa_sspsir.m) — not copied —so the result is original BSD code. SOUND's cleaning operator is expressed in
the efficient
L Lᵀform (no per-channel source-space products), which isnumerically equivalent to the reference loop.
0.33 / 0.0066 / 0.33 S/m); for best results an individual
mne.Forwardshouldbe supplied.
Tests
tests/test_leadfield.py,tests/test_sound.py,tests/test_sspsir.py—synthetic property tests (no MATLAB ground truth needed): the lead field spans
the sensor space and is average-referenced; SOUND flags and suppresses a
corrupted channel while preserving the others and converges; SSP-SIR removes an
injected muscle-like artifact (~variance drop) while preserving a dipolar brain
source (corr > 0.95); plus the array/forward paths and error cases. Full suite
green locally (545 passed, 11 skipped — the skips are the MATLAB parity tests).
Follow-up
SSP-SIR application mode can come in a follow-up; this PR ships the uniform
operator, which is the cleanest and most predictable.