feat(dss): native MNE covariance support for Evoked inputs#42
feat(dss): native MNE covariance support for Evoked inputs#42snesmaeili wants to merge 2 commits into
Conversation
DSS._fit_mne previously fell back to the internal NumPy covariance path for Evoked objects, because mne.compute_covariance accepts only Epochs and Raw. Add compute_evoked_covariance, which treats the averaged response's time samples as observations and returns a genuine mne.Covariance, and use it in the Evoked branch so the estimation stays within the MNE ecosystem, consistent with the Raw and Epochs branches. Closes #39
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #42 +/- ##
==========================================
- Coverage 95.93% 95.92% -0.01%
==========================================
Files 41 41
Lines 4599 4613 +14
Branches 849 851 +2
==========================================
+ Hits 4412 4425 +13
Misses 88 88
- 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:
|
Exercise the dimensionality check so the added Evoked covariance code is fully covered by the patch.
|
Thanks for implementing this sina; but I was mainly thinking whether we could make |
|
Yeah I think in principle |
|
Amazing, I will open a PR and work on it in mne; probably next week. Thanks. |
Summary
DSS._fit_mnefell back to the internal NumPy covariance path forEvokedinputs, because
mne.compute_covarianceaccepts onlyEpochsandRaw. Thisadds a small
compute_evoked_covariancehelper that treats the averagedresponse's time samples as observations and returns a genuine
mne.Covariance,then wires it into the Evoked branch of
_fit_mneso the estimation stayswithin the MNE ecosystem — consistent with the Raw and Epochs branches.
Changes
mne_denoise/dss/utils/covariance.py: newcompute_evoked_covariance. Itwraps the Evoked as a single-trial
EpochsArrayand defers tomne.compute_covariancewithkeep_sample_mean=True(so the single averageis not subtracted away). The intentional "not baseline corrected" notice is
suppressed, since DSS uses the raw second-moment covariance.
mne_denoise/dss/linear.py: the Evoked branch builds baseline/biasedcovariances through the helper instead of calling
_fit_numpy.too-few samples) plus a regression test asserting the Evoked fit reproduces
compute_dsson the MNE-side covariances.Closes #39