bruAristimunha commited on
Commit
8d78ba8
·
verified ·
1 Parent(s): 244e720

Replace with clean markdown card

Browse files
Files changed (1) hide show
  1. README.md +25 -121
README.md CHANGED
@@ -14,13 +14,12 @@ tags:
14
 
15
  # SleepStagerBlanco2020
16
 
17
- Sleep staging architecture from Blanco et al (2020) from
18
 
19
- > **Architecture-only repository.** This repo documents the
20
  > `braindecode.models.SleepStagerBlanco2020` 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,139 +38,44 @@ model = SleepStagerBlanco2020(
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.SleepStagerBlanco2020.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/sleep_stager_blanco_2020.py#L11>
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>Sleep staging architecture from Blanco et al (2020) from [Blanco2020]_</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
- .. figure:: https://media.springernature.com/full/springer-static/image/art%3A10.1007%2Fs00500-019-04174-1/MediaObjects/500_2019_4174_Fig2_HTML.png
65
- :align: center
66
- :alt: SleepStagerBlanco2020 Architecture
67
-
68
- Convolutional neural network for sleep staging described in [Blanco2020]_.
69
- A series of seven convolutional layers with kernel sizes running down from 7 to 3,
70
- in an attempt to extract more general features at the beginning, while more specific
71
- and complex features were extracted in the final stages.
72
-
73
- Parameters
74
- ----------
75
- n_conv_chans : int
76
- Number of convolutional channels. Set to 20 in [Blanco2020]_.
77
- n_groups : int
78
- Number of groups for the convolution. Set to 2 in [Blanco2020]_ for 2 Channel EEG.
79
- controls the connections between inputs and outputs. n_channels and n_conv_chans must be
80
- divisible by n_groups.
81
- drop_prob : float
82
- Dropout rate before the output dense layer.
83
- apply_batch_norm : bool
84
- If True, apply batch normalization after both temporal convolutional
85
- layers.
86
- return_feats : bool
87
- If True, return the features, i.e. the output of the feature extractor
88
- (before the final linear layer). If False, pass the features through
89
- the final linear layer.
90
- n_channels : int
91
- Alias for `n_chans`.
92
- n_classes : int
93
- Alias for `n_outputs`.
94
- input_size_s : float
95
- Alias for `input_window_seconds`.
96
- activation: nn.Module, default=nn.ReLU
97
- Activation function class to apply. Should be a PyTorch activation
98
- module class like ``nn.ReLU`` or ``nn.ELU``. Default is ``nn.ReLU``.
99
-
100
- References
101
- ----------
102
- .. [Blanco2020] Fernandez-Blanco, E., Rivero, D. & Pazos, A. Convolutional
103
- neural networks for sleep stage scoring on a two-channel EEG signal.
104
- Soft Comput 24, 4067–4079 (2020). https://doi.org/10.1007/s00500-019-04174-1
105
-
106
- .. rubric:: Hugging Face Hub integration
107
-
108
- When the optional ``huggingface_hub`` package is installed, all models
109
- automatically gain the ability to be pushed to and loaded from the
110
- Hugging Face Hub. Install with::
111
-
112
- pip install braindecode[hub]
113
-
114
- **Pushing a model to the Hub:**
115
-
116
- .. code::
117
- from braindecode.models import SleepStagerBlanco2020
118
-
119
- # Train your model
120
- model = SleepStagerBlanco2020(n_chans=22, n_outputs=4, n_times=1000)
121
- # ... training code ...
122
-
123
- # Push to the Hub
124
- model.push_to_hub(
125
- repo_id="username/my-sleepstagerblanco2020-model",
126
- commit_message="Initial model upload",
127
- )
128
-
129
- **Loading a model from the Hub:**
130
-
131
- .. code::
132
- from braindecode.models import SleepStagerBlanco2020
133
-
134
- # Load pretrained model
135
- model = SleepStagerBlanco2020.from_pretrained("username/my-sleepstagerblanco2020-model")
136
 
137
- # Load with a different number of outputs (head is rebuilt automatically)
138
- model = SleepStagerBlanco2020.from_pretrained("username/my-sleepstagerblanco2020-model", n_outputs=4)
139
 
140
- **Extracting features and replacing the head:**
141
 
142
- .. code::
143
- import torch
144
 
145
- x = torch.randn(1, model.n_chans, model.n_times)
146
- # Extract encoder features (consistent dict across all models)
147
- out = model(x, return_features=True)
148
- features = out["features"]
149
 
150
- # Replace the classification head
151
- model.reset_head(n_outputs=10)
 
 
 
 
 
 
 
 
 
152
 
153
- **Saving and restoring full configuration:**
154
 
155
- .. code::
156
- import json
157
 
158
- config = model.get_config() # all __init__ params
159
- with open("config.json", "w") as f:
160
- json.dump(config, f)
161
 
162
- model2 = SleepStagerBlanco2020.from_config(config) # reconstruct (no weights)
163
-
164
- All model parameters (both EEG-specific and model-specific such as
165
- dropout rates, activation functions, number of filters) are automatically
166
- saved to the Hub and restored when loading.
167
-
168
- See :ref:`load-pretrained-models` for a complete tutorial.</main>
169
- </div>
170
 
171
  ## Citation
172
 
173
- Please cite both the original paper for this architecture (see the
174
- *References* section above) and braindecode:
175
 
176
  ```bibtex
177
  @article{aristimunha2025braindecode,
 
14
 
15
  # SleepStagerBlanco2020
16
 
17
+ Sleep staging architecture from Blanco et al (2020) from [Blanco2020]
18
 
19
+ > **Architecture-only repository.** Documents the
20
  > `braindecode.models.SleepStagerBlanco2020` class. **No pretrained weights are
21
+ > distributed here.** Instantiate the model and train it on your own
22
+ > data.
 
23
 
24
  ## Quick start
25
 
 
38
  )
39
  ```
40
 
41
+ The signal-shape arguments above are illustrative defaults — adjust to
42
+ match your recording.
43
 
44
  ## Documentation
45
+ - Full API reference: <https://braindecode.org/stable/generated/braindecode.models.SleepStagerBlanco2020.html>
46
+ - Interactive browser (live instantiation, parameter counts):
 
 
47
  <https://huggingface.co/spaces/braindecode/model-explorer>
48
  - Source on GitHub: <https://github.com/braindecode/braindecode/blob/master/braindecode/models/sleep_stager_blanco_2020.py#L11>
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ ## Architecture
 
52
 
53
+ ![SleepStagerBlanco2020 architecture](https://media.springernature.com/full/springer-static/image/art%3A10.1007%2Fs00500-019-04174-1/MediaObjects/500_2019_4174_Fig2_HTML.png)
54
 
 
 
55
 
56
+ ## Parameters
 
 
 
57
 
58
+ | Parameter | Type | Description |
59
+ |---|---|---|
60
+ | `n_conv_chans` | int | Number of convolutional channels. Set to 20 in [Blanco2020]. |
61
+ | `n_groups` | int | Number of groups for the convolution. Set to 2 in [Blanco2020] for 2 Channel EEG. controls the connections between inputs and outputs. n_channels and n_conv_chans must be divisible by n_groups. |
62
+ | `drop_prob` | float | Dropout rate before the output dense layer. |
63
+ | `apply_batch_norm` | bool | If True, apply batch normalization after both temporal convolutional layers. |
64
+ | `return_feats` | bool | If True, return the features, i.e. the output of the feature extractor (before the final linear layer). If False, pass the features through the final linear layer. |
65
+ | `n_channels` | int | Alias for `n_chans`. |
66
+ | `n_classes` | int | Alias for `n_outputs`. |
67
+ | `input_size_s` | float | Alias for `input_window_seconds`. |
68
+ | `activation: nn.Module, default=nn.ReLU` | — | Activation function class to apply. Should be a PyTorch activation module class like `nn.ReLU` or `nn.ELU`. Default is `nn.ReLU`. |
69
 
 
70
 
71
+ ## References
 
72
 
73
+ 1. Fernandez-Blanco, E., Rivero, D. & Pazos, A. Convolutional neural networks for sleep stage scoring on a two-channel EEG signal. Soft Comput 24, 4067–4079 (2020). https://doi.org/10.1007/s00500-019-04174-1
 
 
74
 
 
 
 
 
 
 
 
 
75
 
76
  ## Citation
77
 
78
+ Cite the original architecture paper (see *References* above) and braindecode:
 
79
 
80
  ```bibtex
81
  @article{aristimunha2025braindecode,