Repository navigation
Add CORTEG, an ST-EEGFormer adapted to intracranial ECoG - #1551
Conversation
Port of Yang et al. (NeurIPS 2026): ST-EEGFormer's encoder with a KNNSoftFourier spatial adapter placing each electrode by position, a high-gamma token stream (average or layer-wise gated fusion), and ch_mask for padded batches. Loads braindecode/STEEGFormer-small, warm-starting the high-gamma embedding; matches the reference implementation, including its released Stanford adapter.
No private copy of the block: STEEGFormer's _TransformerEncoderBlock forwards an optional attn_mask to its attention; without one it computes as before.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1551 +/- ##
==========================================
+ Coverage 91.50% 91.53% +0.03%
==========================================
Files 170 171 +1
Lines 22394 22580 +186
==========================================
+ Hits 20491 20669 +178
- Misses 1903 1911 +8 🚀 New features to boost your workflow:
|
|
Reproduction runs of the paper's downstream results with this port (Stanford finger flexion and Brain Treebank tasks A/B, through neuralset/NeuralBench tasks) are on their way; I'll post the numbers here. |
|
Reproduction of the paper's downstream results with this port ( The data come through neuralset studies and neuralbench-style task configs. The windows match the authors' window code to float32 precision. The Brain Treebank events and causal folds match the paper's
Values are mean ± SD over subjects; Brain Treebank cells average seeds 42, 1 and 2. The per-subject AUROCs correlate with the paper's at r = 0.977–0.997. These numbers initialise the weights the checkpoint does not load as the reference does: Recipe and results: |
bruAristimunha
left a comment
There was a problem hiding this comment.
Small comments here, but almost all good!
|
Super good work for me! @julien-gadonneix. Besides the comments, I just noticed some hard-coded values in the modules that would be better exposed. Is there any way to generate the vocab using MNE? |
…fixes - The 142 vocabulary positions come from MNE's 10-05 montage (Colin27), which reproduces the reference's table to its 6 decimals. - The high-gamma warm start of a loaded checkpoint moves to the Hub: braindecode/corteg-small-pretrained holds ST-EEGFormer small with it, and the load hook is gone. - chs_info positions are checked at construction. - fourier_max_freq is exposed, and the adapter and gate MLPs use activation. - forward declares its variables first, then checks, then computes, with the shape of each step.
The 142 slot names duplicated steegformer_channels.json on the Hub; the positions already come from MNE's 10-05 montage.
# Conflicts: # docs/whats_new.rst
Merge master 0f1cce2 (braindecode#1551, CORTEG). Conflicts resolved: - NOTICE.txt: master's file plus the meggpt.py MIT line after corteg.py. - test/unit_tests/models/test_pretrained_compat.py: NO_STRATEGY keeps master's CORTEG and this branch's MEGGPT. docs/whats_new.rst, docs/api.rst, summary.csv, __init__.py, util.py and the shared test registries merged without conflict, keeping both entries. braindecode/models/meggpt.py is unchanged from b289953.
Brings in 0f1cce2 (braindecode#1551 CORTEG). Conflicts resolved by keeping both sides: - docs/whats_new.rst: master's file plus the NICE entry after CORTEG's. - NOTICE.txt: master's file plus braindecode/models/nice.py. - test_pretrained_compat.py: NO_STRATEGY lists both CORTEG and NICE.
Merge origin/master 0f1cce2 (braindecode#1551 CORTEG). Resolved: test/unit_tests/models/test_pretrained_compat.py NO_STRATEGY keeps master's CORTEG and this branch's BBL (one entry per line). NOTICE.txt, docs/whats_new.rst, docs/api.rst, summary.csv and models/__init__.py merged automatically; the diff against master is exactly this branch's additions.
Adds
CORTEG(Yang et al., NeurIPS 2026, arXiv:2605.10337, code, MIT): ST-EEGFormer's encoder read on ECoG.pos, orchs_info) attends over the frozen pretrained codebook, plus a Fourier residual.x_hijoins the low-frequencyx, by mean before the lastn_merge_blocksblocks (merge_strategy="average") or by a per-block gate ("layerwise_gate"); withoutx_hithe model readsxalone.STEEGFormer:CORTEG.from_pretrained("braindecode/STEEGFormer-small", ...)loads the backbone and warm-starts the high-gamma embedding from it.ch_maskfor padded batches (not in the reference, which batches one patient at a time).Testing
x_hi; the authors' released Stanford adapter onSTEEGFormer-smallgives their outputs (network test-k corteg_released --run-network)_CASES/_CH_MASK_EXTRAS/ compat / return-features entries;pytest test/unit_tests -k "CORTEG or corteg"andtest_ch_mask_training.py -k CORTEG: passedpre-commit run --files <changed files>: passed