|
Download README.md from braindecode/CodeBrain: direct link, hf CLI and curl.
- Browser
- Download file 3.55 kB
-
https://huggingface.co/braindecode/CodeBrain/resolve/main/README.md
- Command line
-
hf download hf://braindecode/CodeBrain/README.md
-
curl -L -o README.md https://huggingface.co/braindecode/CodeBrain/resolve/main/README.md
3.55 kB
| license: bsd-3-clause | |
| library_name: braindecode | |
| pipeline_tag: feature-extraction | |
| tags: | |
| - eeg | |
| - biosignal | |
| - pytorch | |
| - neuroscience | |
| - braindecode | |
| - foundation-model | |
| - transformer | |
| # CodeBrain | |
| CodeBrain: Scalable Code EEG Pre-Training for Unified Downstream BCI Tasks. | |
| > **Architecture-only repository.** Documents the | |
| > `braindecode.models.CodeBrain` class. **No pretrained weights are | |
| > distributed here.** Instantiate the model and train it on your own | |
| > data. | |
| ## Quick start | |
| ```bash | |
| pip install braindecode | |
| ``` | |
| ```python | |
| from braindecode.models import CodeBrain | |
| model = CodeBrain( | |
| n_chans=22, | |
| sfreq=200, | |
| input_window_seconds=4.0, | |
| n_outputs=2, | |
| ) | |
| ``` | |
| The signal-shape arguments above are illustrative defaults — adjust to | |
| match your recording. | |
| ## Documentation | |
| - Full API reference: <https://braindecode.org/stable/generated/braindecode.models.CodeBrain.html> | |
| - Interactive browser (live instantiation, parameter counts): | |
| <https://huggingface.co/spaces/braindecode/model-explorer> | |
| - Source on GitHub: <https://github.com/braindecode/braindecode/blob/master/braindecode/models/codebrain.py#L21> | |
| ## Architecture | |
|  | |
| ## Parameters | |
| | Parameter | Type | Description | | |
| |---|---|---| | |
| | `patch_size` | int, default=200 | Number of time samples per patch. Input length is trimmed to the nearest multiple of `patch_size`. | | |
| | `res_channels` | int, default=200 | Width of the residual stream inside each `ResidualBlock`. | | |
| | `skip_channels` | int, default=200 | Width of the skip-connection stream aggregated across blocks. | | |
| | `out_channels` | int, default=200 | Output channels of `final_conv` before the classification head. | | |
| | `num_res_layers` | int, default=8 | Number of stacked `ResidualBlock` modules. | | |
| | `drop_prob` | float, default=0.1 | Dropout rate used inside the `_GConv` SSM and attention layers. | | |
| | `s4_bidirectional` | bool, default=True | Whether the `_GConv` SSM processes the sequence bidirectionally. | | |
| | `s4_layernorm` | bool, default=False | Whether to apply layer normalisation inside the `_GConv` SSM. Set to `False` to match the released pretrained checkpoint. | | |
| | `s4_lmax` | int, default=570 | Maximum sequence length for the `_GConv` SSM kernel. Also determines the patch embedding dimension as `s4_lmax // n_chans`. | | |
| | `s4_d_state` | int, default=64 | State dimension of the `_GConv` SSM. | | |
| | `conv_out_chans` | int, default=25 | Number of output channels in the patch projection convolutions. | | |
| | `conv_groups` | int, default=5 | Number of groups for `GroupNorm` in the patch projection. | | |
| | `activation` | type[nn.Module], default=nn.ReLU | Non-linear activation class used in `init_conv` and `final_conv`. | | |
| ## References | |
| 1. Yi Ding, Xuyang Chen, Yong Li, Rui Yan, Tao Wang, Le Wu (2025). CodeBrain: Scalable Code EEG Pre-Training for Unified Downstream BCI Tasks. https://arxiv.org/abs/2506.09110 | |
| ## Citation | |
| Cite the original architecture paper (see *References* above) and braindecode: | |
| ```bibtex | |
| @article{aristimunha2025braindecode, | |
| title = {Braindecode: a deep learning library for raw electrophysiological data}, | |
| author = {Aristimunha, Bruno and others}, | |
| journal = {Zenodo}, | |
| year = {2025}, | |
| doi = {10.5281/zenodo.17699192}, | |
| } | |
| ``` | |
| ## License | |
| BSD-3-Clause for the model code (matching braindecode). | |
| Pretraining-derived weights, if you fine-tune from a checkpoint, | |
| inherit the licence of that checkpoint and its training corpus. | |