Replace with clean markdown card
Browse files8 unmodified lines9101112131415161718192021222324252612 unmodified lines394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741758 unmodified lines- neuroscience- braindecode- convolutional- transformer---# SPARCNetSeizures, Periodic and Rhythmic pattern Continuum Neural Network (SPaRCNet) from Jing et al (2023) .> **Architecture-only repository.** This repo documents the> `braindecode.models.SPARCNet` 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 start12 unmodified lines)```The signal-shape arguments above are example defaults — adjust themto match your recording.## Documentation- Full API reference (parameters, references, architecture figure):<https://braindecode.org/stable/generated/braindecode.models.SPARCNet.html>- Interactive browser with live instantiation:<https://huggingface.co/spaces/braindecode/model-explorer>- Source on GitHub: <https://github.com/braindecode/braindecode/blob/master/braindecode/models/sparcnet.py#L13>## Architecture descriptionThe block below is the rendered class docstring (parameters,references, architecture figure where available).<div class='bd-doc'><main><p>Seizures, Periodic and Rhythmic pattern Continuum Neural Network (SPaRCNet) from Jing et al (2023) [jing2023]_.</p><span style="display:inline-block;padding:2px 8px;border-radius:4px;background:#5cb85c;color:white;font-size:11px;font-weight:600;margin-right:4px;">Convolution</span>This is a temporal CNN model for biosignal classification based on the DenseNetarchitecture.The model is based on the unofficial implementation [Code2023]_... versionadded:: 0.9Notes-----This implementation is not guaranteed to be correct, has not been checkedby original authors.Parameters----------block_layers : int, optionalNumber of layers per dense block. Default is 4.growth_rate : int, optionalGrowth rate of the DenseNet. Default is 16.bn_size : int, optionalBottleneck size. Default is 16.drop_prob : float, optionalDropout rate. Default is 0.5.conv_bias : bool, optionalWhether to use bias in convolutional layers. Default is True.batch_norm : bool, optionalWhether to use batch normalization. Default is True.activation: nn.Module, default=nn.ELUActivation function class to apply. Should be a PyTorch activationmodule class like ``nn.ReLU`` or ``nn.ELU``. Default is ``nn.ELU``.References----------.. [jing2023] Jing, J., Ge, W., Hong, S., Fernandes, M. B., Lin, Z.,Yang, C., ... & Westover, M. B. (2023). Development of expert-levelclassification of seizures and rhythmic and periodicpatterns during eeg interpretation. Neurology, 100(17), e1750-e1762... [Code2023] Yang, C., Westover, M.B. and Sun, J., 2023. BIOTBiosignal Transformer for Cross-data Learning in the Wild.GitHub https://github.com/ycq091044/BIOT (accessed 2024-02-13).. rubric:: Hugging Face Hub integrationWhen the optional ``huggingface_hub`` package is installed, all modelsautomatically gain the ability to be pushed to and loaded from theHugging Face Hub. Install with::pip install braindecode[hub]**Pushing a model to the Hub:**.. code::from braindecode.models import SPARCNet# Train your modelmodel = SPARCNet(n_chans=22, n_outputs=4, n_times=1000)# ... training code ...# Push to the Hubmodel.push_to_hub(repo_id="username/my-sparcnet-model",commit_message="Initial model upload",)**Loading a model from the Hub:**.. code::from braindecode.models import SPARCNet# Load pretrained modelmodel = SPARCNet.from_pretrained("username/my-sparcnet-model")# Load with a different number of outputs (head is rebuilt automatically)model = SPARCNet.from_pretrained("username/my-sparcnet-model", n_outputs=4)**Extracting features and replacing the head:**.. code::import torchx = 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 headmodel.reset_head(n_outputs=10)**Saving and restoring full configuration:**.. code::import jsonconfig = model.get_config() # all __init__ paramswith open("config.json", "w") as f:json.dump(config, f)model2 = SPARCNet.from_config(config) # reconstruct (no weights)All model parameters (both EEG-specific and model-specific such asdropout rates, activation functions, number of filters) are automaticallysaved to the Hub and restored when loading.See :ref:`load-pretrained-models` for a complete tutorial.</main></div>## CitationPlease cite both the original paper for this architecture (see the*References* section above) and braindecode:```bibtex@article{aristimunha2025braindecode,8 unmodified lines910111213141516171819202122232412 unmodified lines3738394041424344454647484950515253545556575859606162636465666768697071727374758 unmodified lines- neuroscience- braindecode- convolutional---# SPARCNetSeizures, Periodic and Rhythmic pattern Continuum Neural Network (SPaRCNet) from Jing et al (2023) [jing2023].> **Architecture-only repository.** Documents the> `braindecode.models.SPARCNet` class. **No pretrained weights are> distributed here.** Instantiate the model and train it on your own> data.## Quick start12 unmodified lines)```The signal-shape arguments above are illustrative defaults — adjust tomatch your recording.## Documentation- Full API reference: <https://braindecode.org/stable/generated/braindecode.models.SPARCNet.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/sparcnet.py#L13>## Parameters| Parameter | Type | Description ||---|---|---|| `block_layers` | int, optional | Number of layers per dense block. Default is 4. || `growth_rate` | int, optional | Growth rate of the DenseNet. Default is 16. || `bn_size` | int, optional | Bottleneck size. Default is 16. || `drop_prob` | float, optional | Dropout rate. Default is 0.5. || `conv_bias` | bool, optional | Whether to use bias in convolutional layers. Default is True. || `batch_norm` | bool, optional | Whether to use batch normalization. Default is True. || `activation: nn.Module, default=nn.ELU` | — | Activation function class to apply. Should be a PyTorch activation module class like `nn.ReLU` or `nn.ELU`. Default is `nn.ELU`. |## References1. Jing, J., Ge, W., Hong, S., Fernandes, M. B., Lin, Z., Yang, C., ... & Westover, M. B. (2023). Development of expert-level classification of seizures and rhythmic and periodic patterns during eeg interpretation. Neurology, 100(17), e1750-e1762.2. Yang, C., Westover, M.B. and Sun, J., 2023. BIOT Biosignal Transformer for Cross-data Learning in the Wild. GitHub https://github.com/ycq091044/BIOT (accessed 2024-02-13)## CitationCite the original architecture paper (see *References* above) and braindecode:```bibtex@article{aristimunha2025braindecode,
README.md+22-122