NeuroTechX / NeuroTechX/moabb

`Ofner2017(executed=True)` can't set montage and fails

Open
#384 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug dataset help wanted moabb
Dominant language
Python
Stars
1.1k
Forks
264
Avg merge
1d 13m
Merged PRs (30d)
23

Description

Hi, new bug encountered:

from moabb.datasets import Ofner2017
Ofner2017(executed=True).get_data([1])
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[10], line 1
----> 1 Ofner2017(executed=True).get_data([1])

File ~/miniconda3/envs/motor_embedding_benchmark/lib/python3.10/site-packages/moabb/datasets/base.py:113, in BaseDataset.get_data(self, subjects)
    111     if subject not in self.subject_list:
    112         raise ValueError("Invalid subject {:d} given".format(subject))
--> 113     data[subject] = self._get_single_subject_data(subject)
    115 return data

File ~/miniconda3/envs/motor_embedding_benchmark/lib/python3.10/site-packages/moabb/datasets/upper_limb.py:113, in Ofner2017._get_single_subject_data(self, subject)
    109 for ii, path in enumerate(paths):
    110     raw = read_raw_gdf(
    111         path, eog=eog, misc=range(64, 96), preload=True, verbose="ERROR"
    112     )
--> 113     raw.set_montage(montage)
    114     # there is nan in the data
    115     raw._data[np.isnan(raw._data)] = 0

File <decorator-gen-36>:12, in set_montage(self, montage, match_case, match_alias, on_missing, verbose)

File ~/miniconda3/envs/motor_embedding_benchmark/lib/python3.10/site-packages/mne/io/meas_info.py:423, in MontageMixin.set_montage(self, montage, match_case, match_alias, on_missing, verbose)
    420 from ..channels.montage import _set_montage
    422 info = self if isinstance(self, Info) else self.info
--> 423 _set_montage(info, montage, match_case, match_alias, on_missing)
    424 return self

File ~/miniconda3/envs/motor_embedding_benchmark/lib/python3.10/site-packages/mne/channels/montage.py:1258, in _set_montage(***failed resolving arguments***)
   1247 are_is = "are" if pl else "is"
   1248 missing_coord_msg = (
   1249     f"DigMontage is only a subset of info. There {are_is} "
   1250     f"{len(missing)} channel position{pl} not present in the "
   (...)
   1256     f"position{pl} {are_is} allowed to be unknown in your analyses."
   1257 )
-> 1258 _on_missing(on_missing, missing_coord_msg)
   1260 # set ch coordinates and names from digmontage or nan coords
   1261 for ii in missing:

File ~/miniconda3/envs/motor_embedding_benchmark/lib/python3.10/site-packages/mne/utils/check.py:1142, in _on_missing(on_missing, msg, name, error_klass)
   1140 on_missing = "warn" if on_missing == "warning" else on_missing
   1141 if on_missing == "raise":
-> 1142     raise error_klass(msg)
   1143 elif on_missing == "warn":
   1144     warn(msg)

ValueError: DigMontage is only a subset of info. There are 61 channel positions not present in the DigMontage. The channels missing from the montage are:

['eeg-0', 'eeg-1', 'eeg-2', 'eeg-3', 'eeg-4', 'eeg-5', 'eeg-6', 'eeg-7', 'eeg-8', 'eeg-9', 'eeg-10', 'eeg-11', 'eeg-12', 'eeg-13', 'eeg-14', 'eeg-15', 'eeg-16', 'eeg-17', 'eeg-18', 'eeg-19', 'eeg-20', 'eeg-21', 'eeg-22', 'eeg-23', 'eeg-24', 'eeg-25', 'eeg-26', 'eeg-27', 'eeg-28', 'eeg-29', 'eeg-30', 'eeg-31', 'eeg-32', 'eeg-33', 'eeg-34', 'eeg-35', 'eeg-36', 'eeg-37', 'eeg-38', 'eeg-39', 'eeg-40', 'eeg-41', 'eeg-42', 'eeg-43', 'eeg-44', 'eeg-45', 'eeg-46', 'eeg-47', 'eeg-48', 'eeg-49', 'eeg-50', 'eeg-51', 'eeg-52', 'eeg-53', 'eeg-54', 'eeg-55', 'eeg-56', 'eeg-57', 'eeg-58', 'eeg-59', 'eeg-60'].

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the Ofner2017 example, then inspect moabb/datasets/upper_limb.py around Ofner2017._get_single_subject_data and the montage call shown in the traceback. Confirm the expected channel and montage handling with the surrounding dataset-loading code; done means get_data([1]) no longer raises the reported ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.