Skip to content

Fix FutureWarning for renamed standard montages on MNE >= 1.13 - #1164

Merged
bruAristimunha merged 2 commits into
braindecode:masterfrom
qinxwew:fix/mne-montage-renames
Sep 14, 2026
Merged

bruAristimunha merged 2 commits into
braindecode:masterfrom
qinxwew:fix/mne-montage-renames

Conversation

@qinxwew

@qinxwew qinxwew commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #1163.

Summary

MNE 1.13 renamed the standard_1005/standard_1020 standard montages to colin27_1005/colin27_1020 and deprecated the legacy names, which will raise in MNE 1.14 (mne-tools/mne-python#13903). Because braindecode.models.eegpt builds its canonical channel list at import time, importing braindecode with MNE >= 1.13 emits the warning reported in the issue:

FutureWarning: Montage name 'standard_1020' is deprecated and will be removed in MNE 1.14.
Use 'colin27_1020' instead.

Since braindecode supports mne>=1.11.0, and colin27_* only exists from MNE 1.13 on (while the legacy names disappear in 1.14), neither spelling can be hard-coded. This PR adds braindecode.util.resolve_montage_name(), which picks the spelling the installed MNE knows via the public mne.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_montage now accepts both spellings on every supported MNE version)
  • braindecode/datasets/tuh.py (2 sites; standard_1005 is renamed by the same MNE PR and would have started failing on MNE 1.14)
  • braindecode/augmentation/transforms.py

Electrode positions are unaffected: colin27_1020.elc is byte-identical to the previous standard_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 no FutureWarning, (iii) EEGPT channel building — the import-time path from the issue — raises no FutureWarning
  • ruff format --check and ruff check --select=F401,I on all touched files
  • CI

Tests/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.

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).
@qinxwew

qinxwew commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the approval!

About the CI failures on the first run:

  1. test_always_mode_uses_mne_even_when_names_match — my fault: the test asserted that the MNE spline matrix for a channel set interpolated onto its own positions has off-diagonal structure > 1e-6. Self-interpolation is (correctly) numerically exact identity, so the assertion was fragile and failed on all platforms. I reworked the test in de6be39 to use the same channel names at different positions: name_match yields the permutation matrix, while always must compute the spline onto the new positions (mixing several sources per target row, row sums = 1) — a deterministic distinction independent of solver precision.

  2. build_docs — the sphinx-gallery run of examples/datasets_io/plot_benchmark_preprocessing.py died on a ConnectTimeout downloading SleepPhysionet data from physionet.org. This looks like a network flake unrelated to this diff (the PR touches no examples); it should come back green on the re-run triggered by the new commit.

@qinxwew

qinxwew commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

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

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.57%. Comparing base (adaa63a) to head (de6be39).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bruAristimunha
bruAristimunha merged commit f6144d3 into braindecode:master Sep 14, 2026
11 of 12 checks passed
@qinxwew qinxwew mentioned this pull request Sep 30, 2026
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.

Annoying irrelevant MNE warning when importing the latest version of braindecode

2 participants