Skip to content

Conversation

@pre-commit-ci
Copy link
Contributor

@pre-commit-ci pre-commit-ci bot commented Sep 9, 2024

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.6.3 → v0.6.4](astral-sh/ruff-pre-commit@v0.6.3...v0.6.4)
@larsoner
Copy link
Member

@sappelhoff adding a hotfix here for this CircleCI error that appears to be due to (I think) #12830, can you see if a warning should indeed be emitted for this montage or if it's a mistake that crept in in #12830?

@larsoner
Copy link
Member

Oof actually my hotfix is not enough, it causes an error. I'll push so you can see it in CircleCI:

Traceback (most recent call last):
  File "/Users/larsoner/python/mne-python/tutorials/inverse/70_eeg_mri_coords.py", line 129, in <module>
    raw.set_montage(dig_montage)
  File "<decorator-gen-22>", line 12, in set_montage
  File "/Users/larsoner/python/mne-python/mne/_fiff/meas_info.py", line 422, in set_montage
    _set_montage(info, montage, match_case, match_alias, on_missing)
  File "/Users/larsoner/python/mne-python/mne/channels/montage.py", line 1250, in _set_montage
    _on_missing(on_missing, missing_coord_msg)
  File "/Users/larsoner/python/mne-python/mne/utils/check.py", line 1219, in _on_missing
    raise error_klass(msg)
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:

['EEG 001', 'EEG 002', 'EEG 003', 'EEG 004', 'EEG 005', 'EEG 006', 'EEG 007', 'EEG 008', 'EEG 009', 'EEG 010', 'EEG 011', 'EEG 012', 'EEG 013', 'EEG 014', 'EEG 015', 'EEG 016', 'EEG 017', 'EEG 018', 'EEG 019', 'EEG 020', 'EEG 021', 'EEG 022', 'EEG 023', 'EEG 024', 'EEG 025', 'EEG 026', 'EEG 027', 'EEG 028', 'EEG 029', 'EEG 030', 'EEG 031', 'EEG 032', 'EEG 033', 'EEG 034', 'EEG 035', 'EEG 036', 'EEG 037', 'EEG 038', 'EEG 039', 'EEG 040', 'EEG 041', 'EEG 042', 'EEG 043', 'EEG 044', 'EEG 045', 'EEG 046', 'EEG 047', 'EEG 048', 'EEG 049', 'EEG 050', 'EEG 051', 'EEG 052', 'EEG 053', 'EEG 054', 'EEG 055', 'EEG 056', 'EEG 057', 'EEG 058', 'EEG 059', 'EEG 060'].

@sappelhoff
Copy link
Member

Yes, this is an error I inadvertently introduced. I will add a fix and will include a line to the test that would have caught this! thanks for pinging me :)

@sappelhoff
Copy link
Member

This shows that the issue is:

# %%
import mne

montage_path = mne.datasets.misc.data_path() / "sample_eeg_mri" / "sample_mri_montage.elc"

with open(montage_path) as fid:

    for line in fid:
        if "Labels\n" in line:
            break

    ch_names_ = []
    for line in fid:
        if not line or not set(line) - {" "}:
            break
        parsed1 = line.strip(" ").strip("\n")  # old parsing
        parsed2 = line.strip(" ").strip("\n").split()  # new parsing

        print(f"{line.strip()} | {parsed1} | {parsed2}")


# %%

☝️ I wanted to also support ELC files that specify channel labels on a single line. I wasn't thinking about channel labels with spaces ... but that is what causes the issue.

@sappelhoff sappelhoff mentioned this pull request Sep 10, 2024
@larsoner larsoner merged commit 9a2f887 into main Sep 12, 2024
@larsoner larsoner deleted the pre-commit-ci-update-config branch September 12, 2024 14:25
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.

2 participants