Skip to content

ENH: read EGI MFF channelStatus into raw.info["bads"] - #14156

Open
PragnyaKhandelwal wants to merge 2 commits into
mne-tools:mainfrom
PragnyaKhandelwal:egi-mff-channel-status
Open

ENH: read EGI MFF channelStatus into raw.info["bads"]#14156
PragnyaKhandelwal wants to merge 2 commits into
mne-tools:mainfrom
PragnyaKhandelwal:egi-mff-channel-status

Conversation

@PragnyaKhandelwal

Copy link
Copy Markdown
Contributor

Reference issue (if any)

Part of #13926 (GSoC 2026 meta-issue, Phase 1).

What does this implement/fix?

EGI NetStation marks bad channels per recording epoch inside categories.xml using <channelStatus> elements with exclusion="badChannels". Previously, read_raw_egi ignored this file entirely and always returned raw.info["bads"] == [].
This PR adds a helper _read_channel_status_bads that:

  • Checks whether categories.xml exists in the MFF directory (gracefully skips if absent or unparseable)
  • Uses mffpy's Categories XML class to iterate over every category and segment
  • Collects the union of all channels marked exclusion="badChannels" across all segments (both EEG signalBin=1 and PNS signalBin=2)
  • Maps 1-indexed channel numbers to MNE channel names and populates raw.info["bads"]

A test is added that copies an existing test MFF file to a temp directory, injects a minimal categories.xml with two EEG channels marked bad, reads the file, and asserts the bads list is set correctly.

Additional information
categories.xml is absent in most of the existing test MFF files (it is only present in test_egi_evoked.mff, which is an averaged file handled by read_evokeds_mff). The new test therefore constructs a minimal categories.xml in a temp copy of the paused multi-epoch test file to exercise the raw reader path.

All 26 EGI tests pass.

When categories.xml is present in an MFF directory, collect the union of all
channels marked exclusion="badChannels" across every category segment and
populate raw.info["bads"] with their MNE channel names.
@PragnyaKhandelwal
PragnyaKhandelwal marked this pull request as ready for review August 13, 2026 20:16
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.

1 participant