ENH: read EGI MFF channelStatus into raw.info["bads"] - #14156
Open
PragnyaKhandelwal wants to merge 8 commits into
Open
ENH: read EGI MFF channelStatus into raw.info["bads"]#14156PragnyaKhandelwal wants to merge 8 commits into
channelStatus into raw.info["bads"]#14156PragnyaKhandelwal wants to merge 8 commits into
Conversation
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
marked this pull request as ready for review
August 13, 2026 20:16
PragnyaKhandelwal
requested review from
agramfort,
drammock and
larsoner
as code owners
August 13, 2026 20:16
19 tasks
…, goodChannels, unknown signalBin, PNS, and corrupted XML cases
Comment on lines
+80
to
+81
| cats_path = op.join(filepath, "categories.xml") | ||
| if not op.isfile(cats_path): |
Contributor
There was a problem hiding this comment.
@PragnyaKhandelwal can you please remove the str call on _check_fname on Line 498, and then swap out op for Path methods? in modern MNE we try to use pathlib for file handling. If there are other uses of op on file strings in this module, you can swap those out too.
Suggested change
| cats_path = op.join(filepath, "categories.xml") | |
| if not op.isfile(cats_path): | |
| cats_path = filepath / "categories.xml" | |
| if not cats_path.isfile(): |
…move str() from _check_fname
…rop os.path import
| info_filepath = op.join(filepath, "info.xml") | ||
| info_obj = XML.from_file(info_filepath) | ||
| info_filepath = Path(filepath) / "info.xml" | ||
| info_obj = XML.from_file(str(info_filepath)) |
Contributor
There was a problem hiding this comment.
Suggested change
| info_obj = XML.from_file(str(info_filepath)) | |
| info_obj = XML.from_file(info_filepath) # ty: ignore[invalid-argument-type] |
@larsoner is this the way you like to silence ty errors in MNE? In this case we'd have to use this comment 3 times in this module, but seems safer than suppressing this error at the module level.
Contributor
There was a problem hiding this comment.
mffpy's type annotation says from_file takes a string as input, but looks like it handles Path objects just fine.
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 of #13926 (GSoC 2026 meta-issue, Phase 1).
What does this implement/fix?
EGI NetStation marks bad channels per recording epoch inside
categories.xmlusing<channelStatus>elements withexclusion="badChannels". Previously,read_raw_egiignored this file entirely and always returnedraw.info["bads"] == [].This PR adds a helper
_read_channel_status_badsthat:categories.xmlexists in the MFF directory (gracefully skips if absent or unparseable)CategoriesXML class to iterate over every category and segmentexclusion="badChannels"across all segments (both EEGsignalBin=1and PNSsignalBin=2)raw.info["bads"]A test is added that copies an existing test MFF file to a temp directory, injects a minimal
categories.xmlwith two EEG channels marked bad, reads the file, and asserts the bads list is set correctly.Additional information
categories.xmlis absent in most of the existing test MFF files (it is only present intest_egi_evoked.mff, which is an averaged file handled byread_evokeds_mff). The new test therefore constructs a minimalcategories.xmlin a temp copy of the paused multi-epoch test file to exercise the raw reader path.All 26 EGI tests pass.