Replace with clean markdown card
Browse files
README.md
CHANGED
|
@@ -13,13 +13,12 @@ tags:
|
|
| 13 |
|
| 14 |
# EEGMiner
|
| 15 |
|
| 16 |
-
EEGMiner from Ludwig et al (2024) .
|
| 17 |
|
| 18 |
-
> **Architecture-only repository.**
|
| 19 |
> `braindecode.models.EEGMiner` class. **No pretrained weights are
|
| 20 |
-
> distributed here**
|
| 21 |
-
> data
|
| 22 |
-
> separately.
|
| 23 |
|
| 24 |
## Quick start
|
| 25 |
|
|
@@ -38,174 +37,42 @@ model = EEGMiner(
|
|
| 38 |
)
|
| 39 |
```
|
| 40 |
|
| 41 |
-
The signal-shape arguments above are
|
| 42 |
-
|
| 43 |
|
| 44 |
## Documentation
|
| 45 |
-
|
| 46 |
-
-
|
| 47 |
-
<https://braindecode.org/stable/generated/braindecode.models.EEGMiner.html>
|
| 48 |
-
- Interactive browser with live instantiation:
|
| 49 |
<https://huggingface.co/spaces/braindecode/model-explorer>
|
| 50 |
- Source on GitHub: <https://github.com/braindecode/braindecode/blob/master/braindecode/models/eegminer.py#L21>
|
| 51 |
|
| 52 |
-
## Architecture description
|
| 53 |
-
|
| 54 |
-
The block below is the rendered class docstring (parameters,
|
| 55 |
-
references, architecture figure where available).
|
| 56 |
-
|
| 57 |
-
<div class='bd-doc'><main>
|
| 58 |
-
<p>EEGMiner from Ludwig et al (2024) [eegminer]_.</p>
|
| 59 |
-
<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><span style="display:inline-block;padding:2px 8px;border-radius:4px;background:#E69F00;color:white;font-size:11px;font-weight:600;margin-right:4px;">Interpretability</span>
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
.. figure:: https://content.cld.iop.org/journals/1741-2552/21/3/036010/revision2/jnead44d7f1_hr.jpg
|
| 64 |
-
:align: center
|
| 65 |
-
:alt: EEGMiner Architecture
|
| 66 |
-
|
| 67 |
-
EEGMiner is a neural network model for EEG signal classification using
|
| 68 |
-
learnable generalized Gaussian filters. The model leverages frequency domain
|
| 69 |
-
filtering and connectivity metrics or feature extraction, such as Phase Locking
|
| 70 |
-
Value (PLV) to extract meaningful features from EEG data, enabling effective
|
| 71 |
-
classification tasks.
|
| 72 |
-
|
| 73 |
-
The model has the following steps:
|
| 74 |
-
|
| 75 |
-
- **Generalized Gaussian** filters in the frequency domain to the input EEG signals.
|
| 76 |
-
|
| 77 |
-
- **Connectivity estimators** (corr, plv) or **Electrode-Wise Band Power** (mag), by default (plv).
|
| 78 |
-
- `'corr'`: Computes the correlation of the filtered signals.
|
| 79 |
-
- `'plv'`: Computes the phase locking value of the filtered signals.
|
| 80 |
-
- `'mag'`: Computes the magnitude of the filtered signals.
|
| 81 |
-
|
| 82 |
-
- **Feature Normalization**
|
| 83 |
-
- Apply batch normalization.
|
| 84 |
-
|
| 85 |
-
- **Final Layer**
|
| 86 |
-
- Feeds the batch-normalized features into a final linear layer for classification.
|
| 87 |
-
|
| 88 |
-
Depending on the selected method (`mag`, `corr`, or `plv`),
|
| 89 |
-
it computes the filtered signals' magnitude, correlation, or phase locking value.
|
| 90 |
-
These features are then normalized and passed through a batch normalization layer
|
| 91 |
-
before being fed into a final linear layer for classification.
|
| 92 |
-
|
| 93 |
-
The input to EEGMiner should be a three-dimensional tensor representing EEG signals:
|
| 94 |
-
|
| 95 |
-
``(batch_size, n_channels, n_timesteps)``.
|
| 96 |
-
|
| 97 |
-
Notes
|
| 98 |
-
-----
|
| 99 |
-
EEGMiner incorporates learnable parameters for filter characteristics, allowing the
|
| 100 |
-
model to adaptively learn optimal frequency bands and phase delays for the classification task.
|
| 101 |
-
By default, using the PLV as a connectivity metric makes EEGMiner suitable for tasks requiring
|
| 102 |
-
the analysis of phase relationships between different EEG channels.
|
| 103 |
-
|
| 104 |
-
The model and the module have patent [eegminercode]_, and the code is CC BY-NC 4.0.
|
| 105 |
-
|
| 106 |
-
.. versionadded:: 0.9
|
| 107 |
-
|
| 108 |
-
Parameters
|
| 109 |
-
----------
|
| 110 |
-
method : str, default="plv"
|
| 111 |
-
The method used for feature extraction. Options are:
|
| 112 |
-
- "mag": Electrode-Wise band power of the filtered signals.
|
| 113 |
-
- "corr": Correlation between filtered channels.
|
| 114 |
-
- "plv": Phase Locking Value connectivity metric.
|
| 115 |
-
filter_f_mean : list of float, default=[23.0, 23.0]
|
| 116 |
-
Mean frequencies for the generalized Gaussian filters.
|
| 117 |
-
filter_bandwidth : list of float, default=[44.0, 44.0]
|
| 118 |
-
Bandwidths for the generalized Gaussian filters.
|
| 119 |
-
filter_shape : list of float, default=[2.0, 2.0]
|
| 120 |
-
Shape parameters for the generalized Gaussian filters.
|
| 121 |
-
group_delay : tuple of float, default=(20.0, 20.0)
|
| 122 |
-
Group delay values for the filters in milliseconds.
|
| 123 |
-
clamp_f_mean : tuple of float, default=(1.0, 45.0)
|
| 124 |
-
Clamping range for the mean frequency parameters.
|
| 125 |
-
|
| 126 |
-
References
|
| 127 |
-
----------
|
| 128 |
-
.. [eegminer] Ludwig, S., Bakas, S., Adamos, D. A., Laskaris, N., Panagakis,
|
| 129 |
-
Y., & Zafeiriou, S. (2024). EEGMiner: discovering interpretable features
|
| 130 |
-
of brain activity with learnable filters. Journal of Neural Engineering,
|
| 131 |
-
21(3), 036010.
|
| 132 |
-
.. [eegminercode] Ludwig, S., Bakas, S., Adamos, D. A., Laskaris, N., Panagakis,
|
| 133 |
-
Y., & Zafeiriou, S. (2024). EEGMiner: discovering interpretable features
|
| 134 |
-
of brain activity with learnable filters.
|
| 135 |
-
https://github.com/SMLudwig/EEGminer/.
|
| 136 |
-
Cogitat, Ltd. "Learnable filters for EEG classification."
|
| 137 |
-
Patent GB2609265.
|
| 138 |
-
https://www.ipo.gov.uk/p-ipsum/Case/ApplicationNumber/GB2113420.0
|
| 139 |
-
|
| 140 |
-
.. rubric:: Hugging Face Hub integration
|
| 141 |
-
|
| 142 |
-
When the optional ``huggingface_hub`` package is installed, all models
|
| 143 |
-
automatically gain the ability to be pushed to and loaded from the
|
| 144 |
-
Hugging Face Hub. Install with::
|
| 145 |
-
|
| 146 |
-
pip install braindecode[hub]
|
| 147 |
-
|
| 148 |
-
**Pushing a model to the Hub:**
|
| 149 |
-
|
| 150 |
-
.. code::
|
| 151 |
-
from braindecode.models import EEGMiner
|
| 152 |
-
|
| 153 |
-
# Train your model
|
| 154 |
-
model = EEGMiner(n_chans=22, n_outputs=4, n_times=1000)
|
| 155 |
-
# ... training code ...
|
| 156 |
-
|
| 157 |
-
# Push to the Hub
|
| 158 |
-
model.push_to_hub(
|
| 159 |
-
repo_id="username/my-eegminer-model",
|
| 160 |
-
commit_message="Initial model upload",
|
| 161 |
-
)
|
| 162 |
-
|
| 163 |
-
**Loading a model from the Hub:**
|
| 164 |
-
|
| 165 |
-
.. code::
|
| 166 |
-
from braindecode.models import EEGMiner
|
| 167 |
-
|
| 168 |
-
# Load pretrained model
|
| 169 |
-
model = EEGMiner.from_pretrained("username/my-eegminer-model")
|
| 170 |
-
|
| 171 |
-
# Load with a different number of outputs (head is rebuilt automatically)
|
| 172 |
-
model = EEGMiner.from_pretrained("username/my-eegminer-model", n_outputs=4)
|
| 173 |
|
| 174 |
-
|
| 175 |
|
| 176 |
-
..
|
| 177 |
-
import torch
|
| 178 |
|
| 179 |
-
x = torch.randn(1, model.n_chans, model.n_times)
|
| 180 |
-
# Extract encoder features (consistent dict across all models)
|
| 181 |
-
out = model(x, return_features=True)
|
| 182 |
-
features = out["features"]
|
| 183 |
|
| 184 |
-
|
| 185 |
-
model.reset_head(n_outputs=10)
|
| 186 |
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
-
.. code::
|
| 190 |
-
import json
|
| 191 |
|
| 192 |
-
|
| 193 |
-
with open("config.json", "w") as f:
|
| 194 |
-
json.dump(config, f)
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
All model parameters (both EEG-specific and model-specific such as
|
| 199 |
-
dropout rates, activation functions, number of filters) are automatically
|
| 200 |
-
saved to the Hub and restored when loading.
|
| 201 |
|
| 202 |
-
See :ref:`load-pretrained-models` for a complete tutorial.</main>
|
| 203 |
-
</div>
|
| 204 |
|
| 205 |
## Citation
|
| 206 |
|
| 207 |
-
|
| 208 |
-
*References* section above) and braindecode:
|
| 209 |
|
| 210 |
```bibtex
|
| 211 |
@article{aristimunha2025braindecode,
|
|
|
|
| 13 |
|
| 14 |
# EEGMiner
|
| 15 |
|
| 16 |
+
EEGMiner from Ludwig et al (2024) [eegminer].
|
| 17 |
|
| 18 |
+
> **Architecture-only repository.** Documents the
|
| 19 |
> `braindecode.models.EEGMiner` 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.EEGMiner.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/eegminer.py#L21>
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
## Architecture
|
| 51 |
|
| 52 |
+

|
|
|
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
## Parameters
|
|
|
|
| 56 |
|
| 57 |
+
| Parameter | Type | Description |
|
| 58 |
+
|---|---|---|
|
| 59 |
+
| `method` | str, default="plv" | The method used for feature extraction. Options are: - "mag": Electrode-Wise band power of the filtered signals. - "corr": Correlation between filtered channels. - "plv": Phase Locking Value connectivity metric. |
|
| 60 |
+
| `filter_f_mean` | list of float, default=[23.0, 23.0] | Mean frequencies for the generalized Gaussian filters. |
|
| 61 |
+
| `filter_bandwidth` | list of float, default=[44.0, 44.0] | Bandwidths for the generalized Gaussian filters. |
|
| 62 |
+
| `filter_shape` | list of float, default=[2.0, 2.0] | Shape parameters for the generalized Gaussian filters. |
|
| 63 |
+
| `group_delay` | tuple of float, default=(20.0, 20.0) | Group delay values for the filters in milliseconds. |
|
| 64 |
+
| `clamp_f_mean` | tuple of float, default=(1.0, 45.0) | Clamping range for the mean frequency parameters. |
|
| 65 |
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
## References
|
|
|
|
|
|
|
| 68 |
|
| 69 |
+
1. Ludwig, S., Bakas, S., Adamos, D. A., Laskaris, N., Panagakis, Y., & Zafeiriou, S. (2024). EEGMiner: discovering interpretable features of brain activity with learnable filters. Journal of Neural Engineering, 21(3), 036010.
|
| 70 |
+
2. Ludwig, S., Bakas, S., Adamos, D. A., Laskaris, N., Panagakis, Y., & Zafeiriou, S. (2024). EEGMiner: discovering interpretable features of brain activity with learnable filters. https://github.com/SMLudwig/EEGminer/. Cogitat, Ltd. "Learnable filters for EEG classification." Patent GB2609265. https://www.ipo.gov.uk/p-ipsum/Case/ApplicationNumber/GB2113420.0
|
|
|
|
|
|
|
|
|
|
| 71 |
|
|
|
|
|
|
|
| 72 |
|
| 73 |
## Citation
|
| 74 |
|
| 75 |
+
Cite the original architecture paper (see *References* above) and braindecode:
|
|
|
|
| 76 |
|
| 77 |
```bibtex
|
| 78 |
@article{aristimunha2025braindecode,
|