MAINT: Replace internal EEG sample-reading helper with mffpy#13973
Open
PragnyaKhandelwal wants to merge 5 commits into
Open
MAINT: Replace internal EEG sample-reading helper with mffpy#13973PragnyaKhandelwal wants to merge 5 commits into
PragnyaKhandelwal wants to merge 5 commits into
Conversation
Replaces the manual binary block-reading loop in `_read_segment_file` with `mffpy.Reader.get_physical_samples_from_epoch`, adding two helpers: `_get_mff_reader` (opens reader with GCAL disabled to avoid double-scaling against MNE's existing `cals` pipeline) and `_disk_range_to_epochs` (maps a contiguous on-disk sample range across acquisition-skip gaps to per-epoch mffpy `(t0, dt)` windows). PNS reading is unchanged.
11 tasks
PragnyaKhandelwal
added a commit
to PragnyaKhandelwal/mne-python
that referenced
this pull request
Jun 22, 2026
09b8d79 to
6987380
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference issue (if any)
Part ofTowards #13926.Builds on #13932 (merged —
mffpyfor event reading) and #13945 (open —mffpyfor metadata reading). This is the third micro-PR in the series.
What does this implement/fix?
Replaces the internal binary-block EEG sample reader in
RawMff._read_segment_filewithmffpy.Reader.get_physical_samples_from_epoch().Two helpers are added:
_get_mff_reader(mff_path)— opens anmffpy.Readerwith its default EEGcalibration (
GCAL) disabled. MNE'scalsvector already incorporates thatgain (set in
_get_eeg_calibration_info), so leaving it enabled woulddouble-scale every EEG sample.
_disk_range_to_epochs(egi_info, disk_start, disk_stop)— translates acontiguous range of on-disk sample indices (how
BaseRawaddresses data) intoper-epoch
(t0, dt)windows (howmffpyaddresses data). EGI MFF storessignal blocks back-to-back on disk; recording-pause gaps only appear in the
logical sample timeline exposed to users.
The ~50-line manual
fid.seek/np.fromfile/ block-header parsing loop(
_block_r) is removed and replaced with a short loop overget_physical_samples_from_epoch(), consistent with how PNS reading alreadyworks downstream.
mff_pathis stored inegi_infoatRawMff.__init__time so the reader canbe instantiated on demand inside
_read_segment_file.Additional information
All existing tests in
mne/io/egi/tests/test_egi.pypass locally, includingmulti-epoch, paused-recording, PNS, crop, and preload variants. No new test
fixtures are needed — the existing
.mfffiles already exercise multi-blockreads and epoch boundaries.