Repository navigation
Add MIRepNet model - #1146
Add MIRepNet model#1146
Conversation
c974a12 to
45146ac
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: None
What changed in this PR
Adds the released MIRepNet convolutional-Transformer encoder and classification head, including pretrained-checkpoint integration and documentation.
Changes:
- Adds the
MIRepNetmodel with validation, feature extraction, head resetting, and checkpoint key mapping. - Extends shared attention with configurable score scaling while retaining PyTorch 2.0 compatibility.
- Adds focused tests, pretrained Hub integration, registry metadata, citation, licensing, and release documentation.
| File | Description |
|---|---|
test/unit_tests/models/test_return_features.py |
Adds MIRepNet to unified feature-return tests. |
test/unit_tests/models/test_modules.py |
Tests explicit attention scaling and SDPA compatibility. |
test/unit_tests/models/test_mirepnet.py |
Adds MIRepNet parameter-validation tests. |
test/unit_tests/models/test_integration.py |
Excludes MIRepNet from TorchScript tests due to its polymorphic output. |
test/integration_tests/test_pretrained_hub_models.py |
Adds pretrained MIRepNet Hub loading and forward-pass coverage. |
docs/whats_new.rst |
Documents the new model and pretrained weights. |
docs/references.bib |
Adds the MIRepNet publication citation. |
docs/api.rst |
Lists MIRepNet in the model API documentation. |
braindecode/modules/attention.py |
Adds configurable attention-score scaling. |
braindecode/models/util.py |
Registers MIRepNet constructor metadata. |
braindecode/models/summary.csv |
Adds MIRepNet model summary metadata. |
braindecode/models/mirepnet.py |
Implements the MIRepNet architecture and model utilities. |
braindecode/models/__init__.py |
Exports MIRepNet publicly. |
NOTICE.txt |
Records the MIT-licensed MIRepNet implementation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1146 +/- ##
==========================================
+ Coverage 86.57% 87.05% +0.48%
==========================================
Files 142 145 +3
Lines 16303 16655 +352
==========================================
+ Hits 14114 14499 +385
+ Misses 2189 2156 -33 🚀 New features to boost your workflow:
|
Resolve models/__init__.py and docs/whats_new.rst conflicts against master's newly-merged MIRepNet (braindecode#1146) and BaRISTA (braindecode#1173): keep both registry entries, restore alphabetical import/__all__ order, keep both changelog entries.
Summary
Scope
This intentionally excludes InterpolatedMIRepNet, channel interpolation, preprocessing, Euclidean alignment, and the masked reconstruction decoder. The raw checkpoint contains 143 keys; all 109 inference keys used by this downstream implementation load, while decoder, mask-token, and forward-unused channel-embedding keys remain excluded.
Testing
python -m pytest -q: 3,391 passed, 232 skippedCloses #1126
Replication results — original-author implementation
Scope: these real-data measurements use the original-author MIRepNet implementation and released checkpoint, not the Braindecode port. They support provenance, not an end-to-end benchmark of this PR. The paper's 82.36 ± 0.10% was not matched.
Each seed mean is an unweighted mean over all nine subjects; SD is across the three seed means. All 27 subject/seed runs per filter used the last epoch of ten, sequential subject RNG (seeded once per full nine-subject run), unstratified 30/70 splits and the same 1,400 exact trial identities from the first test session. Test sets contain 112 trials per subject, except subject 1 with 84; these are not pooled-trial averages. The control changed only the upper band edge and moved the mean by +0.242504 pp; deficits from the paper remain 2.046949 pp and 1.804444 pp, respectively. No seed/filter sweep or best-test-epoch selection.
Protocol caveats: Euclidean alignment is applied separately to native-channel train/test EEG before interpolation to 45 channels. This is transductive: unlabeled test EEG supplies its own covariance reference; test labels are not used for training. The CPU environment and seeds 666/667/668 are reconstructed, while the original prepared arrays, historical seeds and complete environment are unavailable. Neither filter is proven to be the historical setting; this is practical code-faithful reconstruction, not exact historical replication. Original fine-tuning loaded 108/110 downstream tensors with a new two-class head; that is distinct from the 109 inference tensors and port-parity checks described above.
Full protocol, limitations, source/checkpoint hashes and both per-subject tables · All 54 observations with integer correct counts (CSV).
New verification for this documentation-only update: independently recomputed all 54 accuracies, seed means and both SD definitions; verified ten epochs, sequential RNG chains, identical trial/split metadata between filters and all nine recorded terminal job/container receipts (five successful jobs, four diagnosed prerequisite failures). Both complete evaluations exited 0. Repository pre-commit checks for the two added evidence files and
git diff --checkpassed. No model code changed; the earlier unit-test claims in Testing are preserved historical results, not a newly rerun full suite. No CI or merge outcome is claimed.