Repository navigation
Fix FutureWarning for renamed standard montages on MNE >= 1.13 - #1164
Conversation
MNE 1.13 renamed standard_1005/standard_1020 to colin27_1005/ colin27_1020 and deprecated the legacy names, which will raise in MNE 1.14. braindecode supports mne>=1.11, where only the legacy names exist, so the spelling is now resolved against the installed MNE version via the new braindecode.util.resolve_montage_name() and used at every internal montage lookup (eegpt, dgcnn, interpolated, tuh, augmentation transforms). Fixes braindecode#1163
The old assertion required the MNE spline matrix for a channel set interpolated onto its own positions to have off-diagonal structure > 1e-6, but self-interpolation is (correctly) numerically exact identity, so the test failed on all CI platforms. Rework the test to use the same channel names at different positions: name_match yields the permutation matrix, while always mode must compute the MNE spline onto the new positions, which mixes several sources per target row (off-diagonal weights O(0.1-1), stable across platforms) and preserves constant signals (row sums = 1).
|
Thanks for the approval! About the CI failures on the first run:
|
|
One heads-up: the new commit re-triggered the fork-PR workflow approval requirement — the 4 GitHub Actions workflows on de6be39 are again awaiting maintainer approval (Codacy and CircleCI already pass). Could you re-approve the runs when convenient? Sorry for the extra click, and thanks! |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1164 +/- ##
=======================================
Coverage 86.56% 86.57%
=======================================
Files 142 142
Lines 16292 16303 +11
=======================================
+ Hits 14103 14114 +11
Misses 2189 2189 🚀 New features to boost your workflow:
|
Fixes #1163.
Summary
MNE 1.13 renamed the
standard_1005/standard_1020standard montages tocolin27_1005/colin27_1020and deprecated the legacy names, which will raise in MNE 1.14 (mne-tools/mne-python#13903). Becausebraindecode.models.eegptbuilds its canonical channel list at import time, importingbraindecodewith MNE >= 1.13 emits the warning reported in the issue:Since
braindecodesupportsmne>=1.11.0, andcolin27_*only exists from MNE 1.13 on (while the legacy names disappear in 1.14), neither spelling can be hard-coded. This PR addsbraindecode.util.resolve_montage_name(), which picks the spelling the installed MNE knows via the publicmne.channels.get_builtin_montages()— no version parsing, no private API — and routes every internal montage lookup through it:braindecode/models/eegpt.py(2 sites; one runs at import time — the site from the issue traceback)braindecode/models/dgcnn.py(standard_1005)braindecode/models/interpolated.py(_build_chs_info_from_montagenow accepts both spellings on every supported MNE version)braindecode/datasets/tuh.py(2 sites;standard_1005is renamed by the same MNE PR and would have started failing on MNE 1.14)braindecode/augmentation/transforms.pyElectrode positions are unaffected:
colin27_1020.elcis byte-identical to the previousstandard_1020.elc(verified against mne-python v1.12.0 and v1.13.0) — the rename is purely cosmetic.Validation
pytest test/unit_tests/test_util.py— new regression tests: (i) both renamed montages resolve to a spelling the installed MNE knows, (ii) building them through the helper raises noFutureWarning, (iii) EEGPT channel building — the import-time path from the issue — raises noFutureWarningruff format --checkandruff check --select=F401,Ion all touched filesTests/examples that call
make_standard_montage('standard_1020')directly are intentionally left untouched to keep this PR focused on the library code: they only emit a warning today and can be migrated once MNE 1.14 actually lands.