Repository navigation
Open
Labels
Description
Description of the problem
I have a recording MEG + 10 EEG where a .set_montage("standard_1020") fails with:
Traceback (most recent call last):
Cell In[3], line 1
epochs.set_montage("standard_1020")
File <decorator-gen-25>:12 in set_montage
File ~/git/mscheltienne/mne-python/mne/_fiff/meas_info.py:419 in set_montage
_set_montage(info, montage, match_case, match_alias, on_missing)
File ~/git/mscheltienne/mne-python/mne/channels/montage.py:1311 in _set_montage
"coord_frame": info["dig"].pop()["coord_frame"],
IndexError: pop from empty list
It looks like it's due to custom_eeg_ref_dig being set to True here:
mne-python/mne/channels/montage.py
Lines 1176 to 1189 in 7a91c47
| # keep reference location from EEG-like channels if they | |
| # already exist and are all the same. | |
| # Note: ref position is an empty list for fieldtrip data | |
| if len(ref_pos) and ref_pos[0].any() and (ref_pos[0] == ref_pos).all(): | |
| eeg_ref_pos = ref_pos[0] | |
| # since we have an EEG reference position, we have | |
| # to add it into the info['dig'] as EEG000 | |
| custom_eeg_ref_dig = True | |
| else: | |
| refs = set(ch_pos) & {"EEG000", "REF"} | |
| assert len(refs) <= 1 | |
| eeg_ref_pos = np.zeros(3) if not refs else ch_pos.pop(refs.pop()) | |
| custom_eeg_ref_dig = False | |
| del ref_pos |
Assuming the recording did have an electrode digitization for the EEG electrodes, but we actually skipped it. The
ref_pos array is:
array([[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.],
[1., 0., 0.]])
I'll try to get some ER recordings with/without EEG channels enabled and with/without digitization to confirm on our MEG.
Activity
Famous077 commentedon Feb 25, 2026
Hi @mscheltienne I'd like to work on this bug. The condition
ref_pos[0].any()appearsto incorrectly identify placeholder values
[1., 0., 0.]as validdigitization positions. I'll investigate the fix in montage.py and
open a PR shortly.