Skip to content

Include the CSBrain #1077

Description

@bruAristimunha
No description provided.

Activity

qinxwew commented on Sep 30, 2026

@qinxwew
Contributor

Hi @bruAristimunha — I'd like to take this one on, if that's okay.

Quick context: I recently contributed #1164 (MNE >= 1.13 montage rename shim), #1169 (the new-model PR template/checklist) and #1186 (MSCFormer, benchmarked on BCI IV-2a against CTNet under a shared harness). I'd follow the same recipe here:

  • Port the CSBrain architecture (yuchen2199/CSBrain, arXiv:2506.23075) as an EEGModuleMixin model with the standard registrations (models/__init__.py, summary.csv, util.py, api.rst, architecture figure, whats_new), keeping the region grouping for the structured sparse attention configurable rather than hardcoded to one montage.
  • Benchmark on BCI IV-2a with the same 5-fold per-subject harness used in Add MSCFormer model (multi-scale convolutional transformer for motor imagery) #1186, so the numbers are directly comparable to the MSCFormer/CTNet results there. I can add 2b as well if that's useful.
  • Pretrained weights: the official checkpoint is distributed via Google Drive. I'd be happy to re-host a copy on the HF Hub (à la braindecode/cbramod-pretrained) if you want from_pretrained support in the first PR — or land the architecture + benchmark first and treat weights as a follow-up. Your call.

One flag: the upstream repo currently ships no LICENSE file. I'll open an issue there asking the authors to add one (MIT/Apache-2.0/BSD). If that stalls, the fallback is a reimplementation from the paper's equations (the EEGModuleMixin port rewrites most of the module structure anyway), with the official repo used only as a numerical cross-check.

Thanks!

bruAristimunha commented on Sep 30, 2026

@bruAristimunha
CollaboratorAuthor

it would be great!

I can help in the weights!

let's assume bsd or unlincese

qinxwew commented on Sep 30, 2026

@qinxwew
Contributor

Thanks @bruAristimunha — great to hear! The PR is up now: #1196. A few points to sync:

  • Port fidelity: I verified the port against the official pretrained checkpoint (CSBrain.pth, 8.9M params, SHA-256 cfcdf9dcb069905e5e02e92fe3d59bd3574e779bf554cc02cb701994a79e99cc) — after a pure key rename, feeding the same weights through the upstream reference implementation and through the port produces identical outputs (max abs diff 0.0), so the released weights load as-is into the new module.
  • License: understood — assuming BSD/Unlicense as you suggest. I've also opened Please consider adding an open-source license (MIT/Apache-2.0/BSD) yuchen2199/CSBrain#7 asking the author to add an explicit license; if/when one lands I'll add the adapted-from attribution plus a NOTICE entry on top of the current re-implementation wording.
  • Weights re-host: yes please, that would help a lot! The official checkpoint is currently Google-Drive-only. An HF re-host would make the benchmark fully reproducible without the Drive hop. I can hand over the original file plus a key-mapped state_dict in our module's naming (with hashes for both) — just tell me which shape is most convenient for you.
  • Benchmark: BCI IV-2a, 5-fold cross-session, same harness as MSCFormer/CTNet in Add MSCFormer model (multi-scale convolutional transformer for motor imagery) #1186. CSBrain (official pretrained init) reaches 0.4384 — below its published fine-tuned 2a result (0.5773) and below MSCFormer here, consistent with the systematic harness shift we documented in Add MSCFormer model (multi-scale convolutional transformer for motor imagery) #1186; the full table + figure are in the PR description.
added a commit that references this issue on Oct 6, 2026
c282258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions