Braindecode 1.2.0.dev175267687__tar.gz → 1.2.0.dev176281713__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. {braindecode-1.2.0.dev175267687/braindecode.egg-info → braindecode-1.2.0.dev176281713}/PKG-INFO +2 -3
  2. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/__init__.py +7 -6
  3. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/atcnet.py +1 -1
  4. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/ctnet.py +1 -1
  5. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/deep4.py +2 -6
  6. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/deepsleepnet.py +5 -118
  7. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/eeginception_erp.py +7 -76
  8. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/eeginception_mi.py +0 -2
  9. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/eegnet.py +180 -17
  10. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/eegnex.py +8 -6
  11. braindecode-1.2.0.dev176281713/braindecode/models/eegresnet.py +362 -0
  12. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/eegsimpleconv.py +0 -2
  13. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/eegtcnet.py +1 -1
  14. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/sccnet.py +8 -79
  15. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/shallow_fbcsp.py +0 -2
  16. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/sleep_stager_blanco_2020.py +0 -2
  17. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/sleep_stager_chambon_2018.py +0 -2
  18. braindecode-1.2.0.dev175267687/braindecode/models/attn_sleep.py → braindecode-1.2.0.dev176281713/braindecode/models/sleep_stager_eldele_2021.py +2 -12
  19. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/sparcnet.py +0 -2
  20. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/summary.csv +9 -8
  21. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/tidnet.py +0 -2
  22. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/tsinception.py +3 -15
  23. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/usleep.py +9 -103
  24. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/util.py +4 -5
  25. braindecode-1.2.0.dev176281713/braindecode/version.py +1 -0
  26. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713/braindecode.egg-info}/PKG-INFO +2 -3
  27. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode.egg-info/SOURCES.txt +3 -11
  28. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode.egg-info/requires.txt +0 -1
  29. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/api.rst +4 -10
  30. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/conf.py +10 -17
  31. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/index.rst +2 -2
  32. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/models/models.rst +2 -4
  33. braindecode-1.2.0.dev176281713/docs/models/models_categorization.rst +174 -0
  34. braindecode-1.2.0.dev176281713/docs/models/models_table.rst +139 -0
  35. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/models/models_visualization.rst +0 -10
  36. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/sg_execution_times.rst +63 -66
  37. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/whats_new.rst +0 -1
  38. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/pyproject.toml +4 -6
  39. braindecode-1.2.0.dev175267687/braindecode/version.py +0 -1
  40. braindecode-1.2.0.dev175267687/docs/models/categorization/attention.rst +0 -31
  41. braindecode-1.2.0.dev175267687/docs/models/categorization/channel.rst +0 -31
  42. braindecode-1.2.0.dev175267687/docs/models/categorization/convolution.rst +0 -33
  43. braindecode-1.2.0.dev175267687/docs/models/categorization/filterbank.rst +0 -31
  44. braindecode-1.2.0.dev175267687/docs/models/categorization/gnn.rst +0 -30
  45. braindecode-1.2.0.dev175267687/docs/models/categorization/interpretable.rst +0 -31
  46. braindecode-1.2.0.dev175267687/docs/models/categorization/llm.rst +0 -31
  47. braindecode-1.2.0.dev175267687/docs/models/categorization/recurrent.rst +0 -31
  48. braindecode-1.2.0.dev175267687/docs/models/categorization/spd.rst +0 -31
  49. braindecode-1.2.0.dev175267687/docs/models/models_categorization.rst +0 -201
  50. braindecode-1.2.0.dev175267687/docs/models/models_table.rst +0 -191
  51. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/LICENSE.txt +0 -0
  52. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/MANIFEST.in +0 -0
  53. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/NOTICE.txt +0 -0
  54. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/README.rst +0 -0
  55. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/__init__.py +0 -0
  56. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/augmentation/__init__.py +0 -0
  57. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/augmentation/base.py +0 -0
  58. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/augmentation/functional.py +0 -0
  59. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/augmentation/transforms.py +0 -0
  60. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/classifier.py +0 -0
  61. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/__init__.py +0 -0
  62. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/base.py +0 -0
  63. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/bbci.py +0 -0
  64. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/bcicomp.py +0 -0
  65. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/bids.py +0 -0
  66. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/experimental.py +0 -0
  67. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/mne.py +0 -0
  68. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/moabb.py +0 -0
  69. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/nmt.py +0 -0
  70. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
  71. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/sleep_physionet.py +0 -0
  72. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/tuh.py +0 -0
  73. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datasets/xy.py +0 -0
  74. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datautil/__init__.py +0 -0
  75. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datautil/serialization.py +0 -0
  76. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/datautil/util.py +0 -0
  77. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/eegneuralnet.py +0 -0
  78. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/functional/__init__.py +0 -0
  79. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/functional/functions.py +0 -0
  80. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/functional/initialization.py +0 -0
  81. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/attentionbasenet.py +0 -0
  82. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/base.py +0 -0
  83. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/biot.py +0 -0
  84. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/contrawr.py +0 -0
  85. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/eegconformer.py +0 -0
  86. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/eegitnet.py +0 -0
  87. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/eegminer.py +0 -0
  88. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/fbcnet.py +0 -0
  89. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/fblightconvnet.py +0 -0
  90. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/fbmsnet.py +0 -0
  91. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/hybrid.py +0 -0
  92. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/ifnet.py +0 -0
  93. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/labram.py +0 -0
  94. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/msvtnet.py +0 -0
  95. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/signal_jepa.py +0 -0
  96. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/sinc_shallow.py +0 -0
  97. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/syncnet.py +0 -0
  98. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/models/tcn.py +0 -0
  99. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/__init__.py +0 -0
  100. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/activation.py +0 -0
  101. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/attention.py +0 -0
  102. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/blocks.py +0 -0
  103. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/convolution.py +0 -0
  104. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/filter.py +0 -0
  105. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/layers.py +0 -0
  106. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/linear.py +0 -0
  107. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/parametrization.py +0 -0
  108. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/stats.py +0 -0
  109. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/util.py +0 -0
  110. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/modules/wrapper.py +0 -0
  111. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/preprocessing/__init__.py +0 -0
  112. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/preprocessing/mne_preprocess.py +0 -0
  113. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/preprocessing/preprocess.py +0 -0
  114. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/preprocessing/windowers.py +0 -0
  115. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/regressor.py +0 -0
  116. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/samplers/__init__.py +0 -0
  117. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/samplers/base.py +0 -0
  118. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/samplers/ssl.py +0 -0
  119. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/training/__init__.py +0 -0
  120. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/training/callbacks.py +0 -0
  121. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/training/losses.py +0 -0
  122. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/training/scoring.py +0 -0
  123. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/util.py +0 -0
  124. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/visualization/__init__.py +0 -0
  125. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/visualization/confusion_matrices.py +0 -0
  126. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode/visualization/gradients.py +0 -0
  127. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode.egg-info/dependency_links.txt +0 -0
  128. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/braindecode.egg-info/top_level.txt +0 -0
  129. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/Makefile +0 -0
  130. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/_templates/autosummary/class.rst +0 -0
  131. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/_templates/autosummary/function.rst +0 -0
  132. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/cite.rst +0 -0
  133. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/help.rst +0 -0
  134. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/install/install.rst +0 -0
  135. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/install/install_pip.rst +0 -0
  136. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/docs/install/install_source.rst +0 -0
  137. {braindecode-1.2.0.dev175267687 → braindecode-1.2.0.dev176281713}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 1.2.0.dev175267687
3
+ Version: 1.2.0.dev176281713
4
4
  Summary: Deep learning software to decode EEG, ECG or MEG signals
5
5
  Author-email: Robin Tibor Schirrmeister <robintibor@gmail.com>
6
6
  Maintainer-email: Alexandre Gramfort <agramfort@meta.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Robin Tibor Schirrmeister <robintibor@gmail.com>
@@ -17,7 +17,7 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
17
  Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
- Requires-Python: >=3.10
20
+ Requires-Python: >3.10
21
21
  Description-Content-Type: text/x-rst
22
22
  License-File: LICENSE.txt
23
23
  License-File: NOTICE.txt
@@ -52,7 +52,6 @@ Requires-Dist: sphinx_rtd_theme; extra == "docs"
52
52
  Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
53
53
  Requires-Dist: sphinx-autobuild; extra == "docs"
54
54
  Requires-Dist: sphinxcontrib-bibtex; extra == "docs"
55
- Requires-Dist: sphinx_sitemap; extra == "docs"
56
55
  Requires-Dist: pydata_sphinx_theme; extra == "docs"
57
56
  Requires-Dist: numpydoc; extra == "docs"
58
57
  Requires-Dist: memory_profiler; extra == "docs"
@@ -4,7 +4,6 @@ Some predefined network architectures for EEG decoding.
4
4
 
5
5
  from .atcnet import ATCNet
6
6
  from .attentionbasenet import AttentionBaseNet
7
- from .attn_sleep import AttnSleep
8
7
  from .base import EEGModuleMixin
9
8
  from .biot import BIOT
10
9
  from .contrawr import ContraWR
@@ -16,8 +15,9 @@ from .eeginception_erp import EEGInceptionERP
16
15
  from .eeginception_mi import EEGInceptionMI
17
16
  from .eegitnet import EEGITNet
18
17
  from .eegminer import EEGMiner
19
- from .eegnet import EEGNet, EEGNetv4
18
+ from .eegnet import EEGNetv4
20
19
  from .eegnex import EEGNeX
20
+ from .eegresnet import EEGResNet
21
21
  from .eegsimpleconv import EEGSimpleConv
22
22
  from .eegtcnet import EEGTCNet
23
23
  from .fbcnet import FBCNet
@@ -38,11 +38,12 @@ from .signal_jepa import (
38
38
  from .sinc_shallow import SincShallowNet
39
39
  from .sleep_stager_blanco_2020 import SleepStagerBlanco2020
40
40
  from .sleep_stager_chambon_2018 import SleepStagerChambon2018
41
+ from .sleep_stager_eldele_2021 import SleepStagerEldele2021
41
42
  from .sparcnet import SPARCNet
42
43
  from .syncnet import SyncNet
43
44
  from .tcn import BDTCN, TCN
44
45
  from .tidnet import TIDNet
45
- from .tsinception import TSception
46
+ from .tsinception import TSceptionV1
46
47
  from .usleep import USleep
47
48
  from .util import _init_models_dict, models_mandatory_parameters
48
49
 
@@ -52,7 +53,6 @@ _init_models_dict()
52
53
 
53
54
  __all__ = [
54
55
  "ATCNet",
55
- "AttnSleep",
56
56
  "AttentionBaseNet",
57
57
  "EEGModuleMixin",
58
58
  "BIOT",
@@ -65,9 +65,9 @@ __all__ = [
65
65
  "EEGInceptionMI",
66
66
  "EEGITNet",
67
67
  "EEGMiner",
68
- "EEGNet",
69
68
  "EEGNetv4",
70
69
  "EEGNeX",
70
+ "EEGResNet",
71
71
  "EEGSimpleConv",
72
72
  "EEGTCNet",
73
73
  "FBCNet",
@@ -86,12 +86,13 @@ __all__ = [
86
86
  "SincShallowNet",
87
87
  "SleepStagerBlanco2020",
88
88
  "SleepStagerChambon2018",
89
+ "SleepStagerEldele2021",
89
90
  "SPARCNet",
90
91
  "SyncNet",
91
92
  "BDTCN",
92
93
  "TCN",
93
94
  "TIDNet",
94
- "TSception",
95
+ "TSceptionV1",
95
96
  "USleep",
96
97
  "_init_models_dict",
97
98
  "models_mandatory_parameters",
@@ -138,7 +138,7 @@ class ATCNet(EEGModuleMixin, nn.Module):
138
138
  .. rubric:: Usage and Configuration
139
139
 
140
140
  - ``conv_block_n_filters (F1)``, ``conv_block_depth_mult (D)`` → capacity of the stem
141
- (with ``F2 = F1·D`` feeding attention/TCN), dimensions aligned to ``F2``, like :class:`EEGNet`.
141
+ (with ``F2 = F1·D`` feeding attention/TCN), dimensions aligned to ``F2``, like `EEGNetv4`.
142
142
  - Pool sizes ``P1,P2`` trade temporal resolution for stability/compute; they set
143
143
  ``T_c = T/(P1·P2)`` and thus window width ``T_w``.
144
144
  - ``n_windows`` controls the ensemble over shifts (compute ∝ windows).
@@ -39,7 +39,7 @@ class CTNet(EEGModuleMixin, nn.Module):
39
39
  The architecture consists of three main components:
40
40
 
41
41
  1. **Convolutional Module**:
42
- - Apply :class:`EEGNet` to perform some feature extraction, denoted here as
42
+ - Apply EEGNetV4 to perform some feature extraction, denoted here as
43
43
  _PatchEmbeddingEEGNet module.
44
44
 
45
45
  2. **Transformer Encoder Module**:
@@ -19,13 +19,9 @@ from braindecode.modules import (
19
19
  class Deep4Net(EEGModuleMixin, nn.Sequential):
20
20
  """Deep ConvNet model from Schirrmeister et al (2017) [Schirrmeister2017]_.
21
21
 
22
- :bdg-success:`Convolution`
23
-
24
- .. figure:: https://onlinelibrary.wiley.com/cms/asset/fc200ccc-d8c4-45b4-8577-56ce4d15999a/hbm23730-fig-0001-m.jpg
22
+ .. figure:: https://onlinelibrary.wiley.com/cms/asset/fc200ccc-d8c4-45b4-8577-56ce4d15999a/hbm23730-fig-0001-m.jpg
25
23
  :align: center
26
- :alt: Deep4Net Architecture
27
- :width: 600px
28
-
24
+ :alt: CTNet Architecture
29
25
 
30
26
  Model described in [Schirrmeister2017]_.
31
27
 
@@ -8,128 +8,14 @@ from braindecode.models.base import EEGModuleMixin
8
8
 
9
9
 
10
10
  class DeepSleepNet(EEGModuleMixin, nn.Module):
11
- """DeepSleepNet from Supratak et al. (2017) [Supratak2017]_.
11
+ """Sleep staging architecture from Supratak et al. (2017) [Supratak2017]_.
12
12
 
13
- :bdg-success:`Convolution` :bdg-info:`Recurrent`
14
-
15
- .. figure:: https://raw.githubusercontent.com/akaraspt/deepsleepnet/master/img/deepsleepnet.png
13
+ .. figure:: https://raw.githubusercontent.com/akaraspt/deepsleepnet/refs/heads/master/img/deepsleepnet.png
16
14
  :align: center
17
15
  :alt: DeepSleepNet Architecture
18
- :width: 700px
19
-
20
- .. rubric:: Architectural Overview
21
-
22
- DeepSleepNet couples **dual-path convolution neural network representation learning** with
23
- **sequence residual learning** via bidirectional LSTMs.
24
-
25
- The network have:
26
-
27
- - (i) learns complementary, time-frequency features from each
28
- 30-s epoch using **two parallel CNNs** (small vs. large first-layer filters), then
29
- - (ii) models **temporal dependencies across epochs** using **two-layer BiLSTMs**
30
- with a **residual shortcut** from the CNN features, and finally
31
- - (iii) outputs per-epoch sleep stages. This design encodes both
32
- epoch-local patterns and longer-range transition rules used by human scorers.
33
-
34
- In term of implementation:
35
-
36
- - (i) :class:`_RepresentationLearning` two CNNs extract epoch-wise features
37
- (small-filter path for temporal precision; large-filter path for frequency precision);
38
- - (ii) :class:`_SequenceResidualLearning` stacked BiLSTMs with peepholes + residual shortcut
39
- inject temporal context while preserving CNN evidence;
40
- - (iii) :class:`_Classifier` linear readout (softmax) for the five sleep stages.
41
-
42
- .. rubric:: Macro Components
43
-
44
- - :class:`_RepresentationLearning` **(dual-path CNN → epoch feature)**
45
-
46
- - *Operations.*
47
- - **Small-filter CNN** 4 times:
48
- - :class:`~torch.nn.Conv1d`
49
- - :class:`~torch.nn.BatchNorm1d`
50
- - :class:`~torch.nn.ReLU`
51
- - :class:`~torch.nn.MaxPool1d` after.
52
- First conv uses **filter length ≈ Fs/2** and **stride ≈ Fs/16** to emphasize *timing* of graphoelements.
53
- - **Large-filter CNN**:
54
- - Same stack but first conv uses **filter length ≈ 4·Fs** and
55
- - **stride ≈ Fs/2** to emphasize *frequency* content.
56
- - Outputs from both paths are **concatenated** into the epoch embedding ``a_t``.
57
-
58
- - *Rationale.*
59
- Two first-layer scales provide a **learned, dual-scale filter bank** that trades
60
- temporal vs. frequency precision without hand-crafted features.
61
-
62
- - :class:`_SequenceResidualLearning` (:class:`~torch.nn.BiLSTM` **context + residual fusion)**
63
-
64
- - *Operations.*
65
- - **Two-layer BiLSTM** with **peephole connections** processes the sequence of epoch embeddings
66
- ``{a_t}`` forward and backward; hidden states from both directions are **concatenated**.
67
- - A **shortcut MLP** (fully connected + :class:`~torch.nn.BatchNorm1d` + :class:`~torch.nn.ReLU`) projects ``a_t`` to the BiLSTM output
68
- dimension and is **added** (residual) to the :class:`~torch.nn.BiLSTM` output at each time step.
69
- - *Role.* Encodes **stage-transition rules** and smooths predictions over time while preserving
70
- salient CNN features via the residual path.
71
-
72
- - :class:`_Classifier` **(epoch-wise prediction)**
73
-
74
- - *Operations.*
75
- - :class:`~torch.nn.Linear` to produce per-epoch class probabilities.
76
16
 
77
- Original training uses two-step optimization: CNN pretraining on class-balanced data,
78
- then end-to-end fine-tuning with sequential batches.
79
-
80
- .. rubric:: Convolutional Details
81
-
82
- - **Temporal (where time-domain patterns are learned).**
83
-
84
- Both CNN paths use **1-D temporal convolutions**. The *small-filter* path (first kernel ≈ Fs/2,
85
- stride ≈ Fs/16) captures *when* characteristic transients occur; the *large-filter* path
86
- (first kernel ≈ 4·Fs, stride ≈ Fs/2) captures *which* frequency components dominate over the
87
- epoch. Deeper layers use **small kernels** to refine features with fewer parameters, interleaved
88
- with **max pooling** for downsampling.
89
-
90
- - **Spatial (how channels are processed).**
91
- The original model operates on **single-channel** raw EEG; convolutions therefore mix only
92
- along time (no spatial convolution across electrodes).
93
-
94
- - **Spectral (how frequency information emerges).**
95
- No explicit Fourier/wavelet transform is used. The **large-filter path** serves as a
96
- *frequency-sensitive* analyzer, while the **small-filter path** remains *time-sensitive*,
97
- together functioning as a **two-band learned filter bank** at the first layer.
98
-
99
- .. rubric:: Attention / Sequential Modules
100
-
101
- - **Type.** **Bidirectional LSTM** (two layers) with **peephole connections**; forward and
102
- backward streams are independent and concatenated.
103
- - **Shapes.** For a sequence of ``N`` epochs, the CNN produces ``{a_t} ∈ R^{D}``;
104
- BiLSTM outputs ``h_t ∈ R^{2H}``; the shortcut MLP maps ``a_t → R^{2H}`` to enable
105
- **element-wise residual addition**.
106
- - **Role.** Models **long-range temporal dependencies** (e.g., persisting N2 without visible
107
- K-complex/spindles), stabilizing per-epoch predictions.
108
-
109
-
110
- .. rubric:: Additional Mechanisms
111
-
112
- - **Residual shortcut over sequence encoder.** Adds projected CNN features to BiLSTM outputs,
113
- improving gradient flow and retaining discriminative content from representation learning.
114
- - **Two-step training.**
115
- - (i) **Pretrain** the CNN paths with class-balanced sampling;
116
- - (ii) **fine-tune** the full network with sequential batches, using **lower LR** for CNNs and **higher LR** for the
117
- sequence encoder.
118
- - **State handling.** BiLSTM states are **reinitialized per subject** so that temporal context
119
- does not leak across recordings.
120
-
121
-
122
- .. rubric:: Usage and Configuration
123
-
124
- - **Epoch pipeline.** Use **two parallel CNNs** with the first conv sized to **Fs/2** (small path)
125
- and **4·Fs** (large path), with strides **Fs/16** and **Fs/2**, respectively; stack three more
126
- conv blocks with small kernels, plus **max pooling** in each path. Concatenate path outputs
127
- to form epoch embeddings.
128
- - **Sequence encoder.** Apply **two-layer BiLSTM (peepholes)** over the sequence of embeddings;
129
- add a **projection MLP** on the CNN features and **sum** with BiLSTM outputs (residual).
130
- Finish with :class:`~torch.nn.Linear` per epoch.
131
- - **Reference implementation.** See the official repository for a faithful implementation and
132
- training scripts.
17
+ Convolutional neural network and bidirectional-Long Short-Term
18
+ for single channels sleep staging described in [Supratak2017]_.
133
19
 
134
20
  Parameters
135
21
  ----------
@@ -146,6 +32,7 @@ class DeepSleepNet(EEGModuleMixin, nn.Module):
146
32
  drop_prob : float, default=0.5
147
33
  The dropout rate for regularization. Values should be between 0 and 1.
148
34
 
35
+
149
36
  References
150
37
  ----------
151
38
  .. [Supratak2017] Supratak, A., Dong, H., Wu, C., & Guo, Y. (2017).
@@ -15,84 +15,12 @@ from braindecode.modules import DepthwiseConv2d, Ensure4d, InceptionBlock
15
15
  class EEGInceptionERP(EEGModuleMixin, nn.Sequential):
16
16
  """EEG Inception for ERP-based from Santamaria-Vazquez et al (2020) [santamaria2020]_.
17
17
 
18
- :bdg-success:`Convolution`
19
-
20
18
  .. figure:: https://braindecode.org/dev/_static/model/eeginceptionerp.jpg
21
19
  :align: center
22
20
  :alt: EEGInceptionERP Architecture
23
21
 
24
- Figure: Overview of EEG-Inception architecture. 2D convolution blocks and depthwise 2D convolution blocks include batch normalization, activation and dropout regularization. The kernel size is displayed for convolutional and average pooling layers.
25
-
26
- .. rubric:: Architectural Overview
27
-
28
- A two-stage, multi-scale CNN tailored to ERP detection from short (0-1000 ms) single-trial epochs. Signals are mapped through
29
- * (i) :class:`_InceptionModule1` multi-scale temporal feature extraction plus per-branch spatial mixing;
30
- * (ii) :class:`_InceptionModule2` deeper multi-scale refinement at a reduced temporal resolution; and
31
- * (iii) :class:`_OutputModule` compact aggregation and linear readout.
32
-
33
- .. rubric:: Macro Components
34
-
35
- - :class:`_InceptionModule1` **(multi-scale temporal + spatial mixing)**
36
-
37
- - *Operations.*
38
- - `EEGInceptionERP.c1`: :class:`torch.nn.Conv2d` ``k=(64,1)``, stride ``(1,1)``, *same* pad on input reshaped to ``(B,1,128,8)`` → BN → activation → dropout.
39
- - `EEGInceptionERP.d1`: :class:`torch.nn.Conv2d` (depthwise) ``k=(1,8)``, *valid* pad over channels → BN → activation → dropout.
40
- - `EEGInceptionERP.c2`: :class:`torch.nn.Conv2d` ``k=(32,1)`` → BN → activation → dropout; then `EEGInceptionERP.d2` depthwise ``k=(1,8)`` → BN → activation → dropout.
41
- - `EEGInceptionERP.c3`: :class:`torch.nn.Conv2d` ``k=(16,1)`` → BN → activation → dropout; then `EEGInceptionERP.d3` depthwise ``k=(1,8)`` → BN → activation → dropout.
42
- - `EEGInceptionERP.n1`: :class:`torch.nn.Concat` over branch features.
43
- - `EEGInceptionERP.a1`: :class:`torch.nn.AvgPool2d` ``pool=(4,1)``, stride ``(4,1)`` for temporal downsampling.
44
-
45
- *Interpretability/robustness.* Depthwise `1 x n_chans` layers act as learnable montage-wide spatial filters per temporal scale; pooling stabilizes against jitter.
46
-
47
- - :class:`_InceptionModule2` **(refinement at coarser timebase)**
48
-
49
- - *Operations.*
50
- - `EEGInceptionERP.c4`: :class:`torch.nn.Conv2d` ``k=(16,1)`` → BN → activation → dropout.
51
- - `EEGInceptionERP.c5`: :class:`torch.nn.Conv2d` ``k=(8,1)`` → BN → activation → dropout.
52
- - `EEGInceptionERP.c6`: :class:`torch.nn.Conv2d` ``k=(4,1)`` → BN → activation → dropout.
53
- - `EEGInceptionERP.n2`: :class:`torch.nn.Concat` (merge C4-C6 outputs).
54
- - `EEGInceptionERP.a2`: :class:`torch.nn.AvgPool2d` ``pool=(2,1)``, stride ``(2,1)``.
55
- - `EEGInceptionERP.c7`: :class:`torch.nn.Conv2d` ``k=(8,1)`` → BN → activation → dropout; then `EEGInceptionERP.a3`: :class:`torch.nn.AvgPool2d` ``pool=(2,1)``.
56
- - `EEGInceptionERP.c8`: :class:`torch.nn.Conv2d` ``k=(4,1)`` → BN → activation → dropout; then `EEGInceptionERP.a4`: :class:`torch.nn.AvgPool2d` ``pool=(2,1)``.
57
-
58
- *Role.* Adds higher-level, shorter-window evidence while progressively compressing temporal dimension.
59
-
60
- - :class:`_OutputModule` **(aggregation + readout)**
61
-
62
- - *Operations.*
63
- - :class:`torch.nn.Flatten`
64
- - :class:`torch.nn.Linear` ``(features → 2)``
65
-
66
- .. rubric:: Convolutional Details
67
-
68
- - **Temporal (where time-domain patterns are learned).**
69
- First module uses 1D temporal kernels along the 128-sample axis: ``64``, ``32``, ``16``
70
- (≈500, 250, 125 ms at 128 Hz). After ``pool=(4,1)``, the second module applies ``16``,
71
- ``8``, ``4`` (≈125, 62.5, 31.25 ms at the pooled rate). All strides are ``1`` in convs;
72
- temporal resolution changes only via average pooling.
73
-
74
- - **Spatial (how electrodes are processed).**
75
- Depthwise convs with ``k=(1,8)`` span all channels and are applied **per temporal branch**,
76
- yielding scale-specific channel projections (no cross-branch mixing until concatenation).
77
- There is no full 2D mixing kernel; spatial mixing is factorized and lightweight.
78
-
79
- - **Spectral (how frequency information is captured).**
80
- No explicit transform; multiple temporal kernels form a *learned filter bank* over
81
- ERP-relevant bands. Successive pooling acts as low-pass integration to emphasize sustained
82
- post-stimulus components.
83
-
84
- .. rubric:: Additional Mechanisms
85
-
86
- - Every conv/depthwise block includes **BatchNorm**, nonlinearity (paper used grid-searched activation), and **dropout**.
87
- - Two Inception stages followed by short convs and pooling keep parameters small (≈15k reported) while preserving multi-scale evidence.
88
- - Expected input: epochs of shape ``(B,1,128,8)`` (time x channels as a 2D map) or reshaped from ``(B,8,128)`` with an added singleton feature dimension.
89
-
90
- .. rubric:: Usage and Configuration
91
-
92
- - **Key knobs.** Number of filters per branch; kernel lengths in both Inception modules; depthwise kernel over channels (typically ``n_chans``); pooling lengths/strides; dropout rate; choice of activation.
93
- - **Training tips.** Use 0-1000 ms windows at 128 Hz with CAR; tune activation and dropout (they strongly affect performance); early-stop on validation loss when overfitting emerges.
94
-
95
- .. rubric:: Implementation Details
22
+ The code for the paper and this model is also available at [santamaria2020]_
23
+ and an adaptation for PyTorch [2]_.
96
24
 
97
25
  The model is strongly based on the original InceptionNet for an image. The main goal is
98
26
  to extract features in parallel with different scales. The authors extracted three scales
@@ -105,9 +33,12 @@ class EEGInceptionERP(EEGModuleMixin, nn.Sequential):
105
33
  The winners of BEETL Competition/NeurIps 2021 used parts of the
106
34
  model [beetl]_.
107
35
 
108
- The code for the paper and this model is also available at [santamaria2020]_
109
- and an adaptation for PyTorch [2]_.
36
+ The model is fully described in [santamaria2020]_.
110
37
 
38
+ Notes
39
+ -----
40
+ This implementation is not guaranteed to be correct, has not been checked
41
+ by original authors, only reimplemented from the paper based on [2]_.
111
42
 
112
43
  Parameters
113
44
  ----------
@@ -13,8 +13,6 @@ from braindecode.modules import Ensure4d
13
13
  class EEGInceptionMI(EEGModuleMixin, nn.Module):
14
14
  """EEG Inception for Motor Imagery, as proposed in Zhang et al. (2021) [1]_
15
15
 
16
- :bdg-success:`Convolution`
17
-
18
16
  .. figure:: https://content.cld.iop.org/journals/1741-2552/18/4/046014/revision3/jneabed81f1_hr.jpg
19
17
  :align: center
20
18
  :alt: EEGInceptionMI Architecture
@@ -6,7 +6,7 @@ from __future__ import annotations
6
6
  from typing import Dict, Optional
7
7
 
8
8
  from einops.layers.torch import Rearrange
9
- from mne.utils import deprecated, warn
9
+ from mne.utils import warn
10
10
  from torch import nn
11
11
 
12
12
  from braindecode.functional import glorot_weight_zero_bias
@@ -19,21 +19,22 @@ from braindecode.modules import (
19
19
  )
20
20
 
21
21
 
22
- class EEGNet(EEGModuleMixin, nn.Sequential):
23
- """EEGNet model from Lawhern et al. (2018) [Lawhern2018]_.
22
+ class EEGNetv4(EEGModuleMixin, nn.Sequential):
23
+ """EEGNet v4 model from Lawhern et al. (2018) [Lawhern2018]_.
24
+
25
+ :bdg-success:`Convolution` :bdg-secondary:`Depthwise–Separable`
24
26
 
25
- :bdg-success:`Convolution`
26
27
  .. figure:: https://content.cld.iop.org/journals/1741-2552/15/5/056013/revision2/jneaace8cf01_hr.jpg
27
28
  :align: center
28
- :alt: EEGNet Architecture
29
+ :alt: EEGNetv4 Architecture
29
30
  :width: 600px
30
31
 
31
32
  .. rubric:: Architectural Overview
32
33
 
33
- EEGNet is a compact convolutional network designed for EEG decoding with a pipeline that mirrors classical EEG processing:
34
+ EEGNetv4 is a compact convolutional network designed for EEG decoding with a pipeline that mirrors classical EEG processing:
34
35
  - (i) learn temporal frequency-selective filters,
35
36
  - (ii) learn spatial filters for those frequencies, and
36
- - (iii) condense features with depthwise-separable convolutions before a lightweight classifier.
37
+ - (iii) condense features with depthwise–separable convolutions before a lightweight classifier.
37
38
 
38
39
  The architecture is deliberately small (temporal convolutional and spatial patterns) [Lawhern2018]_.
39
40
 
@@ -44,9 +45,9 @@ class EEGNet(EEGModuleMixin, nn.Sequential):
44
45
  - **Depthwise Spatial Filtering.**
45
46
  Depthwise convolution spanning the channel dimension with ``groups = F1``,
46
47
  yielding ``D`` spatial filters for each temporal filter (no cross-filter mixing).
47
- - **Norm-Nonlinearity-Pooling (+ dropout).**
48
+ - **Norm–Nonlinearity–Pooling (+ dropout).**
48
49
  Batch normalization → ELU → temporal pooling, with dropout.
49
- - **Depthwise-Separable Convolution Block.**
50
+ - **Depthwise–Separable Convolution Block.**
50
51
  (a) depthwise temporal conv to refine temporal structure;
51
52
  (b) pointwise 1x1 conv to mix feature maps into ``F2`` combinations.
52
53
  - **Classifier Head.**
@@ -72,8 +73,6 @@ class EEGNet(EEGModuleMixin, nn.Sequential):
72
73
  - **Depthwise & separable convs:** Parameter-efficient decomposition (depthwise + pointwise) retains power while limiting overfitting
73
74
  [Chollet2017]_ and keeps temporal vs. mixing steps interpretable.
74
75
  - **Regularization:** Batch norm, dropout, pooling, and optional max-norm on spatial kernels aid stability on small EEG datasets.
75
- - The v4 means the version 4 at the arxiv paper [Lawhern2018]_.
76
-
77
76
 
78
77
  Parameters
79
78
  ----------
@@ -349,10 +348,174 @@ class EEGNet(EEGModuleMixin, nn.Sequential):
349
348
  glorot_weight_zero_bias(self)
350
349
 
351
350
 
352
- @deprecated(
353
- "`EEGNetv4` was renamed to `EEGNet` in v1.12; this alias will be removed in v1.14."
354
- )
355
- class EEGNetv4(EEGNet):
356
- """Deprecated alias for EEGNet."""
351
+ class EEGNetv1(EEGModuleMixin, nn.Sequential):
352
+ """EEGNet model from Lawhern et al. 2016 from [EEGNet]_.
353
+
354
+ See details in [EEGNet]_.
355
+
356
+ Parameters
357
+ ----------
358
+ in_chans :
359
+ Alias for n_chans.
360
+ n_classes:
361
+ Alias for n_outputs.
362
+ input_window_samples :
363
+ Alias for n_times.
364
+ activation: nn.Module, default=nn.ELU
365
+ Activation function class to apply. Should be a PyTorch activation
366
+ module class like ``nn.ReLU`` or ``nn.ELU``. Default is ``nn.ELU``.
367
+
368
+ Notes
369
+ -----
370
+ This implementation is not guaranteed to be correct, has not been checked
371
+ by original authors, only reimplemented from the paper description.
372
+
373
+ References
374
+ ----------
375
+ .. [EEGNet] Lawhern, V. J., Solon, A. J., Waytowich, N. R., Gordon,
376
+ S. M., Hung, C. P., & Lance, B. J. (2016).
377
+ EEGNet: A Compact Convolutional Network for EEG-based
378
+ Brain-Computer Interfaces.
379
+ arXiv preprint arXiv:1611.08024.
380
+ """
381
+
382
+ def __init__(
383
+ self,
384
+ n_chans=None,
385
+ n_outputs=None,
386
+ n_times=None,
387
+ final_conv_length="auto",
388
+ pool_mode="max",
389
+ second_kernel_size=(2, 32),
390
+ third_kernel_size=(8, 4),
391
+ drop_prob=0.25,
392
+ activation: nn.Module = nn.ELU,
393
+ chs_info=None,
394
+ input_window_seconds=None,
395
+ sfreq=None,
396
+ ):
397
+ super().__init__(
398
+ n_outputs=n_outputs,
399
+ n_chans=n_chans,
400
+ chs_info=chs_info,
401
+ n_times=n_times,
402
+ input_window_seconds=input_window_seconds,
403
+ sfreq=sfreq,
404
+ )
405
+ del n_outputs, n_chans, chs_info, n_times, input_window_seconds, sfreq
406
+ warn(
407
+ "The class EEGNetv1 is deprecated and will be removed in the "
408
+ "release 1.0 of braindecode. Please use "
409
+ "braindecode.models.EEGNetv4 instead in the future.",
410
+ DeprecationWarning,
411
+ )
412
+ if final_conv_length == "auto":
413
+ assert self.n_times is not None
414
+ self.final_conv_length = final_conv_length
415
+ self.pool_mode = pool_mode
416
+ self.second_kernel_size = second_kernel_size
417
+ self.third_kernel_size = third_kernel_size
418
+ self.drop_prob = drop_prob
419
+ # For the load_state_dict
420
+ # When padronize all layers,
421
+ # add the old's parameters here
422
+ self.mapping = {
423
+ "conv_classifier.weight": "final_layer.conv_classifier.weight",
424
+ "conv_classifier.bias": "final_layer.conv_classifier.bias",
425
+ }
426
+
427
+ pool_class = dict(max=nn.MaxPool2d, mean=nn.AvgPool2d)[self.pool_mode]
428
+ self.add_module("ensuredims", Ensure4d())
429
+ n_filters_1 = 16
430
+ self.add_module(
431
+ "conv_1",
432
+ nn.Conv2d(self.n_chans, n_filters_1, (1, 1), stride=1, bias=True),
433
+ )
434
+ self.add_module(
435
+ "bnorm_1",
436
+ nn.BatchNorm2d(n_filters_1, momentum=0.01, affine=True, eps=1e-3),
437
+ )
438
+ self.add_module("elu_1", activation())
439
+ # transpose to examples x 1 x (virtual, not EEG) channels x time
440
+ self.add_module("permute_1", Rearrange("batch x y z -> batch z x y"))
441
+
442
+ self.add_module("drop_1", nn.Dropout(p=self.drop_prob))
357
443
 
358
- pass
444
+ n_filters_2 = 4
445
+ # keras pads unequal padding more in front, so padding
446
+ # too large should be ok.
447
+ # Not padding in time so that cropped training makes sense
448
+ # https://stackoverflow.com/questions/43994604/padding-with-even-kernel-size-in-a-convolutional-layer-in-keras-theano
449
+
450
+ self.add_module(
451
+ "conv_2",
452
+ nn.Conv2d(
453
+ 1,
454
+ n_filters_2,
455
+ self.second_kernel_size,
456
+ stride=1,
457
+ padding=(self.second_kernel_size[0] // 2, 0),
458
+ bias=True,
459
+ ),
460
+ )
461
+ self.add_module(
462
+ "bnorm_2",
463
+ nn.BatchNorm2d(n_filters_2, momentum=0.01, affine=True, eps=1e-3),
464
+ )
465
+ self.add_module("elu_2", activation())
466
+ self.add_module("pool_2", pool_class(kernel_size=(2, 4), stride=(2, 4)))
467
+ self.add_module("drop_2", nn.Dropout(p=self.drop_prob))
468
+
469
+ n_filters_3 = 4
470
+ self.add_module(
471
+ "conv_3",
472
+ nn.Conv2d(
473
+ n_filters_2,
474
+ n_filters_3,
475
+ self.third_kernel_size,
476
+ stride=1,
477
+ padding=(self.third_kernel_size[0] // 2, 0),
478
+ bias=True,
479
+ ),
480
+ )
481
+ self.add_module(
482
+ "bnorm_3",
483
+ nn.BatchNorm2d(n_filters_3, momentum=0.01, affine=True, eps=1e-3),
484
+ )
485
+ self.add_module("elu_3", activation())
486
+ self.add_module("pool_3", pool_class(kernel_size=(2, 4), stride=(2, 4)))
487
+ self.add_module("drop_3", nn.Dropout(p=self.drop_prob))
488
+
489
+ output_shape = self.get_output_shape()
490
+ n_out_virtual_chans = output_shape[2]
491
+
492
+ if self.final_conv_length == "auto":
493
+ n_out_time = output_shape[3]
494
+ self.final_conv_length = n_out_time
495
+
496
+ # Incorporating classification module and subsequent ones in one final layer
497
+ module = nn.Sequential()
498
+
499
+ module.add_module(
500
+ "conv_classifier",
501
+ nn.Conv2d(
502
+ n_filters_3,
503
+ self.n_outputs,
504
+ (n_out_virtual_chans, self.final_conv_length),
505
+ bias=True,
506
+ ),
507
+ )
508
+
509
+ # Transpose back to the logic of braindecode,
510
+
511
+ # so time in third dimension (axis=2)
512
+ module.add_module(
513
+ "permute_2",
514
+ Rearrange("batch x y z -> batch x z y"),
515
+ )
516
+
517
+ module.add_module("squeeze", SqueezeFinalOutput())
518
+
519
+ self.add_module("final_layer", module)
520
+
521
+ glorot_weight_zero_bias(self)
@@ -51,8 +51,8 @@ class EEGNeX(EEGModuleMixin, nn.Module):
51
51
  - :class:`torch.nn.BatchNorm2d` (no nonlinearity until Block-3, mirroring a linear FIR analysis stage).
52
52
  These layers set up frequency-selective detectors before spatial mixing.
53
53
 
54
- - *Interpretability.* Kernels can be inspected as FIR filters; two stacked temporal
55
- convs allow longer effective kernels without parameter blow-up.
54
+ - *Interpretability.* Kernels can be inspected as FIR filters; two stacked temporal
55
+ convs allow longer effective kernels without parameter blow-up.
56
56
 
57
57
  - **Block-3 — Spatial projection + condensation.**
58
58
 
@@ -64,7 +64,7 @@ class EEGNeX(EEGModuleMixin, nn.Module):
64
64
  - :class:`torch.nn.AvgPool2d` (time)
65
65
  - :class:`torch.nn.Dropout`.
66
66
 
67
- **Role**: Learns per-filter spatial patterns over the **full montage** while temporal
67
+ *Role.* Learns per-filter spatial patterns over the **full montage** while temporal
68
68
  pooling stabilizes and compresses features; max-norm encourages well-behaved spatial
69
69
  weights similar to EEGNet practice.
70
70
 
@@ -72,15 +72,15 @@ class EEGNeX(EEGModuleMixin, nn.Module):
72
72
 
73
73
  - *Operations.*
74
74
  - :class:`torch.nn.Conv2d` with kernels ``(1, k)`` and **dilations**
75
- (e.g., 2 then 4);
75
+ (e.g., 2 then 4);
76
76
  - :class:`torch.nn.BatchNorm2d`
77
77
  - :class:`torch.nn.ELU`
78
78
  - :class:`torch.nn.AvgPool2d` (time)
79
79
  - :class:`torch.nn.Dropout`
80
80
  - :class:`torch.nn.Flatten`.
81
81
 
82
- **Role**: Expands the temporal receptive field efficiently to capture rhythms and
83
- long-range context after condensation.
82
+ *Role.* Expands the temporal receptive field efficiently to capture rhythms and
83
+ long-range context after condensation.
84
84
 
85
85
  - **Final Classifier — Max-norm linear.**
86
86
 
@@ -125,6 +125,8 @@ class EEGNeX(EEGModuleMixin, nn.Module):
125
125
  classifier layers; prefer ELU activations for stable training on small EEG datasets.
126
126
 
127
127
 
128
+ Notes
129
+ -----
128
130
  - The braindecode implementation follows the paper's conv-only design with five blocks
129
131
  and reproduces the depthwise spatial step and dilated temporal stack. See the class
130
132
  reference for exact kernel sizes, dilations, and pooling defaults. You can check the