bruAristimunha commited on
Commit
5a07dae
·
verified ·
1 Parent(s): 26f7a1f

Replace with clean markdown card

Browse files
Files changed (1) hide show
  1. README.md +22 -122
README.md CHANGED
@@ -9,18 +9,16 @@ tags:
9
  - neuroscience
10
  - braindecode
11
  - convolutional
12
- - transformer
13
  ---
14
 
15
  # SPARCNet
16
 
17
- Seizures, Periodic and Rhythmic pattern Continuum Neural Network (SPaRCNet) from Jing et al (2023) .
18
 
19
- > **Architecture-only repository.** This repo documents the
20
  > `braindecode.models.SPARCNet` class. **No pretrained weights are
21
- > distributed here** instantiate the model and train it on your own
22
- > data, or fine-tune from a published foundation-model checkpoint
23
- > separately.
24
 
25
  ## Quick start
26
 
@@ -39,137 +37,39 @@ model = SPARCNet(
39
  )
40
  ```
41
 
42
- The signal-shape arguments above are example defaults — adjust them
43
- to match your recording.
44
 
45
  ## Documentation
46
-
47
- - Full API reference (parameters, references, architecture figure):
48
- <https://braindecode.org/stable/generated/braindecode.models.SPARCNet.html>
49
- - Interactive browser with live instantiation:
50
  <https://huggingface.co/spaces/braindecode/model-explorer>
51
  - Source on GitHub: <https://github.com/braindecode/braindecode/blob/master/braindecode/models/sparcnet.py#L13>
52
 
53
- ## Architecture description
54
-
55
- The block below is the rendered class docstring (parameters,
56
- references, architecture figure where available).
57
-
58
- <div class='bd-doc'><main>
59
- <p>Seizures, Periodic and Rhythmic pattern Continuum Neural Network (SPaRCNet) from Jing et al (2023) [jing2023]_.</p>
60
- <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>
61
-
62
-
63
-
64
- This is a temporal CNN model for biosignal classification based on the DenseNet
65
- architecture.
66
-
67
- The model is based on the unofficial implementation [Code2023]_.
68
-
69
- .. versionadded:: 0.9
70
-
71
- Notes
72
- -----
73
- This implementation is not guaranteed to be correct, has not been checked
74
- by original authors.
75
-
76
- Parameters
77
- ----------
78
- block_layers : int, optional
79
- Number of layers per dense block. Default is 4.
80
- growth_rate : int, optional
81
- Growth rate of the DenseNet. Default is 16.
82
- bn_size : int, optional
83
- Bottleneck size. Default is 16.
84
- drop_prob : float, optional
85
- Dropout rate. Default is 0.5.
86
- conv_bias : bool, optional
87
- Whether to use bias in convolutional layers. Default is True.
88
- batch_norm : bool, optional
89
- Whether to use batch normalization. Default is True.
90
- activation: nn.Module, default=nn.ELU
91
- Activation function class to apply. Should be a PyTorch activation
92
- module class like ``nn.ReLU`` or ``nn.ELU``. Default is ``nn.ELU``.
93
-
94
- References
95
- ----------
96
- .. [jing2023] Jing, J., Ge, W., Hong, S., Fernandes, M. B., Lin, Z.,
97
- Yang, C., ... & Westover, M. B. (2023). Development of expert-level
98
- classification of seizures and rhythmic and periodic
99
- patterns during eeg interpretation. Neurology, 100(17), e1750-e1762.
100
- .. [Code2023] Yang, C., Westover, M.B. and Sun, J., 2023. BIOT
101
- Biosignal Transformer for Cross-data Learning in the Wild.
102
- GitHub https://github.com/ycq091044/BIOT (accessed 2024-02-13)
103
-
104
- .. rubric:: Hugging Face Hub integration
105
-
106
- When the optional ``huggingface_hub`` package is installed, all models
107
- automatically gain the ability to be pushed to and loaded from the
108
- Hugging Face Hub. Install with::
109
-
110
- pip install braindecode[hub]
111
-
112
- **Pushing a model to the Hub:**
113
-
114
- .. code::
115
- from braindecode.models import SPARCNet
116
-
117
- # Train your model
118
- model = SPARCNet(n_chans=22, n_outputs=4, n_times=1000)
119
- # ... training code ...
120
-
121
- # Push to the Hub
122
- model.push_to_hub(
123
- repo_id="username/my-sparcnet-model",
124
- commit_message="Initial model upload",
125
- )
126
-
127
- **Loading a model from the Hub:**
128
-
129
- .. code::
130
- from braindecode.models import SPARCNet
131
-
132
- # Load pretrained model
133
- model = SPARCNet.from_pretrained("username/my-sparcnet-model")
134
-
135
- # Load with a different number of outputs (head is rebuilt automatically)
136
- model = SPARCNet.from_pretrained("username/my-sparcnet-model", n_outputs=4)
137
-
138
- **Extracting features and replacing the head:**
139
-
140
- .. code::
141
- import torch
142
-
143
- x = torch.randn(1, model.n_chans, model.n_times)
144
- # Extract encoder features (consistent dict across all models)
145
- out = model(x, return_features=True)
146
- features = out["features"]
147
 
148
- # Replace the classification head
149
- model.reset_head(n_outputs=10)
150
 
151
- **Saving and restoring full configuration:**
152
 
153
- .. code::
154
- import json
 
 
 
 
 
 
 
155
 
156
- config = model.get_config() # all __init__ params
157
- with open("config.json", "w") as f:
158
- json.dump(config, f)
159
 
160
- model2 = SPARCNet.from_config(config) # reconstruct (no weights)
161
 
162
- All model parameters (both EEG-specific and model-specific such as
163
- dropout rates, activation functions, number of filters) are automatically
164
- saved to the Hub and restored when loading.
165
 
166
- See :ref:`load-pretrained-models` for a complete tutorial.</main>
167
- </div>
168
 
169
  ## Citation
170
 
171
- Please cite both the original paper for this architecture (see the
172
- *References* section above) and braindecode:
173
 
174
  ```bibtex
175
  @article{aristimunha2025braindecode,
 
9
  - neuroscience
10
  - braindecode
11
  - convolutional
 
12
  ---
13
 
14
  # SPARCNet
15
 
16
+ Seizures, Periodic and Rhythmic pattern Continuum Neural Network (SPaRCNet) from Jing et al (2023) [jing2023].
17
 
18
+ > **Architecture-only repository.** Documents the
19
  > `braindecode.models.SPARCNet` class. **No pretrained weights are
20
+ > distributed here.** Instantiate the model and train it on your own
21
+ > data.
 
22
 
23
  ## Quick start
24
 
 
37
  )
38
  ```
39
 
40
+ The signal-shape arguments above are illustrative defaults — adjust to
41
+ match your recording.
42
 
43
  ## Documentation
44
+ - Full API reference: <https://braindecode.org/stable/generated/braindecode.models.SPARCNet.html>
45
+ - Interactive browser (live instantiation, parameter counts):
 
 
46
  <https://huggingface.co/spaces/braindecode/model-explorer>
47
  - Source on GitHub: <https://github.com/braindecode/braindecode/blob/master/braindecode/models/sparcnet.py#L13>
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
 
 
50
 
51
+ ## Parameters
52
 
53
+ | Parameter | Type | Description |
54
+ |---|---|---|
55
+ | `block_layers` | int, optional | Number of layers per dense block. Default is 4. |
56
+ | `growth_rate` | int, optional | Growth rate of the DenseNet. Default is 16. |
57
+ | `bn_size` | int, optional | Bottleneck size. Default is 16. |
58
+ | `drop_prob` | float, optional | Dropout rate. Default is 0.5. |
59
+ | `conv_bias` | bool, optional | Whether to use bias in convolutional layers. Default is True. |
60
+ | `batch_norm` | bool, optional | Whether to use batch normalization. Default is True. |
61
+ | `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`. |
62
 
 
 
 
63
 
64
+ ## References
65
 
66
+ 1. 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.
67
+ 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)
 
68
 
 
 
69
 
70
  ## Citation
71
 
72
+ Cite the original architecture paper (see *References* above) and braindecode:
 
73
 
74
  ```bibtex
75
  @article{aristimunha2025braindecode,