--- license: bsd-3-clause library_name: braindecode pipeline_tag: feature-extraction tags: - eeg - biosignal - pytorch - neuroscience - braindecode - convolutional --- # EEGTCNet EEGTCNet model from Ingolfsson et al (2020) . > **Architecture-only repository.** This repo documents the > `braindecode.models.EEGTCNet` class. **No pretrained weights are > distributed here** — instantiate the model and train it on your own > data, or fine-tune from a published foundation-model checkpoint > separately. ## Quick start ```bash pip install braindecode ``` ```python from braindecode.models import EEGTCNet model = EEGTCNet( n_chans=22, sfreq=250, input_window_seconds=4.0, n_outputs=4, ) ``` The signal-shape arguments above are example defaults — adjust them to match your recording. ## Documentation - Full API reference (parameters, references, architecture figure): - Interactive browser with live instantiation: - Source on GitHub: ## Architecture description The block below is the rendered class docstring (parameters, references, architecture figure where available).

EEGTCNet model from Ingolfsson et al (2020) [ingolfsson2020]_.

ConvolutionRecurrent .. figure:: https://braindecode.org/dev/_static/model/eegtcnet.jpg :align: center :alt: EEGTCNet Architecture Combining EEGNet and TCN blocks. Parameters ---------- activation : nn.Module, optional Activation function to use. Default is `nn.ELU()`. depth_multiplier : int, optional Depth multiplier for the depthwise convolution. Default is 2. filter_1 : int, optional Number of temporal filters in the first convolutional layer. Default is 8. kern_length : int, optional Length of the temporal kernel in the first convolutional layer. Default is 64. dropout : float, optional Dropout rate. Default is 0.5. depth : int, optional Number of residual blocks in the TCN. Default is 2. kernel_size : int, optional Size of the temporal convolutional kernel in the TCN. Default is 4. filters : int, optional Number of filters in the TCN convolutional layers. Default is 12. max_norm_const : float Maximum L2-norm constraint imposed on weights of the last fully-connected layer. Defaults to 0.25. References ---------- .. [ingolfsson2020] Ingolfsson, T. M., Hersche, M., Wang, X., Kobayashi, N., Cavigelli, L., & Benini, L. (2020). EEG-TCNet: An accurate temporal convolutional network for embedded motor-imagery brain–machine interfaces. https://doi.org/10.48550/arXiv.2006.00622 .. rubric:: Hugging Face Hub integration When the optional ``huggingface_hub`` package is installed, all models automatically gain the ability to be pushed to and loaded from the Hugging Face Hub. Install with:: pip install braindecode[hub] **Pushing a model to the Hub:** .. code:: from braindecode.models import EEGTCNet # Train your model model = EEGTCNet(n_chans=22, n_outputs=4, n_times=1000) # ... training code ... # Push to the Hub model.push_to_hub( repo_id="username/my-eegtcnet-model", commit_message="Initial model upload", ) **Loading a model from the Hub:** .. code:: from braindecode.models import EEGTCNet # Load pretrained model model = EEGTCNet.from_pretrained("username/my-eegtcnet-model") # Load with a different number of outputs (head is rebuilt automatically) model = EEGTCNet.from_pretrained("username/my-eegtcnet-model", n_outputs=4) **Extracting features and replacing the head:** .. code:: import torch x = torch.randn(1, model.n_chans, model.n_times) # Extract encoder features (consistent dict across all models) out = model(x, return_features=True) features = out["features"] # Replace the classification head model.reset_head(n_outputs=10) **Saving and restoring full configuration:** .. code:: import json config = model.get_config() # all __init__ params with open("config.json", "w") as f: json.dump(config, f) model2 = EEGTCNet.from_config(config) # reconstruct (no weights) All model parameters (both EEG-specific and model-specific such as dropout rates, activation functions, number of filters) are automatically saved to the Hub and restored when loading. See :ref:`load-pretrained-models` for a complete tutorial.
## Citation Please cite both the original paper for this architecture (see the *References* section 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.