Repository navigation
Closed
Description
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
- Purge existing internal helper functions from tests
- Make sure all tests pass on all platforms
- Replace internal event-reading helper with calls to mffpy — MRG: Use
mffpyfor EGI MFF event reading #13932 - Replace internal metadata-reading helper with calls to mffpy — MAINT: Use mffpy for EGI metadata reading and add PNS shim #13945
- Replace internal data-sample-reading helper with calls to mffpy — MAINT: Replace internal EEG sample-reading helper with mffpy #13973
- Migrate
_get_ep_infoand_get_signalfnamein general.py to mffpy-backed parsing — MAINT: Replacedefusedxmlwithmffpyin_get_ep_infoand_get_signalfname#13991 - Migrate
_get_gainsto mffpy, remove_extract, and drop defusedxml entirely — MAINT: Replacedefusedxmlwithmffpyin_get_gainsand remove_extract#14007 - Migrate EEG calibration to mffpy-native scaling and remove
_get_eeg_calibration_info— MAINT: Remove_get_eeg_calibration_infoand delegate GCAL scaling tomffpy#14011 - Read bad channels from
categories.xmlchannelStatus intoraw.info["bads"]— ENH: read EGI MFFchannelStatusinto raw.info["bads"] #14156
Phase 2: PNS Migration & Final Legacy Removal
- Replace PNS binary block reader in
_read_segment_filewith mffpy-backed reading viaget_physical_samples_from_epoch— MAINT: Replace manual PNS binary block reader in_read_segment_filewithmffpy#14030 - Replace
_get_blocksusage in_read_mff_headerfor EEG header metadata (sfreq, n_channels, samples_block) with mffpy reader APIs — ENH: replace_get_blocksbinary reader with mffpy Reader API #14043 - Remove
_get_blocksand_block_rfrom general.py once PNS reading and EEG header metadata are fully migrated — ENH: replace_get_blocksbinary reader with mffpy Reader API #14043 - Clean up dead header fields (gain, bits, value_range) from
_read_header— MAINT: remove dead gain/bits/value_range fields from _read_header in … #14047 - Add
cel#→ integer condition mapping for event codes — ENH: Addevent_keyparameter toread_raw_egifor MFF event metadata #14086
Phase 3: Extended Validation & Edge-Case Benchmarking
- Conduct side-by-side parity testing against legacy reader
Phase 4: Read Optimization and Memory Management
- Profile new reader to identify main bottleneck —
_mult_cal_one→np.take(one, idx, axis=0)= 7.97s / 60.6% of total read time - Fix
_read_segment_fileto preserve original idx as slice when calling_mult_cal_one— PERF: preserve idx slice in EGI MFF _read_segment_file to avoid np.take on large buffers #14137 - Profile and optimize preload=False path
Phase 5: Documentation, gallery examples, and final polish
- Extend
examples/io/read_impedances.pyto add an EGI section demonstrating reading GCAL/ICAL calibration data via mffpy and visualizing withplot_topomap— ENH: add EGI ICAL/GCAL calibration section toread_impedancesgallery example #14143
Reacted by Scott Huberty
Metadata
Metadata
Assignees
Labels
No labels
Activity
drammock commentedon May 27, 2026
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:
PragnyaKhandelwal commentedon May 28, 2026
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.
drammock commentedon May 28, 2026
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
scott-huberty commentedon May 28, 2026
@PragnyaKhandelwal and I met today, we reviewed the
mne.io.egi.testsmodule. 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 usemffpyto read EGI events. if the existing test suite fails, we will investigate the failures together.scott-huberty commentedon May 28, 2026
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?
PragnyaKhandelwal commentedon May 29, 2026
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!
PragnyaKhandelwal commentedon Jun 22, 2026
Should I check the boxes for event-reading and metadata part of phase 1 @scott-huberty?
scott-huberty commentedon Jul 2, 2026
@PragnyaKhandelwal for extra credit it it might be worth extending this tutorial to demonstrate reading calibration data with
mffpyand visualizing it using MNE topoplotfunctions: https://mne.tools/stable/auto_examples/io/read_impedances.htmlPragnyaKhandelwal commentedon Jul 7, 2026
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.
PragnyaKhandelwal commentedon Aug 1, 2026
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_samplesapplies 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.
PragnyaKhandelwal commentedon Aug 18, 2026
Here's the LOC comparison between v1.12.1 and the current main (excluding blank lines, comments, and docstrings):
mne/io/egi/__init__.pymne/io/egi/egi.pymne/io/egi/egimff.pymne/io/egi/events.pymne/io/egi/general.pymne/io/egi/tests/__init__.pymne/io/egi/tests/test_egi.pyOverall: 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%).
scott-huberty commentedon Aug 18, 2026
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 !