braindecode 1.8.1.dev169883370__tar.gz → 1.8.1.dev170036056__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 (208) hide show
  1. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/NOTICE.txt +1 -0
  2. {braindecode-1.8.1.dev169883370/braindecode.egg-info → braindecode-1.8.1.dev170036056}/PKG-INFO +1 -1
  3. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/augmentation/functional.py +1 -1
  4. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/base.py +54 -5
  5. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/tuh.py +20 -13
  6. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datautil/serialization.py +6 -4
  7. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/__init__.py +2 -0
  8. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/attn_sleep.py +4 -0
  9. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/base.py +34 -15
  10. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/brainomni.py +9 -3
  11. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/csbrain.py +5 -0
  12. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/deep4.py +10 -1
  13. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/dgcnn.py +7 -0
  14. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegnex.py +16 -1
  15. braindecode-1.8.1.dev170036056/braindecode/models/guetschel2026.py +775 -0
  16. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/luna.py +4 -1
  17. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/mapa.py +8 -2
  18. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/medformer.py +12 -3
  19. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/neurorvq.py +17 -3
  20. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/neurorvq_tokenizer.py +47 -52
  21. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/reve.py +13 -1
  22. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/signal_jepa.py +6 -1
  23. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/sleep_stager_blanco_2020.py +6 -2
  24. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/summary.csv +1 -0
  25. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/tcn.py +5 -0
  26. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/tidnet.py +18 -1
  27. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/usleep.py +3 -2
  28. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/util.py +139 -33
  29. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/zuna.py +6 -0
  30. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/quantization.py +12 -8
  31. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/preprocessing/preprocess.py +11 -0
  32. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/preprocessing/windowers.py +5 -4
  33. braindecode-1.8.1.dev170036056/braindecode/version.py +1 -0
  34. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056/braindecode.egg-info}/PKG-INFO +1 -1
  35. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode.egg-info/SOURCES.txt +1 -0
  36. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/api.rst +3 -0
  37. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/user_guide/channel_strategies.rst +1 -1
  38. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/whats_new.rst +33 -0
  39. braindecode-1.8.1.dev169883370/braindecode/version.py +0 -1
  40. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/LICENSE.txt +0 -0
  41. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/MANIFEST.in +0 -0
  42. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/README.rst +0 -0
  43. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/__init__.py +0 -0
  44. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/augmentation/__init__.py +0 -0
  45. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/augmentation/base.py +0 -0
  46. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/augmentation/transforms.py +0 -0
  47. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/classifier.py +0 -0
  48. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/__init__.py +0 -0
  49. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/_notebook_viewer.py +0 -0
  50. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bbci.py +0 -0
  51. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bcicomp.py +0 -0
  52. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bids/__init__.py +0 -0
  53. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bids/datasets.py +0 -0
  54. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bids/format.py +0 -0
  55. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bids/hub.py +0 -0
  56. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bids/hub_format.py +0 -0
  57. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bids/hub_io.py +0 -0
  58. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bids/hub_validation.py +0 -0
  59. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/bids/iterable.py +0 -0
  60. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/chb_mit.py +0 -0
  61. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/collate.py +0 -0
  62. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/mne.py +0 -0
  63. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/moabb.py +0 -0
  64. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/nmt.py +0 -0
  65. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/registry.py +0 -0
  66. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/siena.py +0 -0
  67. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
  68. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/sleep_physionet.py +0 -0
  69. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/utils.py +0 -0
  70. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datasets/xy.py +0 -0
  71. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datautil/__init__.py +0 -0
  72. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datautil/channel_utils.py +0 -0
  73. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datautil/hub_formats.py +0 -0
  74. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/datautil/util.py +0 -0
  75. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/eegneuralnet.py +0 -0
  76. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/functional/__init__.py +0 -0
  77. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/functional/_real_dft.py +0 -0
  78. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/functional/functions.py +0 -0
  79. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/functional/initialization.py +0 -0
  80. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/atcnet.py +0 -0
  81. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/attentionbasenet.py +0 -0
  82. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/axon.py +0 -0
  83. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/barista.py +0 -0
  84. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/bendr.py +0 -0
  85. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/biot.py +0 -0
  86. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/brainbert.py +0 -0
  87. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/brainmodule.py +0 -0
  88. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/brant.py +0 -0
  89. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/cbramod.py +0 -0
  90. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/codebrain.py +0 -0
  91. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/config.py +0 -0
  92. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/contrawr.py +0 -0
  93. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/ctnet.py +0 -0
  94. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/dance.py +0 -0
  95. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/deepsleepnet.py +0 -0
  96. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/diver1.py +0 -0
  97. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eeg_clip.py +0 -0
  98. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegconformer.py +0 -0
  99. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegdino.py +0 -0
  100. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eeginception_erp.py +0 -0
  101. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eeginception_mi.py +0 -0
  102. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegitnet.py +0 -0
  103. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegminer.py +0 -0
  104. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegnet.py +0 -0
  105. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegpt.py +0 -0
  106. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegsimpleconv.py +0 -0
  107. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegsym.py +0 -0
  108. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/eegtcnet.py +0 -0
  109. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/emg2qwerty.py +0 -0
  110. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/fbcnet.py +0 -0
  111. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/fblightconvnet.py +0 -0
  112. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/fbmsnet.py +0 -0
  113. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/hybrid.py +0 -0
  114. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/ifnet.py +0 -0
  115. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/labram.py +0 -0
  116. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/meta_neuromotor.py +0 -0
  117. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/mirepnet.py +0 -0
  118. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/mscformer.py +0 -0
  119. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/msvtnet.py +0 -0
  120. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/mvpformer.py +0 -0
  121. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/neuropose.py +0 -0
  122. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/patchedtransformer.py +0 -0
  123. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/popt.py +0 -0
  124. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/sccnet.py +0 -0
  125. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/seizure_transformer.py +0 -0
  126. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/sensingdynamics.py +0 -0
  127. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/shallow_fbcsp.py +0 -0
  128. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/sinc_shallow.py +0 -0
  129. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
  130. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/sleepfm.py +0 -0
  131. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/sparcnet.py +0 -0
  132. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/sstdpn.py +0 -0
  133. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/steegformer.py +0 -0
  134. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/syncnet.py +0 -0
  135. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/tcformer.py +0 -0
  136. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/tfm_tokenizer.py +0 -0
  137. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/tmsanet.py +0 -0
  138. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/tsinception.py +0 -0
  139. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/models/vemg2pose.py +0 -0
  140. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/__init__.py +0 -0
  141. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/activation.py +0 -0
  142. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/attention.py +0 -0
  143. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/blocks.py +0 -0
  144. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/channels.py +0 -0
  145. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/convolution.py +0 -0
  146. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/dance_modules.py +0 -0
  147. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/filter.py +0 -0
  148. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/layers.py +0 -0
  149. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/linear.py +0 -0
  150. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/linear_attention.py +0 -0
  151. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/parametrization.py +0 -0
  152. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/popt_modules.py +0 -0
  153. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/stats.py +0 -0
  154. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/util.py +0 -0
  155. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/modules/wrapper.py +0 -0
  156. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/preprocessing/__init__.py +0 -0
  157. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
  158. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/preprocessing/mne_preprocess.py +0 -0
  159. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/preprocessing/util.py +0 -0
  160. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/regressor.py +0 -0
  161. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/samplers/__init__.py +0 -0
  162. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/samplers/base.py +0 -0
  163. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/samplers/ssl.py +0 -0
  164. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/training/__init__.py +0 -0
  165. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/training/callbacks.py +0 -0
  166. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/training/losses.py +0 -0
  167. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/training/scoring.py +0 -0
  168. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/util.py +0 -0
  169. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/visualization/__init__.py +0 -0
  170. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/visualization/activations.py +0 -0
  171. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/visualization/attribution.py +0 -0
  172. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/visualization/confusion_matrices.py +0 -0
  173. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/visualization/frequency.py +0 -0
  174. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/visualization/metrics.py +0 -0
  175. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/visualization/sanity.py +0 -0
  176. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode/visualization/topology.py +0 -0
  177. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode.egg-info/dependency_links.txt +0 -0
  178. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode.egg-info/requires.txt +0 -0
  179. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/braindecode.egg-info/top_level.txt +0 -0
  180. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/Makefile +0 -0
  181. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/_templates/autosummary/class.rst +0 -0
  182. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
  183. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/_templates/autosummary/function.rst +0 -0
  184. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
  185. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/agent_docs.rst +0 -0
  186. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/cite.rst +0 -0
  187. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/conf.py +0 -0
  188. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/help.rst +0 -0
  189. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/index.rst +0 -0
  190. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/install/install.rst +0 -0
  191. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/install/install_pip.rst +0 -0
  192. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/install/install_source.rst +0 -0
  193. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/categorization/attention.rst +0 -0
  194. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/categorization/channel.rst +0 -0
  195. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/categorization/convolution.rst +0 -0
  196. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/categorization/filterbank.rst +0 -0
  197. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/categorization/gnn.rst +0 -0
  198. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/categorization/interpretable.rst +0 -0
  199. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/categorization/lbm.rst +0 -0
  200. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/categorization/recurrent.rst +0 -0
  201. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/categorization/spd.rst +0 -0
  202. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/models.rst +0 -0
  203. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/models_categorization.rst +0 -0
  204. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/models_table.rst +0 -0
  205. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/models/models_visualization.rst +0 -0
  206. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/docs/sg_execution_times.rst +0 -0
  207. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/pyproject.toml +0 -0
  208. {braindecode-1.8.1.dev169883370 → braindecode-1.8.1.dev170036056}/setup.cfg +0 -0
@@ -52,6 +52,7 @@ The following components are licensed under the MIT License:
52
52
  - `braindecode/modules/linear_attention.py`
53
53
  - `braindecode/models/seizure_transformer.py`
54
54
  - `docs/_static/model/seizure_transformer_arch.png`
55
+ - `braindecode/models/guetschel2026.py`
55
56
  - `braindecode/models/tmsanet.py`
56
57
 
57
58
  The `brainomni.py` file is a derivative of `OpenTSLab/BrainOmni` (MIT), whose
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 1.8.1.dev169883370
3
+ Version: 1.8.1.dev170036056
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>
@@ -932,7 +932,7 @@ def _rotate_signals(
932
932
  transformed_X = X.clone()
933
933
  sensors_positions = list(sensors_positions_matrix)
934
934
  for s, rot_sensors_matrix in enumerate(rot_sensors_matrices):
935
- rot_sensors_positions = list(rot_sensors_matrix.T)
935
+ rot_sensors_positions = list(rot_sensors_matrix)
936
936
  for time in range(X.shape[-1]):
937
937
  interpolator_t = Rbf(*sensors_positions, X[s, :, time])
938
938
  transformed_X[s, :, time] = torch.from_numpy(
@@ -14,6 +14,7 @@ from __future__ import annotations
14
14
  import bisect
15
15
  import html as _html
16
16
  import json
17
+ import mmap
17
18
  import os
18
19
  import shutil
19
20
  import warnings
@@ -28,6 +29,7 @@ import mne
28
29
  import mne.io
29
30
  import numpy as np
30
31
  import pandas as pd
32
+ from mne.io.constants import FIFF
31
33
  from mne.utils import _soft_import
32
34
  from mne.utils.docs import deprecated
33
35
  from torch.utils.data import ConcatDataset, Dataset, IterableDataset
@@ -220,6 +222,47 @@ def _compute_ch_pos(info, targets_from):
220
222
  return pos
221
223
 
222
224
 
225
+ def _read_fif_window(raw, start, stop):
226
+ """Samples ``start:stop`` of a lazy FIF raw, copied from the file in one go.
227
+
228
+ mne reads, casts and calibrates the FIF data buffers of a range one at a
229
+ time (60 Python steps for a 60-s window saved with 1-s buffers, each through
230
+ a buffered file whose buffer is 4 MB on network file systems). Here one
231
+ slice of the memory-mapped file holds the bytes of every buffer in the
232
+ range and one multiply calibrates them, with mne's arithmetic (float64 data
233
+ times ``raw._cals``), so the values equal ``raw._getitem``'s. Returns None
234
+ (the caller uses mne) unless ``raw`` is a lazy, single-file, uncompressed
235
+ FIF raw of float32 buffers without projector, compensation or gaps.
236
+ """
237
+ if (
238
+ not isinstance(raw, mne.io.Raw)
239
+ or raw.preload
240
+ or len(raw._raw_extras) != 1
241
+ or raw._projector is not None
242
+ or raw._comp is not None
243
+ ):
244
+ return None
245
+ extra = raw._raw_extras[0]
246
+ fname, bounds = extra["filename"], extra["bounds"]
247
+ if not isinstance(fname, Path) or fname.suffix == ".gz":
248
+ return None
249
+ start, stop = start + raw._first_samps[0], stop + raw._first_samps[0]
250
+ first = np.searchsorted(bounds, start, side="right") - 1
251
+ ents = extra["ent"][first : np.searchsorted(bounds, stop)]
252
+ if not ents or any(e is None or e.type != FIFF.FIFFT_FLOAT for e in ents):
253
+ return None
254
+ pos = ents[0].pos
255
+ # mmap: no copy through a 4 MB read buffer, and a cold file is read around
256
+ # the window by the kernel (as mne's 4 MB reads did), not window by window
257
+ with open(fname, "rb") as f, mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m:
258
+ buf = m[pos : ents[-1].pos + 16 + ents[-1].size]
259
+ one = np.concatenate(
260
+ [np.frombuffer(buf, ">f4", e.size // 4, e.pos + 16 - pos) for e in ents]
261
+ ).reshape(-1, extra["orig_nchan"])[start - bounds[first] : stop - bounds[first]]
262
+ picked = one[:, raw._read_picks[0]].T
263
+ return np.multiply(picked, raw._cals[:, np.newaxis], order="C")
264
+
265
+
223
266
  def _window_info(crop_inds, sfreq):
224
267
  """Extract window size from crop indices.
225
268
 
@@ -823,9 +866,11 @@ class EEGWindowsDataset(_ZarrMixin, RecordDataset):
823
866
  if self._zarr_data is not None:
824
867
  X = self._zarr_data[:, i_start:i_stop]
825
868
  else:
826
- X = self.raw._getitem(
827
- (slice(None), slice(i_start, i_stop)), return_times=False
828
- )
869
+ X = _read_fif_window(self.raw, i_start, i_stop)
870
+ if X is None:
871
+ X = self.raw._getitem(
872
+ (slice(None), slice(i_start, i_stop)), return_times=False
873
+ )
829
874
  X = np.array(X, dtype="float32")
830
875
  if self.transform is not None:
831
876
  X = self.transform(X)
@@ -1672,7 +1717,8 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
1672
1717
  kwargs_path = os.path.join(path, ".".join([kwarg_name, "json"]))
1673
1718
  kwargs = getattr(self, kwarg_name)
1674
1719
  if kwargs is not None:
1675
- json.dump(kwargs, open(kwargs_path, "w"))
1720
+ with open(kwargs_path, "w") as f:
1721
+ json.dump(kwargs, f)
1676
1722
 
1677
1723
  @property
1678
1724
  def description(self) -> pd.DataFrame:
@@ -1742,7 +1788,10 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
1742
1788
  # Create path if it doesn't exist
1743
1789
  os.makedirs(path, exist_ok=True)
1744
1790
 
1745
- path_contents = os.listdir(path)
1791
+ # With an offset the caller fills one directory piece by piece (preprocess
1792
+ # saves each recording at its index), so the other entries are expected:
1793
+ # skip the scan that would stat them all on every call and list them in a warning.
1794
+ path_contents = os.listdir(path) if offset == 0 else []
1746
1795
  n_sub_dirs = len(
1747
1796
  [e for e in path_contents if os.path.isdir(os.path.join(path, e))]
1748
1797
  )
@@ -11,10 +11,12 @@ TUH Abnormal EEG Corpus.
11
11
  from __future__ import annotations
12
12
 
13
13
  import glob
14
+ import json
14
15
  import os
15
16
  import re
16
17
  import warnings
17
18
  from datetime import datetime, timezone
19
+ from functools import cache
18
20
  from pathlib import Path
19
21
  from typing import Iterable, Literal
20
22
  from unittest import mock
@@ -183,11 +185,8 @@ class TUH(BaseConcatDataset):
183
185
  }
184
186
  raw.rename_channels(mapping_strip)
185
187
 
186
- montage1005 = mne.channels.make_standard_montage(
187
- resolve_montage_name("standard_1005")
188
- )
189
188
  mapping_eeg_names = {
190
- c.upper(): c for c in montage1005.ch_names if c.upper() in raw.ch_names
189
+ c.upper(): c for c in _standard_1005().ch_names if c.upper() in raw.ch_names
191
190
  }
192
191
 
193
192
  # Set channels whose type could not be inferred (defaulted to "eeg") to "misc":
@@ -210,10 +209,7 @@ class TUH(BaseConcatDataset):
210
209
 
211
210
  @staticmethod
212
211
  def _set_montage(raw):
213
- montage = mne.channels.make_standard_montage(
214
- resolve_montage_name("standard_1005")
215
- )
216
- raw.set_montage(montage, on_missing="ignore")
212
+ raw.set_montage(_standard_1005(), on_missing="ignore")
217
213
 
218
214
  @staticmethod
219
215
  def _create_dataset(
@@ -245,7 +241,11 @@ class TUH(BaseConcatDataset):
245
241
  # file paths, use this instead as before
246
242
  if "year" in description:
247
243
  meas_date = meas_date.replace(*description[["year", "month", "day"]])
248
- raw.set_meas_date(meas_date)
244
+ # FIF (e.g. preprocess(..., save_dir=...)) stores dates from 1901-12-13 to
245
+ # 2038-01-19 only: undated recordings (year 1 above) and de-identified ones
246
+ # (TUAB has 1899-12-30) keep their date in the description only.
247
+ in_fif_range = -(2**31) <= meas_date.timestamp() < 2**31
248
+ raw.set_meas_date(meas_date if in_fif_range else None)
249
249
 
250
250
  d = {
251
251
  "age": int(age),
@@ -255,9 +255,9 @@ class TUH(BaseConcatDataset):
255
255
  # if not, get it from meas_date in raw.info and add to description
256
256
  # if meas_date is None, create fake one
257
257
  if "year" not in description:
258
- d["year"] = raw.info["meas_date"].year
259
- d["month"] = raw.info["meas_date"].month
260
- d["day"] = raw.info["meas_date"].day
258
+ d["year"] = meas_date.year
259
+ d["month"] = meas_date.month
260
+ d["day"] = meas_date.day
261
261
 
262
262
  # read info relevant for preprocessing from raw without loading it
263
263
  if add_physician_reports:
@@ -269,6 +269,12 @@ class TUH(BaseConcatDataset):
269
269
  return base_dataset
270
270
 
271
271
 
272
+ @cache
273
+ def _standard_1005():
274
+ # Built once per process: set_montage copies the montage before using it.
275
+ return mne.channels.make_standard_montage(resolve_montage_name("standard_1005"))
276
+
277
+
272
278
  def _create_description(file_paths, version, ds_name):
273
279
  descriptions = [
274
280
  _parse_description_from_file_path(f, version, ds_name) for f in file_paths
@@ -289,7 +295,8 @@ def _read_date(file_path):
289
295
  date_path = file_path.replace(".edf", "_date.txt")
290
296
  # if date file exists, read it
291
297
  if os.path.exists(date_path):
292
- description = pd.read_json(date_path, typ="series").to_dict()
298
+ with open(date_path) as f:
299
+ description = json.load(f)
293
300
  # otherwise read edf file, extract date and store to file
294
301
  else:
295
302
  raw = mne.io.read_raw_edf(file_path, preload=False, verbose="error")
@@ -79,7 +79,8 @@ def _outdated_load_concat_dataset(path, preload, ids_to_load=None, target_name=N
79
79
  for path in paths:
80
80
  if is_raw and target_name is None:
81
81
  target_file_name = path / "target_name.json"
82
- target_name = json.load(open(target_file_name, "r"))["target_name"]
82
+ with open(target_file_name) as f:
83
+ target_name = json.load(f)["target_name"]
83
84
 
84
85
  all_signals, description = _load_signals_and_description(
85
86
  path=path, preload=preload, is_raw=is_raw, ids_to_load=ids_to_load
@@ -264,7 +265,8 @@ def _load_parallel(path, i, preload, is_raw, has_stored_windows):
264
265
  target_file_path = sub_dir / "target_name.json"
265
266
  target_name = None
266
267
  if target_file_path.exists():
267
- target_name = json.load(open(target_file_path, "r"))["target_name"]
268
+ with open(target_file_path) as f:
269
+ target_name = json.load(f)["target_name"]
268
270
 
269
271
  if is_raw and (not has_stored_windows):
270
272
  dataset = RawDataset(signals, description, target_name)
@@ -304,8 +306,8 @@ def _load_kwargs_json(kwargs_name, sub_dir):
304
306
  kwargs_file_name = ".".join([kwargs_name, "json"])
305
307
  kwargs_file_path = os.path.join(sub_dir, kwargs_file_name)
306
308
  if os.path.exists(kwargs_file_path):
307
- kwargs = json.load(open(kwargs_file_path, "r"))
308
- return kwargs
309
+ with open(kwargs_file_path) as f:
310
+ return json.load(f)
309
311
 
310
312
 
311
313
  def _is_outdated_saved(path):
@@ -39,6 +39,7 @@ from .emg2qwerty import EMG2QwertyNet
39
39
  from .fbcnet import FBCNet
40
40
  from .fblightconvnet import FBLightConvNet
41
41
  from .fbmsnet import FBMSNet
42
+ from .guetschel2026 import Guetschel2026
42
43
  from .hybrid import HybridNet
43
44
  from .ifnet import IFNet
44
45
  from .labram import Labram
@@ -139,6 +140,7 @@ __all__ = [
139
140
  "FBCNet",
140
141
  "FBLightConvNet",
141
142
  "FBMSNet",
143
+ "Guetschel2026",
142
144
  "MetaNeuromotorHand",
143
145
  "HybridNet",
144
146
  "IFNet",
@@ -143,6 +143,10 @@ class AttnSleep(EEGModuleMixin, nn.Module):
143
143
  sfreq=sfreq,
144
144
  )
145
145
  del n_outputs, n_chans, chs_info, n_times, input_window_seconds, sfreq
146
+ if self._n_chans_for_jit not in (None, 1):
147
+ raise ValueError(
148
+ f"AttnSleep takes single-channel input; got n_chans={self._n_chans_for_jit}."
149
+ )
146
150
 
147
151
  self.mapping = {
148
152
  "fc.weight": "final_layer.weight",
@@ -46,6 +46,24 @@ _GEOMETRY_KWARGS = (
46
46
  )
47
47
 
48
48
 
49
+ def _too_short_input_error(exc: RuntimeError, input_shape) -> Optional[ValueError]:
50
+ """ValueError for a layer that found the input too short, else None."""
51
+ if not str(exc).endswith(
52
+ (
53
+ "Output size is too small",
54
+ "Kernel size can't be greater than actual input size",
55
+ )
56
+ ):
57
+ return None
58
+ return ValueError(
59
+ "During model prediction RuntimeError was thrown showing that at some "
60
+ f"layer `{str(exc).split('.')[-1]}` (see above in the stacktrace). This "
61
+ "could be caused by providing too small `n_times`/`input_window_seconds`. "
62
+ "Model may require longer chunks of signal in the input than "
63
+ f"{input_shape}."
64
+ )
65
+
66
+
49
67
  _HF_INSTALL_HINT = (
50
68
  "requires the `huggingface_hub` package. "
51
69
  "Install with: pip install 'braindecode[hub]'"
@@ -483,6 +501,18 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
483
501
  # Called by torch.jit.script before compiling the model.
484
502
  return make_parametrizations_scriptable(self)
485
503
 
504
+ def __call__(self, *args, **kwargs):
505
+ # An input shorter than the layers need raises ValueError, not a torch
506
+ # RuntimeError from deep inside forward.
507
+ try:
508
+ return super().__call__(*args, **kwargs)
509
+ except RuntimeError as exc:
510
+ shape = tuple(args[0].shape) if args and hasattr(args[0], "shape") else None
511
+ error = _too_short_input_error(exc, shape)
512
+ if error is None:
513
+ raise
514
+ raise error from exc
515
+
486
516
  def get_output_shape(self) -> tuple[int, ...]:
487
517
  """Returns shape of neural network output for batch size equal 1.
488
518
 
@@ -506,21 +536,10 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
506
536
  .shape
507
537
  )
508
538
  except RuntimeError as exc:
509
- if str(exc).endswith(
510
- (
511
- "Output size is too small",
512
- "Kernel size can't be greater than actual input size",
513
- )
514
- ):
515
- msg = (
516
- "During model prediction RuntimeError was thrown showing that at some "
517
- f"layer `{str(exc).split('.')[-1]}` (see above in the stacktrace). This "
518
- "could be caused by providing too small `n_times`/`input_window_seconds`. "
519
- "Model may require longer chunks of signal in the input than "
520
- f"{self.input_shape}."
521
- )
522
- raise ValueError(msg) from exc
523
- raise exc
539
+ error = _too_short_input_error(exc, self.input_shape)
540
+ if error is None:
541
+ raise
542
+ raise error from exc
524
543
 
525
544
  def get_config(self) -> dict:
526
545
  """Return a JSON-serializable dict of all ``__init__`` parameters.
@@ -29,15 +29,21 @@ from braindecode.modules.quantization import ResidualVectorQuantizer
29
29
 
30
30
 
31
31
  class _SELU(nn.SELU):
32
- """``nn.SELU`` written as ``scale * x`` / ELU: same values and gradients, and
33
- trainable on Gaudi, whose ELU backward only supports ``scale == 1``."""
32
+ """``nn.SELU`` as ``ELU(x, alpha * scale)`` times ``scale`` where ``x > 0``:
33
+ same values and gradients, and trainable on Gaudi, whose ELU backward only
34
+ supports ``scale == 1``."""
34
35
 
35
36
  def forward(self, x: torch.Tensor) -> torch.Tensor:
36
37
  alpha, scale = (
37
38
  1.6732632423543772848170429916717,
38
39
  1.0507009873554804934193349852946,
39
40
  )
40
- return torch.where(x > 0, x * scale, F.elu(x, alpha * scale))
41
+ # ELU is x on the positive side, so this equals the where(x > 0, x * scale,
42
+ # elu) form bit for bit, without its zero-filled where backward. The
43
+ # factor is at least float32, like the scalar multiply's compute type.
44
+ one = x.new_ones((), dtype=torch.promote_types(x.dtype, torch.float32))
45
+ factor = torch.where(x > 0, one * scale, one)
46
+ return (F.elu(x, alpha * scale) * factor).to(x.dtype)
41
47
 
42
48
 
43
49
  class BrainTokenizer(EEGModuleMixin, nn.Module, license="mit"):
@@ -314,6 +314,11 @@ class CSBrain(EEGModuleMixin, nn.Module):
314
314
  sfreq=sfreq,
315
315
  )
316
316
  del n_chans, chs_info, n_times, input_window_seconds, sfreq, n_outputs
317
+ n_times = self._n_times_or_none()
318
+ if n_times is not None and n_times % patch_size:
319
+ raise ValueError(
320
+ f"n_times ({n_times}) must be a multiple of patch_size ({patch_size})."
321
+ )
317
322
 
318
323
  self.rearrange = Rearrange(
319
324
  "batch n_chans (n_patch patch_size) -> batch n_chans n_patch patch_size",
@@ -170,6 +170,10 @@ class Deep4Net(EEGModuleMixin, nn.Sequential):
170
170
  ):
171
171
  resolved_n_times = round(self._input_window_seconds * self._sfreq)
172
172
 
173
+ if resolved_n_times is not None and resolved_n_times >= min_n_times:
174
+ # The bound above ignores stride_before_pool and an integer
175
+ # final_conv_length; inputs it admits are checked with the exact one.
176
+ min_n_times = self._get_min_n_times(exact=True)
173
177
  if resolved_n_times is not None and resolved_n_times < min_n_times:
174
178
  scaling_factor = resolved_n_times / min_n_times
175
179
  warn(
@@ -363,13 +367,15 @@ class Deep4Net(EEGModuleMixin, nn.Sequential):
363
367
 
364
368
  self.train()
365
369
 
366
- def _get_min_n_times(self) -> int:
370
+ def _get_min_n_times(self, exact: bool = False) -> int:
367
371
  """
368
372
  Calculate the minimum number of time samples required for the model
369
373
  to work with the given temporal parameters.
370
374
  """
371
375
  # Start with the minimum valid output length of the network (1)
372
376
  min_len = 1
377
+ if exact and isinstance(self.final_conv_length, int):
378
+ min_len = self.final_conv_length
373
379
 
374
380
  # List of conv kernel sizes and pool parameters for the 4 blocks, in reverse order
375
381
  # Each tuple: (filter_length, pool_length, pool_stride)
@@ -382,6 +388,9 @@ class Deep4Net(EEGModuleMixin, nn.Sequential):
382
388
 
383
389
  # Work backward from the last layer to the input
384
390
  for filter_len, pool_len, pool_stride in block_params:
391
+ if exact and self.stride_before_pool: # strided conv, then pool stride 1
392
+ min_len = pool_stride * (min_len + pool_len - 2) + filter_len
393
+ continue
385
394
  # Reverse the pooling operation
386
395
  # L_in = stride * (L_out - 1) + kernel_size
387
396
  min_len = pool_stride * (min_len - 1) + pool_len
@@ -142,6 +142,11 @@ def _build_initial_adjacency(chs_info, n_chans, n_neighbors=5):
142
142
  electrode_positions = extract_channel_locations_from_chs_info(
143
143
  chs_info, num_channels=n_chans
144
144
  )
145
+ # MNE stores NaN for a channel without a position.
146
+ if electrode_positions is not None and not (
147
+ len(electrode_positions) == n_chans and np.isfinite(electrode_positions).all()
148
+ ):
149
+ electrode_positions = None
145
150
 
146
151
  if electrode_positions is None and chs_info is not None:
147
152
  # Try to infer positions from channel names via a standard montage
@@ -162,6 +167,8 @@ def _build_initial_adjacency(chs_info, n_chans, n_neighbors=5):
162
167
  "with 3-D positions or that channel names match a standard montage."
163
168
  )
164
169
 
170
+ if n_chans < 2:
171
+ raise ValueError("DGCNN needs at least 2 channels to build its channel graph.")
165
172
  n_neighbors_capped = min(n_neighbors, n_chans - 1)
166
173
 
167
174
  # Pairwise Euclidean distances
@@ -9,6 +9,7 @@ import torch
9
9
  import torch.nn as nn
10
10
  from einops.layers.torch import Rearrange
11
11
 
12
+ from braindecode.functional import fft_conv1d, prefer_fft_conv
12
13
  from braindecode.models.base import EEGModuleMixin
13
14
  from braindecode.modules import Conv2dWithConstraint, LinearWithConstraint
14
15
 
@@ -234,7 +235,7 @@ class EEGNeX(EEGModuleMixin, nn.Module):
234
235
  )
235
236
 
236
237
  self.block_2 = nn.Sequential(
237
- nn.Conv2d(
238
+ _TemporalConv(
238
239
  in_channels=self.filter_1,
239
240
  out_channels=self.filter_2,
240
241
  kernel_size=self.kernel_block_1_2,
@@ -352,3 +353,17 @@ class EEGNeX(EEGModuleMixin, nn.Module):
352
353
  self.filter_1 * T5
353
354
  ) # filter_1 is the number of channels before flatten
354
355
  return final_in_features
356
+
357
+
358
+ class _TemporalConv(nn.Conv2d):
359
+ """``(1, k)`` Conv2d with "same" output length; on CPU, through
360
+ :func:`~braindecode.functional.fft_conv1d` where
361
+ :func:`~braindecode.functional.prefer_fft_conv` expects it to be faster."""
362
+
363
+ def forward(self, x: torch.Tensor) -> torch.Tensor:
364
+ if not prefer_fft_conv(x, self.kernel_size[1]):
365
+ return self._conv_forward(x, self.weight, self.bias)
366
+ b, _, h, t = x.shape # the conv1d of each of the b * h rows
367
+ x = x.transpose(1, 2).reshape(b * h, -1, t)
368
+ x = fft_conv1d(x, self.weight.squeeze(2), self.bias)
369
+ return x.unflatten(0, [b, h]).transpose(1, 2)