Skip to content

GSoC 2026: Use mffpy for EGI Reader #13926

Closed

Description

@PragnyaKhandelwal

This is the meta-issue to track the milestones for my GSoC 2026 project replacing the internal EGI reader with the mffpy backend.

Phase 1: Core Refactor & CI Hardening

Phase 2: PNS Migration & Final Legacy Removal

Phase 3: Extended Validation & Edge-Case Benchmarking

  • Conduct side-by-side parity testing against legacy reader

Phase 4: Read Optimization and Memory Management

Phase 5: Documentation, gallery examples, and final polish

Activity

  1. drammock commented on May 27, 2026

    @drammock
    Member

    given my feedback in #13914 (about making each PR smaller / less ambitious) I think it makes sense to have this checklist be more fine-grained. For example, something like:

    - [ ] purge existing internal helper functions from tests
    - [ ] make sure all tests pass on all platforms
    - [ ] replace internal event-reading helper with calls to mffpy
    - [ ] replace internal metadata-reading helper with calls to mffpy
    - [ ] replace internal data-sample-reading helper with calls to mffpy
    - [ ] add support for PNS reading
    - [ ] etc etc
    
  2. PragnyaKhandelwal commented on May 28, 2026

    @PragnyaKhandelwal
    ContributorAuthor

    given my feedback in #13914 (about making each PR smaller / less ambitious) I think it makes sense to have this checklist be more fine-grained. For example, something like:

    Thanks @drammock, that makes perfect sense! I have updated the checklist above to be much more granular for Phase 1 as you suggested. As I move on to the later phases over the summer, I will make sure to expand those into smaller, granular checkboxes as well.

  3. drammock commented on May 28, 2026

    @drammock
    Member

    I have updated the checklist above to be much more granular for Phase 1 as you suggested

    Great, thanks. Just to be clear: I haven't immersed myself in the MFF code recently, so the checklist I suggested is just a guess. You (and @scott-huberty) should adjust that list based on your knowledge of what the code does and how much work each step will be

  4. scott-huberty commented on May 28, 2026

    @scott-huberty
    Contributor

    I have updated the checklist above to be much more granular for Phase 1 as you suggested

    Great, thanks. Just to be clear: I haven't immersed myself in the MFF code recently, so the checklist I suggested is just a guess. You (and @scott-huberty) should adjust that list based on your knowledge of what the code does and how much work each step will be

    @PragnyaKhandelwal and I met today, we reviewed the mne.io.egi.tests module. It doesn't look like the test suite relies on any internal functions or attributes, there are no xfail/skipif marks, and the test suite passes on main. So we agreed that this week @PragnyaKhandelwal can work on a micro-PR to use mffpy to read EGI events. if the existing test suite fails, we will investigate the failures together.

  5. scott-huberty commented on May 28, 2026

    @scott-huberty
    Contributor

    Phase 3: Validation and parity testing against legacy reader

    • Conduct side-by-side parity testing against legacy reader

    Since we have an existing EGI test suite, I think this "parity testing" happens with every PR, as opposed to being its own dedicated step. Unless by "validation and parity testing", you are suggesting to carry out a more comprehensive parity benchmark (e.g. using a publicly available dataset) that goes above and beyond our test suite?

  6. PragnyaKhandelwal commented on May 29, 2026

    @PragnyaKhandelwal
    ContributorAuthor

    Since we have an existing EGI test suite, I think this "parity testing" happens with every PR, as opposed to being its own dedicated step. Unless by "validation and parity testing", you are suggesting to carry out a more comprehensive parity benchmark (e.g. using a publicly available dataset) that goes above and beyond our test suite?

    You are exactly right, @scott-huberty! The standard parity checks are covered by the CI on every micro-PR via mne.datasets.testing.
    Phase 3 is meant for exactly what you suggested: a much more comprehensive parity benchmark using real, publicly available datasets that go beyond the lightweight test suite. To avoid any confusion, I will rename Phase 3 to 'Extended Validation & Edge-Case Benchmarking'.
    Let me know if that sounds like a good plan!

  7. PragnyaKhandelwal commented on Jun 22, 2026

    @PragnyaKhandelwal
    ContributorAuthor

    Should I check the boxes for event-reading and metadata part of phase 1 @scott-huberty?

  8. scott-huberty commented on Jul 2, 2026

    @scott-huberty
    Contributor

    @PragnyaKhandelwal for extra credit it it might be worth extending this tutorial to demonstrate reading calibration data with mffpy and visualizing it using MNE topoplotfunctions: https://mne.tools/stable/auto_examples/io/read_impedances.html

  9. PragnyaKhandelwal commented on Jul 7, 2026

    @PragnyaKhandelwal
    ContributorAuthor

    @PragnyaKhandelwal for extra credit it it might be worth extending this tutorial to demonstrate reading calibration data with mffpy and visualizing it using MNE topoplotfunctions: https://mne.tools/stable/auto_examples/io/read_impedances.html

    Thanks @scott-huberty! That's a great idea — I've added it as a checkbox in Phase 5 of the meta-issue. I'll work on it after Phase 2 finishes.

  10. PragnyaKhandelwal commented on Aug 1, 2026

    @PragnyaKhandelwal
    ContributorAuthor

    Phase 3 parity testing complete.

    Ran side-by-side comparison of the new mffpy-backed reader against the legacy reader on a real 128-channel MFF dataset (~42 min recording, 1.37 GB preloaded). Max relative error across all EEG channels: 9.35e-08 — below float32 machine epsilon (1.19e-07), so the outputs are numerically equivalent within the precision of the hardware format.

    The drift has two independent sources: (1) mffpy parses GCAL values internally through float32, giving slightly different precision than the old reader's direct float64 XML parse; (2) mffpy's get_physical_samples applies an .astype(float32) roundtrip. Both are inherent to mffpy's design and too small to affect any downstream analysis. No fix needed.

    Benchmark results pushed to the mne-egi-benchmark repo.

  11. PragnyaKhandelwal commented on Aug 18, 2026

    @PragnyaKhandelwal
    ContributorAuthor

    Here's the LOC comparison between v1.12.1 and the current main (excluding blank lines, comments, and docstrings):

    File v1.12.1 current diff
    mne/io/egi/__init__.py 2 2 0
    mne/io/egi/egi.py 237 241 +4
    mne/io/egi/egimff.py 723 703 -20
    mne/io/egi/events.py 153 134 -19
    mne/io/egi/general.py 153 43 -110
    mne/io/egi/tests/__init__.py 0 0 0
    mne/io/egi/tests/test_egi.py 503 574 +71
    TOTAL 1771 1697 -74

    Overall: 74 fewer lines (4.2% reduction). Most of the gain is in general.py (-110), which held the old hand-written binary parser — now replaced by mffpy calls. The test file grew by +71 lines due to added test coverage, so excluding tests the production code alone shrank by 145 lines (11.4%).

  12. scott-huberty commented on Aug 18, 2026

    @scott-huberty
    Contributor

    Not too bad, and the heavy lifting has been delegated to the format experts at mffpy. I think it's a maintenance win. Great job @PragnyaKhandelwal !

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions