Repository navigation
resolve_channel_positions: place a montage in REVE's position bank - #1400
Merged
bruAristimunha merged 7 commits intoOct 14, 2026
Merged
bruAristimunha merged 7 commits into
bruAristimunha merged 7 commits into
Conversation
…bank
One rule per channel, first match wins: montage-qualified bank name
(montage="biosemi128" -> biosemi128_A1), exact name, normalised name
(case, EEG prefix, -REF/-LE/-AR, legacy T3-T6 and MNE's location
aliases), the channel's loc, the midpoint of a bipolar A-B pair, then
on_missing ("error" with difflib suggestions that are never applied,
"drop", or "nearest" to snap positioned channels to a bank entry).
Returns the positions, the kept indices and per-channel provenance
(rule, bank name, distance). A position is never invented.
raw.set_montage gives loc in the head frame while REVE's bank holds the
montage files' own frames (46-57 mm apart for standard_1005), so loc is
registered onto the bank (trimmed similarity fit on the channels named
in both, else MNE's standard_1005 template). A named channel whose
registered loc lies more than 30 mm from its bank entry is a name
collision (BioSemi-128 A1/A2/C1-C6 against REVE's 10-20 entries) and
keeps its loc, with a warning.
Tests run offline on a copy of REVE's released bank.
…ing) REVE(montage=None, on_missing="error") resolves its default positions with the shared rule: exact bank names give the same default_pos and outputs as before (bank rows round-trip float32 -> float64 -> float32), channels outside the bank are placed from their loc or as bipolar midpoints instead of raising, and model.channel_provenance records the rule per channel. on_missing="drop" leaves channels out; forward then reads only the kept input channels when it gets no pos (TorchScript keeps working). The pos= forward override is unchanged. Fixes BioSemi-128 A1/A2 (and C1-C6) landing on the bank's 10-20 sites of the same names: their loc is used with a warning, and montage="biosemi128" reads the bank's biosemi128_* entries. RevePositionBank.forward raises for an unknown name instead of returning fewer rows than channels.
…on-resolver # Conflicts: # braindecode/models/reve.py
… no provenance, no 2.7k-line bank fixture)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1400 +/- ##
==========================================
+ Coverage 90.10% 90.12% +0.02%
==========================================
Files 167 167
Lines 21740 21786 +46
==========================================
+ Hits 19589 19635 +46
Misses 2151 2151 🚀 New features to boost your workflow:
|
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
braindecode.modules.resolve_channel_positions(chs_info, bank, montage=None, on_missing="error"), one function of about 60 lines, and uses it in REVE.Each channel gets the first match among:
montage="biosemi128"makesA1readbiosemi128_A1, near the vertex, instead of the 10-20 earlobeA1;EEGprefix or-REF/-LE/-ARsuffix;A-B, the midpoint of A and B.Channels left over follow
on_missing:"error"raises;"drop"leaves them out, and REVE then reads only the kept input channels;"nearest"takes the bank entry closest to the channel'sloc, and drops a channel that has noloc.No position is invented.
RevePositionBank.forwardnow raises for an unknown name instead of returning fewer rows than channels. Exact bank names give the samedefault_posas before.Tests use a 6-entry bank written to a temporary file, not a copy of the bank.