Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

FIX: Missing coordinates.xml in MFF file #13148

Merged
merged 3 commits into from
Mar 7, 2025

Conversation

scott-huberty
Copy link
Contributor

The EGI MFF reader already tries to account for the case where a sensor coordinate file (coordinates.xml) is missing:

def _read_locs(filepath, egi_info, channel_naming):
"""Read channel locations."""
_soft_import("defusedxml", "reading EGI MFF data")
from defusedxml.minidom import parse
fname = op.join(filepath, "coordinates.xml")
if not op.exists(fname):
logger.warn("File coordinates.xml not found, not setting channel locations")
ch_names = [channel_naming % (i + 1) for i in range(egi_info["n_channels"])]
return ch_names, None

So if this variable mon can be None, then all the code dealing with it should be nested inside the if-block below:

ch_names, mon = _read_locs(input_fname, egi_info, channel_naming)

if mon is not None:
info.set_montage(mon, on_missing="ignore")
ref_idx = np.flatnonzero(np.isin(mon.ch_names, REFERENCE_NAMES))

I also updated a test to simulate this case.

Copy link
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

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

Looks good, marking for merge-when-green, thanks @scott-huberty !

@larsoner larsoner enabled auto-merge (squash) March 7, 2025 17:37
@larsoner larsoner merged commit 7c531e4 into mne-tools:main Mar 7, 2025
31 of 32 checks passed
@scott-huberty scott-huberty deleted the egimff_fix branch March 7, 2025 18:38
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants