Skip to content

MAINT: Remove _get_eeg_calibration_info and delegate GCAL scaling to mffpy#14011

Merged
scott-huberty merged 7 commits into
mne-tools:mainfrom
PragnyaKhandelwal:egi-mff-cal-cleanup
Jul 2, 2026
Merged

MAINT: Remove _get_eeg_calibration_info and delegate GCAL scaling to mffpy#14011
scott-huberty merged 7 commits into
mne-tools:mainfrom
PragnyaKhandelwal:egi-mff-cal-cleanup

Conversation

@PragnyaKhandelwal

Copy link
Copy Markdown
Contributor

Reference issue (if any)

Part of #13926 (Phase 1 — legacy helper cleanup).
Follows #14007.

What does this implement/fix?

Removes _get_eeg_calibration_info from egimff.py and lets mffpy apply per-channel GCAL scaling natively instead.
Previously, _get_mff_reader disabled mffpy's built-in GCAL calibration (set_calibration("EEG", None)) because _get_eeg_calibration_info was already baking GCAL into MNE's cals array. This split the calibration responsibility across two places. Now mffpy handles GCAL directly (as it does by default), and MNE's cals for EEG channels are simplified to a flat unit conversion (1e-6 for µV channels, 1 for V channels).
As a result, _get_gains in general.py loses its only caller and is removed entirely.

Additional information

The value_range/bits branch inside _get_eeg_calibration_info was dead code — both fields are hardcoded to 0 in _read_header and never updated.

@PragnyaKhandelwal PragnyaKhandelwal marked this pull request as ready for review July 1, 2026 09:28
@PragnyaKhandelwal

Copy link
Copy Markdown
Contributor Author

test failure seems unrelated....

@scott-huberty scott-huberty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

Comment thread mne/io/egi/egimff.py Outdated
logger.info(" Reading events ...")
egi_events, egi_info, mff_events = _read_events(input_fname, egi_info)
cals = _get_eeg_calibration_info(input_fname, egi_info)
_cal_scales = {"uV": 1e-6, "V": 1}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total nitpick but.. This variable is defined in two places (_read_evoked_mff, RawMff). You could move it to the module level as a constant. Unfortunately frozendict was not introduced until Python 3.15, so you can just keep it as a regular, mutable dict 🙂

@scott-huberty

Copy link
Copy Markdown
Contributor

test failure seems unrelated....

The CircleCI jobs failed because the pre-commit bot made a commit after you, and the CIrcleCI jobs won't run on commits from that bot.

Comment thread mne/io/egi/egimff.py Outdated
)

REFERENCE_NAMES = ("VREF", "Vertex Reference")
_cal_scales = {"uV": 1e-6, "V": 1}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_cal_scales = {"uV": 1e-6, "V": 1}
CAL_SCALES = {"uV": 1e-6, "V": 1}

As mentioned on our call today, there is a convention to make constants upper-case, as a hint to other developers that this variable should not be mutated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @scott-huberty!

@scott-huberty scott-huberty enabled auto-merge (squash) July 2, 2026 19:07
@scott-huberty scott-huberty merged commit 1a442f0 into mne-tools:main Jul 2, 2026
32 checks passed
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