braindecode 2.1.0.dev184110306__tar.gz → 2.1.0.dev4294968686__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 (239) hide show
  1. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/NOTICE.txt +5 -0
  2. {braindecode-2.1.0.dev184110306/braindecode.egg-info → braindecode-2.1.0.dev4294968686}/PKG-INFO +1 -1
  3. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/__init__.py +1 -0
  4. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/base.py +8 -1
  5. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/brainomni.py +5 -4
  6. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/corteg.py +192 -127
  7. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegminer.py +14 -18
  8. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/fnirs4d.py +84 -175
  9. braindecode-2.1.0.dev4294968686/braindecode/models/fnirs_cnn1d.py +242 -0
  10. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/fnirs_t.py +84 -232
  11. braindecode-2.1.0.dev4294968686/braindecode/models/fnirsnet.py +261 -0
  12. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/luna.py +18 -6
  13. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/megxl.py +121 -79
  14. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/neurorvq.py +12 -4
  15. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/pratibha2.py +89 -115
  16. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/reve.py +1 -107
  17. braindecode-2.1.0.dev4294968686/braindecode/models/samba.py +806 -0
  18. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/signal_jepa.py +10 -23
  19. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/summary.csv +2 -1
  20. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/tfm_tokenizer.py +9 -43
  21. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/util.py +29 -4
  22. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/channels.py +104 -0
  23. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/spatial_temporal.py +21 -1
  24. braindecode-2.1.0.dev4294968686/braindecode/version.py +1 -0
  25. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686/braindecode.egg-info}/PKG-INFO +1 -1
  26. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode.egg-info/SOURCES.txt +1 -0
  27. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/api.rst +1 -0
  28. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/whats_new.rst +42 -31
  29. braindecode-2.1.0.dev184110306/braindecode/models/fnirs_cnn1d.py +0 -339
  30. braindecode-2.1.0.dev184110306/braindecode/models/fnirsnet.py +0 -374
  31. braindecode-2.1.0.dev184110306/braindecode/version.py +0 -1
  32. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/LICENSE.txt +0 -0
  33. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/MANIFEST.in +0 -0
  34. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/README.rst +0 -0
  35. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/__init__.py +0 -0
  36. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/augmentation/__init__.py +0 -0
  37. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/augmentation/base.py +0 -0
  38. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/augmentation/functional.py +0 -0
  39. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/augmentation/transforms.py +0 -0
  40. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/classifier.py +0 -0
  41. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/__init__.py +0 -0
  42. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/_notebook_viewer.py +0 -0
  43. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/base.py +0 -0
  44. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/bbci.py +0 -0
  45. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/bcicomp.py +0 -0
  46. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/bids/__init__.py +0 -0
  47. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/bids/datasets.py +0 -0
  48. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/bids/hub.py +0 -0
  49. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/bids/hub_format.py +0 -0
  50. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/bids/hub_io.py +0 -0
  51. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/bids/hub_validation.py +0 -0
  52. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/bids/iterable.py +0 -0
  53. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/chb_mit.py +0 -0
  54. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/collate.py +0 -0
  55. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/mne.py +0 -0
  56. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/moabb.py +0 -0
  57. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/nmt.py +0 -0
  58. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/registry.py +0 -0
  59. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/siena.py +0 -0
  60. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
  61. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/sleep_physionet.py +0 -0
  62. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/tuh.py +0 -0
  63. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/utils.py +0 -0
  64. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datasets/xy.py +0 -0
  65. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datautil/__init__.py +0 -0
  66. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datautil/channel_utils.py +0 -0
  67. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datautil/hub_formats.py +0 -0
  68. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datautil/serialization.py +0 -0
  69. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/datautil/util.py +0 -0
  70. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/eegneuralnet.py +0 -0
  71. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/functional/__init__.py +0 -0
  72. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/functional/_lfilter.py +0 -0
  73. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/functional/_real_dft.py +0 -0
  74. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/functional/attention.py +0 -0
  75. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/functional/channel_mask.py +0 -0
  76. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/functional/channels.py +0 -0
  77. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/functional/functions.py +0 -0
  78. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/functional/initialization.py +0 -0
  79. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/functional/patches.py +0 -0
  80. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/atcnet.py +0 -0
  81. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/attentionbasenet.py +0 -0
  82. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/attn_sleep.py +0 -0
  83. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/axon.py +0 -0
  84. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/barista.py +0 -0
  85. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/bbl.py +0 -0
  86. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/bendr.py +0 -0
  87. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/biot.py +0 -0
  88. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/brainbert.py +0 -0
  89. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/brainmodule.py +0 -0
  90. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/brant.py +0 -0
  91. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/caresleepnet.py +0 -0
  92. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/cbramod.py +0 -0
  93. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/codebrain.py +0 -0
  94. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/config.py +0 -0
  95. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/contrawr.py +0 -0
  96. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/csbrain.py +0 -0
  97. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/ctnet.py +0 -0
  98. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/dance.py +0 -0
  99. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/deep4.py +0 -0
  100. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/deepsleepnet.py +0 -0
  101. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/dgcnn.py +0 -0
  102. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/diver1.py +0 -0
  103. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/duin.py +0 -0
  104. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eeg_clip.py +0 -0
  105. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegconformer.py +0 -0
  106. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegdino.py +0 -0
  107. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eeginception_erp.py +0 -0
  108. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eeginception_mi.py +0 -0
  109. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegitnet.py +0 -0
  110. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegnet.py +0 -0
  111. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegnex.py +0 -0
  112. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegpt.py +0 -0
  113. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegsimpleconv.py +0 -0
  114. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegsym.py +0 -0
  115. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/eegtcnet.py +0 -0
  116. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/emg2qwerty.py +0 -0
  117. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/epint.py +0 -0
  118. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/fbcnet.py +0 -0
  119. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/fblightconvnet.py +0 -0
  120. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/fbmsnet.py +0 -0
  121. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/gcnsnet.py +0 -0
  122. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/geonirs.py +0 -0
  123. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/guetschel2026.py +0 -0
  124. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/hybrid.py +0 -0
  125. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/ifnet.py +0 -0
  126. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/jung_mae.py +0 -0
  127. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/labram.py +0 -0
  128. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/mapa.py +0 -0
  129. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/medformer.py +0 -0
  130. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/meggpt.py +0 -0
  131. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/meta_neuromotor.py +0 -0
  132. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/mirepnet.py +0 -0
  133. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/model.html.jinja +0 -0
  134. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/mscformer.py +0 -0
  135. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/msvtnet.py +0 -0
  136. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/mtrenirs.py +0 -0
  137. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/mvpformer.py +0 -0
  138. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/neuropose.py +0 -0
  139. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/neurorvq_tokenizer.py +0 -0
  140. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/nice.py +0 -0
  141. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/patchedtransformer.py +0 -0
  142. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/popt.py +0 -0
  143. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/sccnet.py +0 -0
  144. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/seizure_transformer.py +0 -0
  145. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/sensingdynamics.py +0 -0
  146. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/shallow_fbcsp.py +0 -0
  147. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/sinc_shallow.py +0 -0
  148. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
  149. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
  150. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/sleepfm.py +0 -0
  151. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/sparcnet.py +0 -0
  152. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/sstdpn.py +0 -0
  153. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/steegformer.py +0 -0
  154. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/syncnet.py +0 -0
  155. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/tccnet.py +0 -0
  156. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/tcformer.py +0 -0
  157. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/tcn.py +0 -0
  158. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/tidnet.py +0 -0
  159. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/tinymyo.py +0 -0
  160. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/tmsanet.py +0 -0
  161. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/tsinception.py +0 -0
  162. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/usleep.py +0 -0
  163. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/vemg2pose.py +0 -0
  164. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/models/zuna.py +0 -0
  165. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/__init__.py +0 -0
  166. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/activation.py +0 -0
  167. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/attention.py +0 -0
  168. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/blocks.py +0 -0
  169. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/convolution.py +0 -0
  170. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/dance_modules.py +0 -0
  171. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/filter.py +0 -0
  172. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/layers.py +0 -0
  173. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/linear.py +0 -0
  174. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/linear_attention.py +0 -0
  175. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/parametrization.py +0 -0
  176. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/quantization.py +0 -0
  177. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/seanet.py +0 -0
  178. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/stats.py +0 -0
  179. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/util.py +0 -0
  180. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/modules/wrapper.py +0 -0
  181. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/preprocessing/__init__.py +0 -0
  182. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
  183. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/preprocessing/mne_preprocess.py +0 -0
  184. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/preprocessing/preprocess.py +0 -0
  185. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/preprocessing/util.py +0 -0
  186. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/preprocessing/windowers.py +0 -0
  187. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/regressor.py +0 -0
  188. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/samplers/__init__.py +0 -0
  189. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/samplers/base.py +0 -0
  190. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/samplers/ssl.py +0 -0
  191. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/training/__init__.py +0 -0
  192. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/training/_trial_aggregation.py +0 -0
  193. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/training/callbacks.py +0 -0
  194. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/training/losses.py +0 -0
  195. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/training/scoring.py +0 -0
  196. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/util.py +0 -0
  197. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/visualization/__init__.py +0 -0
  198. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/visualization/activations.py +0 -0
  199. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/visualization/attribution.py +0 -0
  200. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/visualization/confusion_matrices.py +0 -0
  201. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/visualization/frequency.py +0 -0
  202. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/visualization/metrics.py +0 -0
  203. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/visualization/sanity.py +0 -0
  204. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode/visualization/topology.py +0 -0
  205. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode.egg-info/dependency_links.txt +0 -0
  206. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode.egg-info/requires.txt +0 -0
  207. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/braindecode.egg-info/top_level.txt +0 -0
  208. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/Makefile +0 -0
  209. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/_templates/autosummary/class.rst +0 -0
  210. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
  211. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/_templates/autosummary/function.rst +0 -0
  212. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
  213. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/agent_docs.rst +0 -0
  214. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/cite.rst +0 -0
  215. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/conf.py +0 -0
  216. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/help.rst +0 -0
  217. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/index.rst +0 -0
  218. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/install/gaudi.rst +0 -0
  219. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/install/install.rst +0 -0
  220. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/install/install_pip.rst +0 -0
  221. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/install/install_source.rst +0 -0
  222. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/categorization/attention.rst +0 -0
  223. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/categorization/channel.rst +0 -0
  224. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/categorization/convolution.rst +0 -0
  225. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/categorization/filterbank.rst +0 -0
  226. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/categorization/gnn.rst +0 -0
  227. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/categorization/interpretable.rst +0 -0
  228. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/categorization/lbm.rst +0 -0
  229. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/categorization/recurrent.rst +0 -0
  230. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/categorization/spd.rst +0 -0
  231. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/models.rst +0 -0
  232. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/models_categorization.rst +0 -0
  233. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/models_table.rst +0 -0
  234. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/models/models_visualization.rst +0 -0
  235. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/sg_execution_times.rst +0 -0
  236. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/user_guide/channel_strategies.rst +0 -0
  237. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/docs/user_guide/cropped_inference.rst +0 -0
  238. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/pyproject.toml +0 -0
  239. {braindecode-2.1.0.dev184110306 → braindecode-2.1.0.dev4294968686}/setup.cfg +0 -0
@@ -96,8 +96,13 @@ The following components are licensed under the Apache License 2.0:
96
96
  - `braindecode/models/mscformer.py`
97
97
  - `braindecode/models/fnirsnet.py`
98
98
  - `braindecode/models/fnirs4d.py`
99
+ - `braindecode/models/samba.py`
99
100
  - `docs/_static/model/fnirs4d.png` (wzhlearning/fNIRS4D `fig/fig2.png`, resized)
100
101
 
102
+ The `samba.py` file adapts the encoder of `Jiazhen-Hong/SAMBA` and rewrites in
103
+ PyTorch the `Mamba2` block of `state-spaces/mamba` (Apache-2.0, Copyright 2023
104
+ Tri Dao, Albert Gu).
105
+
101
106
  ### CC BY 4.0 Licensed Files
102
107
 
103
108
  The following figures are reproduced from open-access papers under the
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 2.1.0.dev184110306
3
+ Version: 2.1.0.dev4294968686
4
4
  Summary: Deep learning software to decode EEG, ECG or MEG signals
5
5
  Author-email: Robin Tibor Schirrmeister <robintibor@gmail.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Alexandre Gramfort <agramfort@meta.com>
6
6
  Maintainer-email: Alexandre Gramfort <agramfort@meta.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Robin Tibor Schirrmeister <robintibor@gmail.com>
@@ -85,6 +85,7 @@ if TYPE_CHECKING:
85
85
  from .popt import PopulationTransformer
86
86
  from .pratibha2 import Pratibha2
87
87
  from .reve import REVE
88
+ from .samba import SAMBA
88
89
  from .sccnet import SCCNet
89
90
  from .seizure_transformer import SeizureTransformer
90
91
  from .sensingdynamics import SensingDynamics
@@ -10,6 +10,7 @@ import functools
10
10
  import inspect
11
11
  import json
12
12
  import logging
13
+ import sys
13
14
  import warnings
14
15
  from collections import OrderedDict
15
16
  from pathlib import Path, PurePosixPath, PureWindowsPath
@@ -1031,13 +1032,19 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
1031
1032
  except ValueError:
1032
1033
  n_times = 200
1033
1034
 
1034
- return summary(
1035
+ statistics = summary(
1035
1036
  self,
1036
1037
  input_size=(1, n_chans, n_times),
1037
1038
  col_names=col_names,
1038
1039
  row_settings=row_settings,
1039
1040
  verbose=0,
1040
1041
  )
1042
+ # torchinfo 1.8 also stores the summary layers in a module-level dict,
1043
+ # keyed by class name, whatever ``cache_forward_pass`` is: it kept the
1044
+ # last printed instance of each class alive. braindecode never reads it.
1045
+ cache = getattr(sys.modules[summary.__module__], "_cached_forward_pass", {})
1046
+ cache.pop(type(self).__name__, None)
1047
+ return statistics
1041
1048
 
1042
1049
  def _pretrained_summary(self):
1043
1050
  """Display data shared by the text and notebook representations."""
@@ -29,7 +29,7 @@ from braindecode.modules import (
29
29
  SpatialTemporalBlock,
30
30
  )
31
31
  from braindecode.modules.quantization import ResidualVectorQuantizer
32
- from braindecode.modules.spatial_temporal import _attend
32
+ from braindecode.modules.spatial_temporal import _SELU, _attend
33
33
 
34
34
 
35
35
  class BrainTokenizer(EEGModuleMixin, nn.Module, license="mit"):
@@ -508,7 +508,8 @@ class BrainOmni(EEGModuleMixin, nn.Module, license="mit"):
508
508
  return nn.Sequential(
509
509
  nn.Dropout(0.1),
510
510
  nn.Linear(self.n_neuro * self.lm_dim, self.lm_dim),
511
- self.activation(),
511
+ # nn.SELU (the released config) computed as _SELU, the scale == 1 ELU form
512
+ (_SELU if self.activation is nn.SELU else self.activation)(),
512
513
  nn.Linear(self.lm_dim, n_outputs),
513
514
  )
514
515
 
@@ -624,9 +625,9 @@ class _SensorEmbedding(nn.Module):
624
625
  super().__init__()
625
626
  self.sensor_embedding_layer = nn.Embedding(3, n_dim)
626
627
  self.pos_embedding_layer = nn.Sequential(
627
- nn.Linear(6, n_dim // 2), nn.SELU(), nn.Linear(n_dim // 2, n_dim)
628
+ nn.Linear(6, n_dim // 2), _SELU(), nn.Linear(n_dim // 2, n_dim)
628
629
  )
629
- self.aggregate_mlp = FeedForwardBlock(n_dim, 4, 0.0, nn.SELU)
630
+ self.aggregate_mlp = FeedForwardBlock(n_dim, 4, 0.0, _SELU)
630
631
  self.norm = RMSNorm(n_dim, eps=1e-6)
631
632
 
632
633
  def forward(self, pos: torch.Tensor, sensor_type: torch.Tensor) -> torch.Tensor:
@@ -5,7 +5,10 @@
5
5
  # Copyright (c) 2026 Liuyin Yang
6
6
  """CORTEG: an ST-EEGFormer adapted to intracranial recordings."""
7
7
 
8
+ from __future__ import annotations
9
+
8
10
  import math
11
+ from functools import partial
9
12
  from typing import Dict, Optional, Union
10
13
 
11
14
  import mne
@@ -14,14 +17,14 @@ import torch
14
17
  from torch import nn
15
18
  from torch.nn import functional as F
16
19
 
17
- from braindecode.functional import check_ch_mask, masked_mean
18
- from braindecode.models.base import EEGModuleMixin
19
- from braindecode.models.steegformer import (
20
- STEEGFORMER_CHANNEL_ORDER,
21
- _ChannelPositionalEmbed,
22
- _init_weights,
23
- _TemporalPositionalEncoding,
20
+ from braindecode.functional import (
21
+ check_ch_mask,
22
+ init_weights_,
23
+ masked_mean,
24
+ sinusoidal_positional_encoding,
24
25
  )
26
+ from braindecode.models.base import EEGModuleMixin
27
+ from braindecode.models.steegformer import STEEGFORMER_CHANNEL_ORDER
25
28
  from braindecode.models.util import chs_info_positions
26
29
  from braindecode.modules import (
27
30
  FeedForwardBlock,
@@ -29,22 +32,9 @@ from braindecode.modules import (
29
32
  PatchTokenizer,
30
33
  PreNormTransformerBlock,
31
34
  )
32
- from braindecode.util import resolve_montage_name
33
-
34
-
35
- def _vocab_positions() -> torch.Tensor:
36
- """``(142, 3)`` positions (m) of ST-EEGFormer's positioned vocabulary slots.
37
-
38
- The slot names come from STEEGFormer's channel vocabulary, their positions
39
- from MNE's Colin27 10-05 montage (the reference's table, to 6 decimals).
40
- """
41
- montage = mne.channels.make_standard_montage(resolve_montage_name("standard_1005"))
42
- ch_pos = montage.get_positions()["ch_pos"]
43
- positions = np.stack([ch_pos[name] for name in STEEGFORMER_CHANNEL_ORDER])
44
- return torch.as_tensor(positions, dtype=torch.float32)
45
35
 
46
36
 
47
- class CORTEG(EEGModuleMixin, nn.Module):
37
+ class CORTEG(EEGModuleMixin, nn.Module, license="mit"):
48
38
  r"""CORTEG from Yang et al. (2026) [Yang2026b]_.
49
39
 
50
40
  :bdg-info:`Attention/Transformer` :bdg-danger:`Foundation Model` :bdg-dark-line:`Channel`
@@ -67,8 +57,9 @@ class CORTEG(EEGModuleMixin, nn.Module):
67
57
  scalp model was never trained on. The paper trains only the spatial
68
58
  adapter, the high-gamma patch embedding, LoRA on the last
69
59
  ``n_merge_blocks`` blocks with their LayerNorms, and the head (about 297 K
70
- parameters for the small backbone); this module builds the network, and
71
- LoRA and freezing are left to the training code.
60
+ parameters for the small backbone); this module builds the network and
61
+ freezes the channel codebook, and leaves LoRA and the freezing of the other
62
+ parameters to the training code.
72
63
 
73
64
  .. rubric:: Macro Components
74
65
 
@@ -82,7 +73,7 @@ class CORTEG(EEGModuleMixin, nn.Module):
82
73
  - **KNNSoftFourier spatial adapter** (``CORTEG.channel_adapter``).
83
74
  *Operations:* a soft branch maps each electrode position to softmax
84
75
  weights over the 142 positioned slots of the pretrained channel
85
- embedding (``CORTEG.channel_pos``, kept frozen) and returns their
76
+ codebook (``CORTEG.channel_codebook``, frozen) and returns their
86
77
  weighted sum; the last bias starts from a Gaussian ``knn_k``-nearest-
87
78
  neighbour kernel over the slots' scalp positions, so the soft branch
88
79
  starts as a nearest-electrode interpolation. A Fourier residual
@@ -101,50 +92,48 @@ class CORTEG(EEGModuleMixin, nn.Module):
101
92
  - **Read-out** (``CORTEG.norm``, ``CORTEG.final_layer``). *Operations:*
102
93
  layer norm, mean over all tokens (CLS included), linear head.
103
94
 
104
- .. rubric:: Inputs
105
-
106
- The paper decomposes the raw signal into two streams, both z-scored per
107
- channel with training-set statistics:
108
-
109
- - ``x``: the low-frequency stream, resampled to 128 Hz (the 16-sample
110
- patches of the pretrained model then span 125 ms);
111
- - ``x_hi``: the 70-200 Hz Hilbert envelope at 200 Hz, so that its
112
- 25-sample patches line up with those of ``x``.
113
-
114
- With MNE, ``raw.copy().filter(70, 200).apply_hilbert(envelope=True)
115
- .resample(200)`` gives ``x_hi``. Without ``x_hi`` the model reads ``x``
116
- alone, as the paper's low-frequency-only ablation.
117
-
118
- Electrode positions are 3D coordinates in metres (the paper's MNI
119
- coordinates), passed as ``pos`` or read from ``chs_info``.
120
-
121
- .. rubric:: Pre-trained weights
122
-
123
- The ST-EEGFormer small backbone, with the high-gamma embedding
124
- warm-started from its low-frequency one, loads from the re-hosted
125
- checkpoint; the adapter, gate and head keep their initialization::
126
-
127
- model = CORTEG.from_pretrained(
128
- "braindecode/corteg-small-pretrained", n_outputs=5, n_times=128,
129
- chs_info=chs_info,
130
- )
131
-
132
- A bare :class:`~braindecode.models.STEEGFormer` checkpoint, such as
133
- ``braindecode/STEEGFormer-small``, has no high-gamma embedding. Loading it
134
- derives that embedding from the loaded low-frequency one, and so overwrites
135
- a trained high-gamma embedding.
95
+ .. rubric:: Temporal, Spatial, and Spectral Encoding
96
+
97
+ - **Temporal:** patches of ``patch_size`` samples (16 at 128 Hz, 125 ms),
98
+ each tagged with the fixed sinusoidal encoding of its position; the CLS
99
+ token takes position 0.
100
+ - **Spatial:** the 3D position of each electrode, in metres (the paper's
101
+ MNI coordinates), passed as ``pos`` or read from ``chs_info``, becomes a
102
+ channel embedding through the spatial adapter.
103
+ - **Spectral:** the second stream, ``x_hi``, carries the high-gamma
104
+ envelope that the scalp model never saw.
105
+
106
+ .. rubric:: Additional Mechanisms
107
+
108
+ - **Input streams:** the paper decomposes the raw signal into two streams,
109
+ both z-scored per channel with training-set statistics. ``x`` is the
110
+ low-frequency stream, resampled to 128 Hz; ``x_hi`` is the 70-200 Hz
111
+ Hilbert envelope at 200 Hz, so that its 25-sample patches line up with
112
+ those of ``x``. With MNE, ``raw.copy().filter(70, 200)
113
+ .apply_hilbert(envelope=True).resample(200)`` gives ``x_hi``. Without
114
+ ``x_hi`` the model reads ``x`` alone, as the paper's low-frequency-only
115
+ ablation.
116
+ - **Channel padding:** ``ch_mask`` is an addition to the reference, which
117
+ batches one patient at a time: padded channels take part in no
118
+ attention and no pooling.
119
+
120
+ .. important::
121
+
122
+ The ST-EEGFormer small backbone, with the high-gamma embedding
123
+ warm-started from its low-frequency one, loads from the re-hosted
124
+ checkpoint; the adapter, gate and head keep their initialization::
125
+
126
+ model = CORTEG.from_pretrained(
127
+ "braindecode/corteg-small-pretrained", n_outputs=5, n_times=128,
128
+ chs_info=chs_info,
129
+ )
136
130
 
137
- The authors' Stanford model (finger flexion, nine patients pooled) is
138
- re-hosted with its LoRA factors folded in::
131
+ The authors' Stanford model (finger flexion, nine patients pooled) is
132
+ re-hosted with its LoRA factors folded in::
139
133
 
140
- model = CORTEG.from_pretrained(
141
- "braindecode/corteg-stanford-pooled", chs_info=chs_info
142
- )
143
-
144
- .. note::
145
- The outputs match the reference implementation for the same weights
146
- and inputs, for both merge strategies. ``ch_mask`` is an addition:
147
- the reference batches one patient at a time.
134
+ model = CORTEG.from_pretrained(
135
+ "braindecode/corteg-stanford-pooled", chs_info=chs_info
136
+ )
148
137
 
149
138
  Parameters
150
139
  ----------
@@ -168,8 +157,6 @@ class CORTEG(EEGModuleMixin, nn.Module):
168
157
  activation : type[nn.Module]
169
158
  Activation layer class of the feed-forward blocks and of the MLPs of
170
159
  the spatial adapter and the gate.
171
- n_chans_pos : int
172
- Size of the pretrained channel vocabulary (145 for small/base/large).
173
160
  merge_strategy : {"average", "layerwise_gate"}
174
161
  Fusion of the high-gamma stream: the paper's default mean before the
175
162
  last ``n_merge_blocks`` blocks (the released Stanford adapter), or the
@@ -201,14 +188,15 @@ class CORTEG(EEGModuleMixin, nn.Module):
201
188
 
202
189
  def __init__(
203
190
  self,
204
- # --- signal-related (handled by EEGModuleMixin) ---
191
+ # braindecode parameters
205
192
  n_outputs=None,
206
193
  n_chans=None,
207
194
  chs_info=None,
208
195
  n_times=None,
209
196
  input_window_seconds=None,
210
197
  sfreq=None,
211
- # --- model hyperparameters (defaults: small backbone) ---
198
+ *,
199
+ # model-specific parameters (defaults: small backbone)
212
200
  patch_size: int = 16,
213
201
  hi_patch_size: int = 25,
214
202
  embed_dim: int = 512,
@@ -218,7 +206,6 @@ class CORTEG(EEGModuleMixin, nn.Module):
218
206
  drop_prob: float = 0.0,
219
207
  drop_path: float = 0.1,
220
208
  activation: type[nn.Module] = nn.GELU,
221
- n_chans_pos: int = 145,
222
209
  merge_strategy: str = "average",
223
210
  n_merge_blocks: int = 4,
224
211
  knn_k: int = 8,
@@ -249,13 +236,7 @@ class CORTEG(EEGModuleMixin, nn.Module):
249
236
  )
250
237
  vocab_positions = _vocab_positions() # (n_slots, 3)
251
238
  n_slots = len(vocab_positions)
252
- if n_chans_pos < n_slots:
253
- raise ValueError(
254
- f"n_chans_pos must be at least {n_slots}, the "
255
- f"positioned slots of the vocabulary, got {n_chans_pos}."
256
- )
257
239
  self.embed_dim = embed_dim
258
- self.depth = depth
259
240
  self.merge_strategy = merge_strategy
260
241
  self.merge_at = depth - n_merge_blocks
261
242
  self.knn_k = knn_k
@@ -265,8 +246,8 @@ class CORTEG(EEGModuleMixin, nn.Module):
265
246
  self.register_buffer("default_pos", default_pos, persistent=False)
266
247
  self.register_buffer("vocab_positions", vocab_positions, persistent=False)
267
248
 
268
- # The ST-EEGFormer backbone, under the names of STEEGFormer's modules
269
- # so that its checkpoints load as they are.
249
+ # The ST-EEGFormer backbone; its weights keep STEEGFormer's names, except
250
+ # the channel codebook.
270
251
  self.patch_embed = PatchTokenizer(
271
252
  patch_size=patch_size,
272
253
  n_times=self.n_times,
@@ -276,10 +257,18 @@ class CORTEG(EEGModuleMixin, nn.Module):
276
257
  projection="linear",
277
258
  output_order="patch_channel",
278
259
  )
279
- self.temporal_pos = _TemporalPositionalEncoding(embed_dim)
280
- self.channel_pos = _ChannelPositionalEmbed(n_chans_pos, embed_dim)
281
- # The soft branch's codebook, frozen as in the paper.
282
- self.channel_pos.embedding.weight.requires_grad_(False)
260
+ # Fixed sinusoidal encoding of the patch positions: (n_positions, D),
261
+ # position 0 for the CLS token and 1.. for the time patches.
262
+ self.register_buffer(
263
+ "temporal_encoding",
264
+ sinusoidal_positional_encoding(_N_TEMPORAL_POSITIONS, embed_dim),
265
+ persistent=False,
266
+ )
267
+ # The pretrained channel embedding of the vocabulary's slots, (n_slots, D):
268
+ # the soft branch's codebook, frozen as in the paper and filled by a checkpoint.
269
+ self.channel_codebook = nn.Parameter(
270
+ torch.empty(n_slots, embed_dim), requires_grad=False
271
+ )
283
272
  self.cls_token = nn.Parameter(torch.zeros(1, 1, embed_dim))
284
273
  self.pos_drop = nn.Dropout(drop_prob)
285
274
  dpr = torch.linspace(0, drop_path, depth).tolist()
@@ -290,18 +279,18 @@ class CORTEG(EEGModuleMixin, nn.Module):
290
279
  MultiHeadAttention(embed_dim, num_heads, drop_prob),
291
280
  FeedForwardBlock(
292
281
  embed_dim,
293
- expansion=int(mlp_ratio),
282
+ expansion=mlp_ratio,
294
283
  drop_p=drop_prob,
295
284
  activation=activation,
296
285
  ),
297
286
  drop_prob,
298
- eps=1e-6,
287
+ eps=_LAYER_NORM_EPS,
299
288
  drop_path=dpr[i],
300
289
  )
301
290
  for i in range(depth)
302
291
  ]
303
292
  )
304
- self.norm = nn.LayerNorm(embed_dim, eps=1e-6)
293
+ self.norm = nn.LayerNorm(embed_dim, eps=_LAYER_NORM_EPS)
305
294
 
306
295
  # x_hi of this length gives one high-gamma token per low-frequency token.
307
296
  self.patch_embed_hi = PatchTokenizer(
@@ -329,14 +318,14 @@ class CORTEG(EEGModuleMixin, nn.Module):
329
318
  self.final_layer = nn.Linear(embed_dim, self.n_outputs)
330
319
 
331
320
  self._init_parameters()
332
- # Loading a bare ST-EEGFormer checkpoint warm-starts the high-gamma embedding.
333
- self.register_load_state_dict_post_hook(self._warm_start_high_gamma)
334
321
 
335
322
  def _init_parameters(self) -> None:
336
323
  """Model-specific initialization (see ``reset_parameters``)."""
337
324
  for module in (self.patch_embed, self.encoder, self.norm, self.final_layer):
338
325
  module.apply(_init_weights)
339
326
  nn.init.normal_(self.cls_token, std=0.02)
327
+ # Zero, as if there were no channel embedding, until a checkpoint fills it.
328
+ nn.init.zeros_(self.channel_codebook)
340
329
  self._init_high_gamma_from_low()
341
330
  prior = None
342
331
  if self.default_pos is not None:
@@ -360,24 +349,9 @@ class CORTEG(EEGModuleMixin, nn.Module):
360
349
  hi.weight.copy_(resized[0])
361
350
  hi.bias.copy_(lo.bias)
362
351
 
363
- def _warm_start_high_gamma(self, _module, incompatible_keys):
364
- """Post-load hook: warm-start the high-gamma embedding a checkpoint lacks.
365
-
366
- A bare ST-EEGFormer checkpoint loads ``patch_embed`` but has no
367
- ``patch_embed_hi``, which torch reports as missing; a CORTEG checkpoint
368
- has both and keeps its own.
369
- """
370
- missing = incompatible_keys.missing_keys
371
- if (
372
- "patch_embed_hi.proj.weight" in missing
373
- and "patch_embed.proj.weight" not in missing
374
- ):
375
- self._init_high_gamma_from_low()
376
-
377
- def reset_head(self, n_outputs):
352
+ def reset_head(self, n_outputs: int) -> None:
378
353
  """Replace the linear head for a new ``n_outputs``."""
379
- self._n_outputs = n_outputs
380
- self._update_init_kwargs(n_outputs=n_outputs)
354
+ self._set_n_outputs(n_outputs)
381
355
  self.final_layer = nn.Linear(self.embed_dim, n_outputs)
382
356
  _init_weights(self.final_layer)
383
357
 
@@ -442,19 +416,21 @@ class CORTEG(EEGModuleMixin, nn.Module):
442
416
  )
443
417
  if mask is not None:
444
418
  # Padding may hold NaN, which the embeddings would spread.
445
- x = x.masked_fill(~mask[:, :, None], 0.0)
446
- pos = pos.masked_fill(~mask[:, :, None], 0.0)
419
+ x = x.masked_fill(~mask[:, :, None], 0.0) # (B, C, T)
420
+ pos = pos.masked_fill(~mask[:, :, None], 0.0) # (B, C, 3)
447
421
  if x_hi is not None:
448
- x_hi = x_hi.masked_fill(~mask[:, :, None], 0.0)
422
+ x_hi = x_hi.masked_fill(~mask[:, :, None], 0.0) # (B, C, T_hi)
449
423
  # (B, N), patch-major like the tokens
450
424
  token_mask = mask.repeat(1, n_patches)
451
425
  key_mask = F.pad(token_mask, (1, 0), value=True) # (B, 1 + N), CLS first
452
426
  attn_mask = key_mask[:, None, None, :] # (B, 1, 1, 1 + N)
453
427
 
454
- codebook = self.channel_pos.embedding.weight[: self.vocab_positions.shape[0]]
455
- channel_emb = self.channel_adapter(pos, codebook) # (B or 1, C, D)
456
- # (B or 1, P, C, D)
457
- embedding = self.temporal_pos(n_patches) + channel_emb[:, None]
428
+ # Each electrode's embedding, from its position and the pretrained codebook.
429
+ channel_emb = self.channel_adapter(pos, self.channel_codebook) # (B or 1, C, D)
430
+ # Positions 1..P of the temporal encoding, (1, P, 1, D), plus the channel
431
+ # embedding (B or 1, 1, C, D) -> (B or 1, P, C, D)
432
+ temporal_emb = self.temporal_encoding[1 : n_patches + 1][None, :, None]
433
+ embedding = temporal_emb + channel_emb[:, None]
458
434
  tokens = self.patch_embed(x) # (B, P, C, D)
459
435
  lo = (tokens + embedding).flatten(1, 2) # (B, N, D)
460
436
  if x_hi is not None:
@@ -468,7 +444,8 @@ class CORTEG(EEGModuleMixin, nn.Module):
468
444
  ).permute(0, 3, 1, 2) # (B, P, C, D)
469
445
  hi = (hi_tokens + embedding).flatten(1, 2) # (B, N, D)
470
446
 
471
- cls = self.cls_token + self.temporal_pos.cls_token_encoding() # (1, 1, D)
447
+ # CLS token at position 0 of the temporal encoding: (1, 1, D)
448
+ cls = self.cls_token + self.temporal_encoding[0]
472
449
  z = torch.cat([cls.expand(batch_size, -1, -1), lo], dim=1) # (B, 1 + N, D)
473
450
  z = self.pos_drop(z)
474
451
  if hi is not None and self.layerwise_gate is not None:
@@ -498,28 +475,79 @@ class CORTEG(EEGModuleMixin, nn.Module):
498
475
  return self.final_layer(masked_mean(z, key_mask, [1])) # (B, n_outputs)
499
476
 
500
477
 
478
+ # Constants and helpers, below the model class.
479
+
480
+ # LayerNorm epsilon of STEEGFormer's blocks and final norm.
481
+ _LAYER_NORM_EPS = 1e-6
482
+ # Positions of the fixed temporal encoding, CLS token included, as in STEEGFormer.
483
+ _N_TEMPORAL_POSITIONS = 2048
484
+ # Numerical floors of the soft branch's k-NN prior: the smallest kernel bandwidth
485
+ # (m), and the floor that keeps the normalization and the logarithm of the kernel
486
+ # weights finite.
487
+ _MIN_BANDWIDTH = 1e-6
488
+ _WEIGHT_EPSILON = 1e-8
489
+ # Weight initialization of the ST-EEGFormer reference: Xavier-uniform linear
490
+ # layers with zero bias, unit LayerNorms.
491
+ _init_weights = partial(init_weights_, weights={nn.Linear: nn.init.xavier_uniform_})
492
+
493
+
494
+ def _vocab_positions() -> torch.Tensor:
495
+ """``(142, 3)`` positions (m) of ST-EEGFormer's positioned vocabulary slots.
496
+
497
+ The slot names come from ``STEEGFORMER_CHANNEL_ORDER``, the channel
498
+ vocabulary of the released ST-EEGFormer checkpoints; their positions from
499
+ MNE's Colin27 10-05 montage, which gives the reference's table to 6
500
+ decimals.
501
+ """
502
+ montage = mne.channels.make_standard_montage("colin27_1005")
503
+ ch_pos = montage.get_positions()["ch_pos"]
504
+ positions = np.stack([ch_pos[name] for name in STEEGFORMER_CHANNEL_ORDER])
505
+ return torch.as_tensor(positions, dtype=torch.float32)
506
+
507
+
501
508
  def _knn_log_prior(
502
509
  positions: torch.Tensor, vocab_positions: torch.Tensor, k: int
503
510
  ) -> torch.Tensor:
504
511
  """Log Gaussian k-NN weight of each vocabulary slot, averaged over ``positions``.
505
512
 
506
- The bandwidth is the median distance of the ``k`` nearest slots.
513
+ Steps:
514
+
515
+ 1. Take the ``k`` nearest slots of each electrode.
516
+ 2. Weight them with a Gaussian kernel whose bandwidth is the median of
517
+ their distances, normalized per electrode.
518
+ 3. Scatter the weights over all slots, take the log and average over the
519
+ electrodes.
520
+
521
+ ``positions`` is ``(n_chans, 3)`` and ``vocab_positions`` ``(n_slots, 3)``,
522
+ both in metres; the result is ``(n_slots,)``.
507
523
  """
524
+ # (n_chans, n_slots) -> (n_chans, k) distances and slot indices
508
525
  distances, slots = torch.cdist(positions, vocab_positions).topk(
509
526
  k, dim=-1, largest=False
510
527
  )
511
- sigma = distances.median().clamp(min=1e-6)
512
- weights = torch.exp(-0.5 * (distances / sigma) ** 2)
513
- weights = weights / weights.sum(dim=-1, keepdim=True).clamp(min=1e-8)
528
+ sigma = distances.median().clamp(min=_MIN_BANDWIDTH) # scalar
529
+ weights = torch.exp(-0.5 * (distances / sigma) ** 2) # (n_chans, k)
530
+ weights = weights / weights.sum(dim=-1, keepdim=True).clamp(min=_WEIGHT_EPSILON)
531
+ # (n_chans, n_slots), zero outside the k nearest slots
514
532
  dense = torch.zeros(len(positions), len(vocab_positions)).scatter_(
515
533
  1, slots, weights
516
534
  )
517
- return torch.log(dense + 1e-8).mean(dim=0)
535
+ return torch.log(dense + _WEIGHT_EPSILON).mean(dim=0) # (n_slots,)
518
536
 
519
537
 
520
538
  class _KNNSoftFourierAdapter(nn.Module):
521
- """Channel embedding of a 3D position: a soft branch over the pretrained
522
- codebook plus a Fourier-feature residual."""
539
+ """Channel embedding of a 3D electrode position (the paper's KNNSoftFourier).
540
+
541
+ Steps:
542
+
543
+ 1. ``soft``: the position selects a softmax-weighted sum of the pretrained
544
+ codebook slots (:class:`_SoftCodebookBranch`).
545
+ 2. ``residual``: a Fourier-feature MLP adds a position-specific correction
546
+ (:class:`_FourierBranch`), zero at initialization.
547
+
548
+ ``forward(pos, codebook)`` maps ``pos`` ``(batch or 1, n_chans, 3)`` and
549
+ ``codebook`` ``(n_slots, embed_dim)`` to ``(batch or 1, n_chans, embed_dim)``.
550
+ """
523
551
 
524
552
  def __init__(
525
553
  self,
@@ -538,22 +566,33 @@ class _KNNSoftFourierAdapter(nn.Module):
538
566
  """Start the soft branch at ``prior`` (uniform if ``None``) and the
539
567
  residual at zero."""
540
568
  with torch.no_grad():
541
- bias = self.soft.net[-1].bias
569
+ bias = self.soft.net[-1].bias # (n_slots,)
542
570
  bias.copy_(torch.zeros_like(bias) if prior is None else prior)
543
571
  self.soft.scale.fill_(1.0)
544
572
  nn.init.zeros_(self.residual.net[-1].weight)
545
573
 
546
574
  def forward(self, pos: torch.Tensor, codebook: torch.Tensor) -> torch.Tensor:
575
+ # (B or 1, C, 3) -> (B or 1, C, D), the two branches summed
547
576
  return self.soft(pos, codebook) + self.residual(pos)
548
577
 
549
578
 
550
579
  class _SoftCodebookBranch(nn.Module):
551
- """Softmax attention of a position over the codebook slots."""
580
+ """Softmax attention of a position over the codebook slots.
581
+
582
+ Steps:
583
+
584
+ 1. An MLP maps the 3D position to one logit per slot.
585
+ 2. The softmax of the logits weights the slots of the codebook; the weighted
586
+ sum is multiplied by a learned scalar ``scale``.
587
+
588
+ ``forward(pos, codebook)`` maps ``pos`` ``(batch or 1, n_chans, 3)`` and
589
+ ``codebook`` ``(n_slots, embed_dim)`` to ``(batch or 1, n_chans, embed_dim)``.
590
+ """
552
591
 
553
592
  def __init__(self, n_slots: int, hidden: int, activation: type[nn.Module]):
554
593
  super().__init__()
555
594
  self.net = nn.Sequential(
556
- nn.Linear(3, hidden),
595
+ nn.Linear(3, hidden), # 3: x, y, z of the electrode
557
596
  activation(),
558
597
  nn.Linear(hidden, hidden),
559
598
  activation(),
@@ -562,13 +601,25 @@ class _SoftCodebookBranch(nn.Module):
562
601
  self.scale = nn.Parameter(torch.ones(1))
563
602
 
564
603
  def forward(self, pos: torch.Tensor, codebook: torch.Tensor) -> torch.Tensor:
565
- return self.scale * torch.matmul(self.net(pos).softmax(dim=-1), codebook)
604
+ # (B or 1, C, 3) -> (B or 1, C, n_slots) weights over the slots
605
+ weights = self.net(pos).softmax(dim=-1)
606
+ # (B or 1, C, n_slots) @ (n_slots, D) -> (B or 1, C, D)
607
+ return self.scale * torch.matmul(weights, codebook)
566
608
 
567
609
 
568
610
  class _FourierBranch(nn.Module):
569
- """MLP on sinusoidal features of a position, at log-spaced frequencies."""
611
+ """MLP on sinusoidal features of a position, at log-spaced frequencies.
570
612
 
571
- freqs: torch.Tensor
613
+ Steps:
614
+
615
+ 1. Multiply each of the 3 coordinates by the ``n_freqs`` frequencies, log-spaced
616
+ from 1 to ``max_freq`` radians per metre.
617
+ 2. Concatenate the sine and the cosine of the angles.
618
+ 3. Apply an MLP to the ``6 * n_freqs`` features.
619
+
620
+ ``forward(pos)`` maps ``pos`` ``(batch or 1, n_chans, 3)`` to
621
+ ``(batch or 1, n_chans, embed_dim)``.
622
+ """
572
623
 
573
624
  def __init__(
574
625
  self,
@@ -579,6 +630,7 @@ class _FourierBranch(nn.Module):
579
630
  activation: type[nn.Module],
580
631
  ):
581
632
  super().__init__()
633
+ self.freqs: torch.Tensor
582
634
  self.register_buffer(
583
635
  "freqs", torch.logspace(0, math.log10(max_freq), n_freqs), persistent=False
584
636
  )
@@ -592,12 +644,24 @@ class _FourierBranch(nn.Module):
592
644
  )
593
645
 
594
646
  def forward(self, pos: torch.Tensor) -> torch.Tensor:
647
+ # (B or 1, C, 3, 1) * (n_freqs,) -> (B or 1, C, 3 * n_freqs) angles
595
648
  angles = (pos[..., None] * self.freqs).flatten(-2)
649
+ # (B or 1, C, 6 * n_freqs) -> (B or 1, C, D)
596
650
  return self.net(torch.cat([angles.sin(), angles.cos()], dim=-1))
597
651
 
598
652
 
599
653
  class _LayerwiseGate(nn.Module):
600
- """One tanh gate per block and sample, from the mean low and high tokens."""
654
+ """One tanh gate per block and sample, from the mean low and high tokens.
655
+
656
+ Steps:
657
+
658
+ 1. Concatenate the mean low-frequency and high-gamma tokens of the sample.
659
+ 2. Apply a LayerNorm and a bottleneck MLP with one output per block.
660
+ 3. Squash the outputs with a tanh into gates in ``(-1, 1)``.
661
+
662
+ ``forward(lo, hi)`` maps two ``(batch, embed_dim)`` means to the gates
663
+ ``(batch, depth)``.
664
+ """
601
665
 
602
666
  def __init__(
603
667
  self, embed_dim: int, depth: int, bottleneck: int, activation: type[nn.Module]
@@ -616,4 +680,5 @@ class _LayerwiseGate(nn.Module):
616
680
  nn.init.zeros_(self.net[-1].bias)
617
681
 
618
682
  def forward(self, lo: torch.Tensor, hi: torch.Tensor) -> torch.Tensor:
683
+ # (B, D) and (B, D) -> (B, 2 * D) -> (B, depth) gates in (-1, 1)
619
684
  return torch.tanh(self.net(torch.cat([lo, hi], dim=-1)))