Skip to content

Add MIRepNet model - #1146

Merged
bruAristimunha merged 10 commits into
braindecode:masterfrom
bruAristimunha:feat/mirepnet-1126
Sep 29, 2026
Merged

bruAristimunha merged 10 commits into
braindecode:masterfrom
bruAristimunha:feat/mirepnet-1126

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Aug 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add the released downstream MIRepNet convolutional-Transformer encoder and classification head.
  • Preserve released checkpoint behavior, including embed-dimension attention scaling, while keeping the shared attention module compatible with PyTorch 2.0.
  • Add unified feature extraction and head-reset support, validation, checkpoint key mapping, registry metadata, citation, license notice, release note, and focused/generic tests.

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 skipped
  • Focused MIRepNet, shared-attention, feature/reset-head, config, Hub, batch-size-one, compile, export, and categorization tests pass
  • Pre-commit checks pass

Closes #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.

Reconstructed BNCI2014004 protocol Mean accuracy (%) Population SD (pp) Sample SD (pp) Seed means: 666 / 667 / 668 (%)
Baseline 8–32 Hz 80.313051 0.898893 1.100914 81.250000 / 79.100529 / 80.588624
Single fixed paper-band control, 8–30 Hz 80.555556 1.408435 1.724974 82.506614 / 79.232804 / 79.927249

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 --check passed. 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.

Copilot AI lite review requested due to automatic review settings September 21, 2026 19:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MIRepNet model 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

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.05%. Comparing base (25c7ed6) to head (547bd8d).
⚠️ Report is 10 commits behind head on master.

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

Copilot AI review requested due to automatic review settings September 28, 2026 20:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Checkpoint key mapping lacks direct validation, and metadata and API documentation need alignment.

Review effort: Lite
Findings: None

Copilot AI review requested due to automatic review settings September 29, 2026 11:28
@bruAristimunha
bruAristimunha merged commit b935567 into braindecode:master Sep 29, 2026
11 checks passed
@bruAristimunha
bruAristimunha deleted the feat/mirepnet-1126 branch September 29, 2026 11:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Add regression coverage for upstream checkpoint keys and include MIRepNet in the generated API autosummary.

Review effort: Lite
Findings: None

bruAristimunha added a commit to qinxwew/braindecode that referenced this pull request Sep 29, 2026
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.
bruAristimunha added a commit to bruAristimunha/braindecode that referenced this pull request Oct 6, 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.

Implement this model: https://github.com/staraink/MIRepNet

2 participants