BIDS pipeline preprocessing EEG montage

  • MNE version: 1.7.1
  • operating system: Ubuntu 22.04

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬ preprocessing/_01_data_quality ──────────────────────────────────────
β”‚12:57:38β”‚ ⏳️ sub-000 ses-00 run-01 Reading experimental recording: sub-000_ses-00_task-szMonitoring_run-01
β”‚12:57:38β”‚ ⏳️ sub-000 ses-00 run-01 Setting EEG channel locations to template montage: standard_1020.
β”‚12:57:38β”‚ ❌ sub-000 ses-00 run-01 A critical error occurred. The error message was: DigMontage is only a subset of info. There are 19 channel positions not present in the DigMontage. The channels missing from the montage are:

['FP1-Avg', 'F3-Avg', 'C3-Avg', 'P3-Avg', 'O1-Avg', 'F7-Avg', 'T3-Avg', 'T5-Avg', 'FZ-Avg', 'CZ-Avg', 'PZ-Avg', 'FP2-Avg', 'F4-Avg', 'C4-Avg', 'P4-Avg', 'O2-Avg', 'F8-Avg', 'T4-Avg', 'T6-Avg'].

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.

Aborting pipeline run. The traceback is:

  File "/home/andraderenew/.local/lib/python3.10/site-packages/mne_bids_pipeline/steps/preprocessing/_01_data_quality.py", line 98, in assess_data_quality
    raw = import_experimental_data(
  File "/home/andraderenew/.local/lib/python3.10/site-packages/mne_bids_pipeline/_import_data.py", line 384, in import_experimental_data
    _set_eeg_montage(cfg=cfg, raw=raw, subject=subject, session=session, run=run)
  File "/home/andraderenew/.local/lib/python3.10/site-packages/mne_bids_pipeline/_import_data.py", line 332, in _set_eeg_montage
    raw.set_montage(montage, match_case=False, match_alias=True)
  File "<decorator-gen-22>", line 12, in set_montage
  File "/home/andraderenew/.local/lib/python3.10/site-packages/mne/_fiff/meas_info.py", line 427, in set_montage
    _set_montage(info, montage, match_case, match_alias, on_missing)
  File "/home/andraderenew/.local/lib/python3.10/site-packages/mne/channels/montage.py", line 1258, in _set_montage
    _on_missing(on_missing, missing_coord_msg)
  File "/home/andraderenew/.local/lib/python3.10/site-packages/mne/utils/check.py", line 1190, in _on_missing
    raise error_klass(msg)

Dear community,

I have an issue with BIDS pipeline. I don’t know what is the problem but I suspect it is an issue with channel naming.

I think I could us this but I don’t know where to put it. I just have a configuration file. Is there any workaround. Do I need to send my configuration file? It is baseed on a dataset where depending on the subject there is different channel names although all are 10-20 montage. Thank you for all the help in advance.

mapping = {
    'FP1-Avg': 'Fp1', 'F3-Avg': 'F3', 'C3-Avg': 'C3', 'P3-Avg': 'P3', 'O1-Avg': 'O1',
    'F7-Avg': 'F7', 'T3-Avg': 'T7', 'T5-Avg': 'P7', 'FZ-Avg': 'Fz', 'CZ-Avg': 'Cz',
    'PZ-Avg': 'Pz', 'FP2-Avg': 'Fp2', 'F4-Avg': 'F4', 'C4-Avg': 'C4', 'P4-Avg': 'P4',
    'O2-Avg': 'O2', 'F8-Avg': 'F8', 'T4-Avg': 'T8', 'T6-Avg': 'P8'
}

# Rename the channels
raw.rename_channels(mapping)

I have realized part of the problem is due to having varying numbers of channel names, sessions and runs. Is that a problem for BIDS pipeline. What can be a workaround?

Hello, you need to fix the channel names in the channels.tsv files.

Best wishes,
Richard

I’m sorry I’m new in BIDS. I don’t know if I have a channels.tsv file.

I do have events.tsv and also edf file. I do have files in the original dataset with montage types and channel names.

I run BIDS validator and it gave some warnings. Regarding different runs and sessions. I hope that is not an issue.

Although no EEG channel name has average, something from the pipeline perhaps of having set up eeg_reference= average?

Oh my, it appears the *_channels.tsv files are only recommended but not required by the standard. :person_facepalming: cc @sappelhoff

@andraderenew Currently, MNE-BIDS-Pipeline has no support for renaming existing channels, and entirely relies on what’s in the BIDS dataset. β€œNormally” you’d have accompanying *_channels.tsv files that would allow you to easily adjust the BIDS channel names. This doesn’t seem to be the case for your dataset.

I think you could do something like this in your pipeline config:

# Prepare the montage
import mne
montage = mne.channels.make_standard_montage("standard_1005")
montage.rename_channels({name: f"{name}-Avg" for name in montage.ch_names})

# Set the montage
eeg_template_montage = montage

This would rename the channels in the montage and wouldn’t require you to rename the channels in your raw files / BIDS data. That way, when setting the montage, MNE will be able to establish the correspondence between montage and EEG data.

Best wishes,
Richard

1 Like

This should normally not be an issue.