Skip to content

ENH: add generalized eigendecomposition preprocessing#14050

Open
SaharSattari wants to merge 2 commits into
mne-tools:mainfrom
SaharSattari:add-ged
Open

ENH: add generalized eigendecomposition preprocessing#14050
SaharSattari wants to merge 2 commits into
mne-tools:mainfrom
SaharSattari:add-ged

Conversation

@SaharSattari

Copy link
Copy Markdown

This pull request adds a new mne.preprocessing.GED class implementing generalized eigendecomposition (GED) for contrast-based EEG preprocessing.

The implementation:

  • fits GED spatial filters using foreground and background covariance matrices;
  • supports regularization of the background covariance;
  • accepts both NumPy arrays and Raw objects;
  • transforms data into GED component space;
  • reconstructs Raw objects or NumPy arrays after excluding selected GED components;
  • provides component, property, and eigenvalue plotting methods;
  • exposes normalized generalized eigenvalues;
  • includes unit tests and API-reference documentation.

The implementation is based on the GED artifact-removal approach used in:

  • S. Sattari, N. Virji-Babul and L. C. Wu, "Contrast-Based Artifact Removal Enables Microstate Analysis in Ambulatory EEG," in IEEE Transactions on Biomedical Engineering, vol. 73, no. 7, pp. 2351-2361, July 2026, doi: 10.1109/TBME.2025.3630112.
  • S. Sattari, N. Virji-Babul and L. C. Wu, "Investigation of Channel Density and Real-Time Processing Effects on GED-based EEG Denoising," IEEE EMBC 2026.

I adapted the implementation from my own published research code. I used ChatGPT (GPT-5.6 Thinking) to help adapt the implementation to the MNE-Python API, assist with test development, docstrings, and the contribution workflow. I reviewed all generated code and documentation, tested the implementation locally on synthetic and MNE example data, and verified that the GED-specific tests and documentation checks pass.

@larsoner

Copy link
Copy Markdown
Member

We already have quite some GED-related code (see, e.g., #13346), have you looked? We would much rather improve/extend existing code than add 900 new, independent lines. I'd recommend a GitHub issue that outlines what we currently have, and what new or additional things could be added

@SaharSattari

Copy link
Copy Markdown
Author

We already have quite some GED-related code (see, e.g., #13346), have you looked? We would much rather improve/extend existing code than add 900 new, independent lines. I'd recommend a GitHub issue that outlines what we currently have, and what new or additional things could be added

Thank you for pointing this out. My intended use case is somewhat different. The goal was to use GED similarly to ICA as a preprocessing tool. From my initial understanding, the existing code provides the underlying eigendecomposition and spatial-filter infrastructure, but not a preprocessing workflow. I’ll review the existing implementation more carefully and open an issue outlining what is already supported, what may be missing for this preprocessing use case, and how the existing implementation could potentially be extended rather than introducing a separate implementation. Thank you for the guidance.

@larsoner

Copy link
Copy Markdown
Member

Sounds good, thanks for investigating and working on how to contribute this to MNE!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants