Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

loading ERM fails when preparing for maxfiltering if ERM contains EEG #1036

Open
drammock opened this issue Jan 13, 2025 · 1 comment
Open

Comments

@drammock
Copy link
Member

drammock commented Jan 13, 2025

pipeline calls to maxwell_filter_prepare_emptyroom seem like they'll always fail when the ERM contains EEG channels, because the pipeline always removes everything except MEG channels from raw_ref:

raw_ref.pick_types(meg=True, exclude=[])
if prepare_maxwell_filter:
# We need to include any automatically found bad channels, if relevant.
# TODO: This 'union' operation should affect the raw runs, too,
# otherwise rank mismatches will still occur (eventually for some
# configs). But at least using the union here should reduce them.
raw_er = mne.preprocessing.maxwell_filter_prepare_emptyroom(
raw_er=raw_er,
raw=raw_ref,
bads="union",
)

under the hood, maxwell_filter_prepare_emptyroom does this:

https://github.com/mne-tools/mne-python/blob/1d2635f84a55785c3531cfe4027eda3820a7fb31/mne/preprocessing/maxwell.py#L175-L176

So the result looks like:

E   ValueError: DigMontage is only a subset of info. There are 60 channel positions not present in the DigMontage. The channels missing from the montage are:
E   
E   ['EEG001', 'EEG002', 'EEG003', 'EEG004', 'EEG005', 'EEG006', 'EEG007', 'EEG008', 'EEG009', 'EEG010', 'EEG011', 'EEG012', 'EEG013', 'EEG014', 'EEG015', 'EEG016', 'EEG017', 'EEG018', 'EEG019', 'EEG020', 'EEG021', 'EEG022', 'EEG023', 'EEG024', 'EEG025', 'EEG026', 'EEG027', 'EEG028', 'EEG029', 'EEG030', 'EEG031', 'EEG032', 'EEG033', 'EEG034', 'EEG035', 'EEG036', 'EEG037', 'EEG038', 'EEG039', 'EEG040', 'EEG041', 'EEG042', 'EEG043', 'EEG044', 'EEG045', 'EEG046', 'EEG047', 'EEG048', 'EEG049', 'EEG050', 'EEG051', 'EEG052', 'EEG053', 'EEG054', 'EEG055', 'EEG056', 'EEG057', 'EEG058', 'EEG059', 'EEG060'].
E   
E   Consider using inst.rename_channels to match the montage nomenclature, or inst.set_channel_types if these are not EEG channels, or use the on_missing parameter if the channel positions are allowed to be unknown in your analyses.

I'm hoping / assuming that just removing EEG channels from ERM also is the right way to go here (?) If so I can open a PR.

@larsoner
Copy link
Member

Yeah in principle EEG channels shouldn't be in empty-room data I think

drammock added a commit to drammock/mne-bids-pipeline that referenced this issue Jan 13, 2025
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

No branches or pull requests

2 participants