Skip to content

Fix eeglab loading issue while calling _get_montage_information due to scalar x,y,z in 'nodatchans'#13395

Merged
wmvanvliet merged 11 commits intomne-tools:mainfrom
emrecncelik:main
Sep 2, 2025
Merged

Fix eeglab loading issue while calling _get_montage_information due to scalar x,y,z in 'nodatchans'#13395
wmvanvliet merged 11 commits intomne-tools:mainfrom
emrecncelik:main

Conversation

@emrecncelik
Copy link
Copy Markdown
Contributor

Reference issue

This issue was raised in the forum: https://mne.discourse.group/t/saved-using-eeglab-the-set-file-cannot-be-opened/11237

It was also raised in #11227 but was marked as closed.

Bug summary

Minimal code that reproduces the error for specific eeglab data, you should download and unzip the data in the following URL: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/PX8PND

import mne
epochs = mne.io.read_epochs_eeglab("./dataverse_files/AVC1_Full_MARA.set")

Results in (summarized),

File ~/anaconda3/lib/python3.12/site-packages/mne/io/eeglab/eeglab.py:230, in _get_info(eeg, eog, montage_units)
    228 if eeg_has_ch_names_info:
    229     has_pos = _eeg_has_montage_information(eeg)
--> 230     ch_names, ch_types, eeg_montage = _get_montage_information(
    231         eeg, has_pos, montage_units=montage_units
    232     )
    233     update_ch_names = False
    234 else:  # if eeg.chanlocs is empty, we still need default chan names

File ~/anaconda3/lib/python3.12/site-packages/mne/io/eeglab/eeglab.py:173, in _get_montage_information(eeg, get_pos, montage_units)
    170 ys = nodatchans.get("Y", [])
    171 zs = nodatchans.get("Z", [])
--> 173 for type_, description, x, y, z in zip(types, descriptions, xs, ys, zs):
    174     if type_ != "FID":
    175         continue

TypeError: 'float' object is not iterable

What does this implement/fix?

This error was caused by xs, ys, zs being a float value rather than an iterable or array. Added np.atleast_1d function after getting the x, y, z values to ensure they are iterables.

Additional information

  • I do not have access to the data from the previous issue and the forum posts but the problem looks the same.

@welcome
Copy link
Copy Markdown

welcome bot commented Aug 26, 2025

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

@emrecncelik emrecncelik changed the title Fix eeglab loading issue while calling _get_montage_information due to scalar x,y,z in 'nodatchans' Fix eeglab loading issue while calling _get_montage_information due to scalar x,y,z in 'nodatchans' Aug 26, 2025
Copy link
Copy Markdown
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

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

thanks for the clear reproducible example and the fix! I confirm the fix works with the linked files and the code in this PR. Could you please add a changelog entry? doc/changes/dev/13395.bugfix.rst; see other files in that folder for examples. First-time contributors (I think that applies to you?) should use the :newcontrib: role in the changelog entry, and add themselves (alphabetically) to doc/changes/names.inc also.

Copy link
Copy Markdown
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.

Comments addressed, marking for merge-when-green -- thanks in advance @emrecncelik !

@emrecncelik
Copy link
Copy Markdown
Contributor Author

Thank you! I've had a tiny bit of trouble with the change log since I'm not that familiar with it, sorry for the hassle.

@wmvanvliet wmvanvliet merged commit 17c4e03 into mne-tools:main Sep 2, 2025
32 checks passed
@welcome
Copy link
Copy Markdown

welcome bot commented Sep 2, 2025

🎉 Congrats on merging your first pull request! 🥳 Looking forward to seeing more from you in the future! 💪

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

Successfully merging this pull request may close these issues.

4 participants