braindecode 2.1.0.dev183574403__tar.gz → 2.1.0.dev184110306__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.dev183574403/braindecode.egg-info → braindecode-2.1.0.dev184110306}/PKG-INFO +1 -3
  2. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/classifier.py +37 -10
  3. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/base.py +77 -71
  4. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/bids/hub.py +32 -65
  5. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/bids/hub_io.py +148 -42
  6. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/tuh.py +68 -139
  7. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/utils.py +1 -4
  8. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datautil/__init__.py +0 -1
  9. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datautil/hub_formats.py +30 -62
  10. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datautil/util.py +34 -40
  11. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/eegneuralnet.py +38 -7
  12. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/functional/__init__.py +1 -8
  13. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/functional/attention.py +17 -5
  14. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/functional/channel_mask.py +9 -2
  15. braindecode-2.1.0.dev184110306/braindecode/functional/channels.py +120 -0
  16. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/functional/functions.py +11 -3
  17. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/__init__.py +2 -3
  18. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/attn_sleep.py +182 -46
  19. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/axon.py +1 -7
  20. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/base.py +77 -91
  21. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/bbl.py +55 -84
  22. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/bendr.py +2 -11
  23. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/biot.py +4 -13
  24. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/brainomni.py +16 -230
  25. braindecode-2.1.0.dev184110306/braindecode/models/caresleepnet.py +445 -0
  26. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/cbramod.py +3 -9
  27. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/codebrain.py +1 -7
  28. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/config.py +15 -3
  29. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/corteg.py +59 -13
  30. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/csbrain.py +10 -37
  31. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/deep4.py +12 -2
  32. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/dgcnn.py +5 -76
  33. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/duin.py +1 -7
  34. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eeg_clip.py +5 -17
  35. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegconformer.py +20 -9
  36. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegitnet.py +15 -1
  37. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegnet.py +23 -5
  38. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegpt.py +13 -8
  39. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegtcnet.py +32 -18
  40. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/emg2qwerty.py +8 -21
  41. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/gcnsnet.py +46 -22
  42. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/geonirs.py +368 -496
  43. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/jung_mae.py +89 -210
  44. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/labram.py +254 -229
  45. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/medformer.py +1 -6
  46. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/meggpt.py +106 -133
  47. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/megxl.py +8 -5
  48. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/meta_neuromotor.py +10 -15
  49. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/mirepnet.py +1 -7
  50. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/model.html.jinja +1 -1
  51. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/msvtnet.py +15 -31
  52. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/mtrenirs.py +9 -21
  53. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/neuropose.py +25 -0
  54. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/nice.py +66 -54
  55. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/patchedtransformer.py +1 -6
  56. braindecode-2.1.0.dev184110306/braindecode/models/pratibha2.py +494 -0
  57. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/reve.py +158 -90
  58. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/sensingdynamics.py +9 -0
  59. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/shallow_fbcsp.py +11 -2
  60. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/signal_jepa.py +4 -28
  61. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/sleepfm.py +31 -33
  62. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/steegformer.py +50 -128
  63. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/tccnet.py +131 -73
  64. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/tinymyo.py +78 -113
  65. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/tsinception.py +23 -19
  66. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/util.py +78 -18
  67. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/vemg2pose.py +11 -0
  68. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/zuna.py +1 -7
  69. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/__init__.py +4 -0
  70. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/channels.py +136 -165
  71. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/convolution.py +61 -0
  72. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/filter.py +43 -30
  73. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/layers.py +37 -5
  74. braindecode-2.1.0.dev184110306/braindecode/modules/spatial_temporal.py +164 -0
  75. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/preprocessing/preprocess.py +0 -15
  76. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/preprocessing/windowers.py +3 -1
  77. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/training/losses.py +5 -54
  78. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/util.py +6 -1
  79. braindecode-2.1.0.dev184110306/braindecode/version.py +1 -0
  80. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/visualization/attribution.py +23 -10
  81. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306/braindecode.egg-info}/PKG-INFO +1 -3
  82. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode.egg-info/SOURCES.txt +1 -0
  83. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode.egg-info/requires.txt +0 -2
  84. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/api.rst +16 -2
  85. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/cite.rst +2 -2
  86. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/user_guide/channel_strategies.rst +0 -9
  87. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/whats_new.rst +181 -227
  88. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/pyproject.toml +1 -2
  89. braindecode-2.1.0.dev183574403/braindecode/functional/channels.py +0 -294
  90. braindecode-2.1.0.dev183574403/braindecode/models/caresleepnet.py +0 -356
  91. braindecode-2.1.0.dev183574403/braindecode/models/pratibha2.py +0 -518
  92. braindecode-2.1.0.dev183574403/braindecode/version.py +0 -1
  93. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/LICENSE.txt +0 -0
  94. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/MANIFEST.in +0 -0
  95. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/NOTICE.txt +0 -0
  96. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/README.rst +0 -0
  97. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/__init__.py +0 -0
  98. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/augmentation/__init__.py +0 -0
  99. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/augmentation/base.py +0 -0
  100. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/augmentation/functional.py +0 -0
  101. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/augmentation/transforms.py +0 -0
  102. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/__init__.py +0 -0
  103. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/_notebook_viewer.py +0 -0
  104. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/bbci.py +0 -0
  105. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/bcicomp.py +0 -0
  106. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/bids/__init__.py +0 -0
  107. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/bids/datasets.py +0 -0
  108. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/bids/hub_format.py +0 -0
  109. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/bids/hub_validation.py +0 -0
  110. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/bids/iterable.py +0 -0
  111. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/chb_mit.py +0 -0
  112. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/collate.py +0 -0
  113. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/mne.py +0 -0
  114. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/moabb.py +0 -0
  115. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/nmt.py +0 -0
  116. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/registry.py +0 -0
  117. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/siena.py +0 -0
  118. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
  119. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/sleep_physionet.py +0 -0
  120. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datasets/xy.py +0 -0
  121. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datautil/channel_utils.py +0 -0
  122. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/datautil/serialization.py +0 -0
  123. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/functional/_lfilter.py +0 -0
  124. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/functional/_real_dft.py +0 -0
  125. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/functional/initialization.py +0 -0
  126. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/functional/patches.py +0 -0
  127. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/atcnet.py +0 -0
  128. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/attentionbasenet.py +0 -0
  129. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/barista.py +0 -0
  130. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/brainbert.py +0 -0
  131. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/brainmodule.py +0 -0
  132. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/brant.py +0 -0
  133. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/contrawr.py +0 -0
  134. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/ctnet.py +0 -0
  135. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/dance.py +0 -0
  136. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/deepsleepnet.py +0 -0
  137. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/diver1.py +0 -0
  138. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegdino.py +0 -0
  139. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eeginception_erp.py +0 -0
  140. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eeginception_mi.py +0 -0
  141. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegminer.py +0 -0
  142. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegnex.py +0 -0
  143. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegsimpleconv.py +0 -0
  144. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/eegsym.py +0 -0
  145. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/epint.py +0 -0
  146. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/fbcnet.py +0 -0
  147. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/fblightconvnet.py +0 -0
  148. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/fbmsnet.py +0 -0
  149. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/fnirs4d.py +0 -0
  150. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/fnirs_cnn1d.py +0 -0
  151. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/fnirs_t.py +0 -0
  152. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/fnirsnet.py +0 -0
  153. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/guetschel2026.py +0 -0
  154. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/hybrid.py +0 -0
  155. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/ifnet.py +0 -0
  156. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/luna.py +0 -0
  157. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/mapa.py +0 -0
  158. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/mscformer.py +0 -0
  159. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/mvpformer.py +0 -0
  160. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/neurorvq.py +0 -0
  161. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/neurorvq_tokenizer.py +0 -0
  162. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/popt.py +0 -0
  163. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/sccnet.py +0 -0
  164. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/seizure_transformer.py +0 -0
  165. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/sinc_shallow.py +0 -0
  166. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
  167. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
  168. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/sparcnet.py +0 -0
  169. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/sstdpn.py +0 -0
  170. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/summary.csv +0 -0
  171. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/syncnet.py +0 -0
  172. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/tcformer.py +0 -0
  173. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/tcn.py +0 -0
  174. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/tfm_tokenizer.py +0 -0
  175. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/tidnet.py +0 -0
  176. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/tmsanet.py +0 -0
  177. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/models/usleep.py +0 -0
  178. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/activation.py +0 -0
  179. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/attention.py +0 -0
  180. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/blocks.py +0 -0
  181. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/dance_modules.py +0 -0
  182. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/linear.py +0 -0
  183. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/linear_attention.py +0 -0
  184. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/parametrization.py +0 -0
  185. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/quantization.py +0 -0
  186. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/seanet.py +0 -0
  187. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/stats.py +0 -0
  188. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/util.py +0 -0
  189. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/modules/wrapper.py +0 -0
  190. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/preprocessing/__init__.py +0 -0
  191. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
  192. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/preprocessing/mne_preprocess.py +0 -0
  193. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/preprocessing/util.py +0 -0
  194. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/regressor.py +0 -0
  195. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/samplers/__init__.py +0 -0
  196. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/samplers/base.py +0 -0
  197. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/samplers/ssl.py +0 -0
  198. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/training/__init__.py +0 -0
  199. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/training/_trial_aggregation.py +0 -0
  200. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/training/callbacks.py +0 -0
  201. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/training/scoring.py +0 -0
  202. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/visualization/__init__.py +0 -0
  203. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/visualization/activations.py +0 -0
  204. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/visualization/confusion_matrices.py +0 -0
  205. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/visualization/frequency.py +0 -0
  206. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/visualization/metrics.py +0 -0
  207. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/visualization/sanity.py +0 -0
  208. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode/visualization/topology.py +0 -0
  209. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode.egg-info/dependency_links.txt +0 -0
  210. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/braindecode.egg-info/top_level.txt +0 -0
  211. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/Makefile +0 -0
  212. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/_templates/autosummary/class.rst +0 -0
  213. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
  214. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/_templates/autosummary/function.rst +0 -0
  215. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
  216. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/agent_docs.rst +0 -0
  217. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/conf.py +0 -0
  218. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/help.rst +0 -0
  219. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/index.rst +0 -0
  220. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/install/gaudi.rst +0 -0
  221. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/install/install.rst +0 -0
  222. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/install/install_pip.rst +0 -0
  223. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/install/install_source.rst +0 -0
  224. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/categorization/attention.rst +0 -0
  225. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/categorization/channel.rst +0 -0
  226. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/categorization/convolution.rst +0 -0
  227. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/categorization/filterbank.rst +0 -0
  228. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/categorization/gnn.rst +0 -0
  229. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/categorization/interpretable.rst +0 -0
  230. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/categorization/lbm.rst +0 -0
  231. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/categorization/recurrent.rst +0 -0
  232. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/categorization/spd.rst +0 -0
  233. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/models.rst +0 -0
  234. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/models_categorization.rst +0 -0
  235. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/models_table.rst +0 -0
  236. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/models/models_visualization.rst +0 -0
  237. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/sg_execution_times.rst +0 -0
  238. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/docs/user_guide/cropped_inference.rst +0 -0
  239. {braindecode-2.1.0.dev183574403 → braindecode-2.1.0.dev184110306}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 2.1.0.dev183574403
3
+ Version: 2.1.0.dev184110306
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>
@@ -44,7 +44,6 @@ Requires-Dist: torch>=2.7; python_version < "3.12" and extra == "eegprep"
44
44
  Provides-Extra: hub
45
45
  Requires-Dist: huggingface_hub[torch]>=0.20.0; extra == "hub"
46
46
  Requires-Dist: zarr>=3.1; extra == "hub"
47
- Requires-Dist: filelock; extra == "hub"
48
47
  Provides-Extra: viz
49
48
  Requires-Dist: captum>=0.7.0; extra == "viz"
50
49
  Provides-Extra: sae
@@ -58,7 +57,6 @@ Requires-Dist: codecov; extra == "tests"
58
57
  Requires-Dist: pytest_cases; extra == "tests"
59
58
  Requires-Dist: mypy; extra == "tests"
60
59
  Requires-Dist: ipython; extra == "tests"
61
- Requires-Dist: PyYAML; extra == "tests"
62
60
  Requires-Dist: transformers>=4.57.0; extra == "tests"
63
61
  Requires-Dist: bids_validator; extra == "tests"
64
62
  Provides-Extra: typing
@@ -8,6 +8,7 @@
8
8
  # License: BSD (3-clause)
9
9
 
10
10
  import warnings
11
+ from functools import partial
11
12
 
12
13
  from skorch import NeuralNet
13
14
  from skorch.callbacks import EpochScoring
@@ -16,7 +17,6 @@ from torch import Tensor
16
17
  from torch.nn import CrossEntropyLoss
17
18
 
18
19
  from .eegneuralnet import _EEGNeuralNet
19
- from .training.losses import CroppedLoss, _class_target
20
20
  from .training.scoring import predict_trials
21
21
  from .util import ThrowAwayIndexLoader, update_estimator_docstring
22
22
 
@@ -101,6 +101,16 @@ class EEGClassifier(_EEGNeuralNet, NeuralNetClassifier):
101
101
  else:
102
102
  return iterator
103
103
 
104
+ def _get_predict_nonlinearity(self):
105
+ nonlinearity = super()._get_predict_nonlinearity()
106
+ if self.predict_nonlinearity == "auto" and len(self._criteria) == 1:
107
+ criterion = getattr(self, self._criteria[0] + "_")
108
+ if isinstance(getattr(criterion, "_orig_mod", criterion), CrossEntropyLoss):
109
+ # CrossEntropyLoss reads the classes on axis 1, also for dense outputs
110
+ # (batch, classes, positions); skorch's softmax uses the last axis.
111
+ return partial(Tensor.softmax, dim=1)
112
+ return nonlinearity
113
+
104
114
  def predict_proba(self, X):
105
115
  """Return the output of the module's forward method as a numpy.
106
116
 
@@ -148,6 +158,9 @@ class EEGClassifier(_EEGNeuralNet, NeuralNetClassifier):
148
158
  def get_loss(self, y_pred, y_true, *args, **kwargs):
149
159
  """Return the loss for this batch by calling NeuralNet get_loss.
150
160
 
161
+ A floating ``y_true`` with the shape of ``y_pred`` is read as class
162
+ probabilities; with any other shape, as class indices, cast to int64.
163
+
151
164
  Parameters
152
165
  ----------
153
166
  y_pred : torch tensor
@@ -175,15 +188,7 @@ class EEGClassifier(_EEGNeuralNet, NeuralNetClassifier):
175
188
  loss : float
176
189
  The loss value.
177
190
  """
178
- # CroppedLoss pools logits before comparing them with trial targets.
179
- # Composite inputs have their own target dtype contract in the loader.
180
- if (
181
- isinstance(y_pred, Tensor)
182
- and isinstance(y_true, Tensor)
183
- and not isinstance(self.criterion_, CroppedLoss)
184
- and not isinstance(kwargs.get("X"), (tuple, list))
185
- ):
186
- y_true = _class_target(y_pred, y_true)
191
+ y_true = _class_indices(y_pred, y_true)
187
192
  return NeuralNet.get_loss(self, y_pred, y_true, *args, **kwargs)
188
193
 
189
194
  def predict(self, X):
@@ -281,3 +286,25 @@ class EEGClassifier(_EEGNeuralNet, NeuralNetClassifier):
281
286
  )
282
287
  )
283
288
  return callbacks
289
+
290
+
291
+ # Helper of EEGClassifier.get_loss, below the class.
292
+ def _class_indices(y_pred, y_true):
293
+ """Cast a float target to int64 unless it has the shape of ``y_pred``.
294
+
295
+ Window datasets slice targets out of the float32 signal, and labels read from
296
+ a table can be floats: the loader keeps floats, and the shape tells class
297
+ probabilities (the shape of the predictions) from class indices. A Mixup target
298
+ ``(y_a, y_b, lam)`` casts ``y_a`` and ``y_b``, never the weights ``lam``.
299
+ """
300
+ if isinstance(y_true, (tuple, list)) and len(y_true) == 3:
301
+ y_a, y_b, lam = y_true
302
+ return _class_indices(y_pred, y_a), _class_indices(y_pred, y_b), lam
303
+ if (
304
+ isinstance(y_pred, Tensor)
305
+ and isinstance(y_true, Tensor)
306
+ and y_true.is_floating_point()
307
+ and y_true.shape != y_pred.shape
308
+ ):
309
+ return y_true.long()
310
+ return y_true
@@ -40,7 +40,7 @@ from typing_extensions import TypeVar
40
40
 
41
41
  from ._notebook_viewer import plot as _viewer_plot
42
42
  from .bids.hub import HubDatasetMixin
43
- from .bids.hub_io import _restore_nan_from_json
43
+ from .bids.hub_io import _epochs_from_zarr, _raw_from_zarr, _restore_nan_from_json
44
44
  from .registry import register_dataset
45
45
 
46
46
  zarr = _soft_import("zarr", purpose="lazy loading from Zarr", strict=False)
@@ -206,16 +206,50 @@ def _channel_info(mne_obj):
206
206
  return n_ch, type_str, sfreq
207
207
 
208
208
 
209
+ def _misc_mask(info):
210
+ """Boolean mask ``(n_chans,)`` of the ``misc`` channels, which hold the targets.
211
+
212
+ Reads the FIFF kind of each channel, ``FIFFV_MISC_CH`` being the only kind of
213
+ type ``misc``, from an ``mne.Info`` or from the JSON form of Info that lazy Zarr
214
+ stores hold, so no Info is built. There a kind is a ``{"value": int, ...}``
215
+ dict, or a bare int when it was not an mne ``NamedInt``.
216
+ """
217
+ kinds = [ch["kind"] for ch in info["chs"]]
218
+ kinds = [kind["value"] if isinstance(kind, dict) else kind for kind in kinds]
219
+ return np.asarray(kinds) == FIFF.FIFFV_MISC_CH
220
+
221
+
222
+ def _split_channel_targets(X, info, last_target_only):
223
+ """Split a window ``X: (n_chans, n_times)`` into its signal and its targets.
224
+
225
+ The targets are the ``misc`` channels of ``info`` (an ``mne.Info`` or the stored
226
+ one, so a lazy recording is not read): their last sample ``(n_misc,)`` if
227
+ ``last_target_only``, else all of them ``(n_misc, n_times)``. The signal keeps
228
+ the other rows ``(n_chans - n_misc, n_times)``. Raises ``ValueError`` if
229
+ ``info`` has no ``misc`` channel.
230
+
231
+ Returns
232
+ -------
233
+ X, y
234
+ Signal and targets.
235
+ """
236
+ misc_mask = _misc_mask(info)
237
+ y = X[misc_mask, -1] if last_target_only else X[misc_mask]
238
+ if not len(y):
239
+ raise ValueError(
240
+ "targets_from='channels' needs a misc channel, but this window has "
241
+ "none (was it removed by preprocessing?)"
242
+ )
243
+ return X[~misc_mask], y
244
+
245
+
209
246
  def _check_window_targets(targets_from, info):
210
247
  if targets_from not in ("metadata", "channels"):
211
248
  raise ValueError("Wrong value for parameter `targets_from`.")
212
- if targets_from == "channels":
213
- if not isinstance(info, mne.Info): # lazy Zarr stores hold serialized Info
214
- info = mne.Info.from_json_dict(info)
215
- if "misc" not in info.get_channel_types():
216
- raise ValueError(
217
- "targets_from='channels' requires a misc channel in the selected channels."
218
- )
249
+ if targets_from == "channels" and not _misc_mask(info).any():
250
+ raise ValueError(
251
+ "targets_from='channels' requires a misc channel in the selected channels."
252
+ )
219
253
  return targets_from
220
254
 
221
255
 
@@ -226,13 +260,13 @@ def _compute_ch_pos(info, targets_from):
226
260
  (meters) -- the same representation braindecode models already consume (see
227
261
  e.g. ``signal_jepa``/``REVE``). When ``targets_from != "metadata"`` the
228
262
  window's misc channels are dropped from ``X`` in ``__getitem__``, so the
229
- matching misc rows are dropped here too. Emits a one-time ``UserWarning`` if
230
- no channel carries a real position (no montage set).
263
+ matching misc rows are dropped here too. ``info`` is an ``mne.Info`` or the
264
+ stored one of a lazy dataset. Emits a one-time ``UserWarning`` if no channel
265
+ carries a real position (no montage set).
231
266
  """
232
267
  pos = np.asarray([ch["loc"][:3] for ch in info["chs"]], dtype="float32")
233
268
  if targets_from != "metadata":
234
- misc_mask = np.asarray(info.get_channel_types()) == "misc"
235
- pos = pos[~misc_mask]
269
+ pos = pos[~_misc_mask(info)]
236
270
  has_pos = np.isfinite(pos).all(axis=1) & np.any(pos != 0, axis=1)
237
271
  if pos.size and not has_pos.any():
238
272
  warnings.warn(
@@ -551,8 +585,8 @@ def _zarr_to_memmap(zarr_path, group_name):
551
585
  finally:
552
586
  del mm
553
587
 
554
- # A reader on read-only media may be unable to acquire the store lock.
555
- # Never publish a mixture of chunks under the previous store's ID.
588
+ # A writer may replace the store while the cache is filled; never publish
589
+ # a mixture of chunks under the previous store's ID.
556
590
  if not os.path.samestat(store_stat, zarr_p.stat()):
557
591
  raise OSError(f"Zarr store {zarr_p} changed while populating its cache.")
558
592
 
@@ -589,6 +623,7 @@ class _ZarrMixin:
589
623
  """
590
624
 
591
625
  _zarr_data = None
626
+ _mne_state = None # Older lazy pickles omit the stored recording state.
592
627
 
593
628
  def _open_zarr(self):
594
629
  npy_path = getattr(self, "_zarr_cache_path", None)
@@ -604,14 +639,12 @@ class _ZarrMixin:
604
639
 
605
640
  def _make_mne_info(self):
606
641
  """Reconstruct ``mne.Info`` from stored dict (no data I/O)."""
607
- if not hasattr(self, "_zarr_info"):
608
- self._zarr_info = mne.Info.from_json_dict(
609
- _restore_nan_from_json(self._info_dict)
610
- )
611
- return self._zarr_info
642
+ return mne.Info.from_json_dict(_restore_nan_from_json(self._info_dict))
612
643
 
613
644
  @classmethod
614
- def _init_zarr_base(cls, zarr_path, group_name, description, info_dict, transform):
645
+ def _init_zarr_base(
646
+ cls, zarr_path, group_name, description, info_dict, transform, mne_state
647
+ ):
615
648
  """Shared ``_from_zarr`` preamble: create instance with zarr attrs."""
616
649
  if zarr is False:
617
650
  raise ImportError("zarr is required: pip install braindecode[hub]")
@@ -620,12 +653,12 @@ class _ZarrMixin:
620
653
  obj._zarr_path = Path(zarr_path)
621
654
  obj._group_name = group_name
622
655
  obj._info_dict = info_dict
656
+ obj._mne_state = mne_state
623
657
  return obj
624
658
 
625
659
  def __getstate__(self):
626
660
  state = self.__dict__.copy()
627
661
  state.pop("_zarr_data", None)
628
- state.pop("_zarr_info", None)
629
662
  return state
630
663
 
631
664
  def __setstate__(self, state):
@@ -756,10 +789,11 @@ class RawDataset(_ZarrMixin, RecordDataset):
756
789
  info_dict,
757
790
  target_name=None,
758
791
  transform=None,
792
+ mne_state=None,
759
793
  ):
760
794
  """Create a lazy Zarr-backed RawDataset (internal API)."""
761
795
  obj = cls._init_zarr_base(
762
- zarr_path, group_name, description, info_dict, transform
796
+ zarr_path, group_name, description, info_dict, transform, mne_state
763
797
  )
764
798
  obj.target_name = cls._target_name(obj, target_name)
765
799
  obj.raw_preproc_kwargs = []
@@ -769,7 +803,9 @@ class RawDataset(_ZarrMixin, RecordDataset):
769
803
  @property
770
804
  def raw(self):
771
805
  if self._raw is None and self._zarr_data is not None:
772
- self.raw = mne.io.RawArray(self._zarr_data, self._make_mne_info())
806
+ self.raw = _raw_from_zarr(
807
+ self._zarr_data, self._make_mne_info(), self._mne_state or {}
808
+ )
773
809
  return self._raw
774
810
 
775
811
  @raw.setter
@@ -929,10 +965,11 @@ class EEGWindowsDataset(_ZarrMixin, RecordDataset):
929
965
  targets_from="metadata",
930
966
  last_target_only=True,
931
967
  transform=None,
968
+ mne_state=None,
932
969
  ):
933
970
  """Create a lazy Zarr-backed EEGWindowsDataset (internal API)."""
934
971
  obj = cls._init_zarr_base(
935
- zarr_path, group_name, description, info_dict, transform
972
+ zarr_path, group_name, description, info_dict, transform, mne_state
936
973
  )
937
974
  obj.metadata = metadata
938
975
  obj.last_target_only = last_target_only
@@ -949,7 +986,9 @@ class EEGWindowsDataset(_ZarrMixin, RecordDataset):
949
986
  @property
950
987
  def raw(self):
951
988
  if self._raw is None and self._zarr_data is not None:
952
- self.raw = mne.io.RawArray(self._zarr_data, self._make_mne_info())
989
+ self.raw = _raw_from_zarr(
990
+ self._zarr_data, self._make_mne_info(), self._mne_state or {}
991
+ )
953
992
  return self._raw
954
993
 
955
994
  @raw.setter
@@ -967,7 +1006,7 @@ class EEGWindowsDataset(_ZarrMixin, RecordDataset):
967
1006
  ``targets_from="channels"``). All-zero/NaN when no montage is set.
968
1007
  """
969
1008
  if self._ch_pos is None:
970
- info = self._raw.info if self._raw is not None else self._make_mne_info()
1009
+ info = self._raw.info if self._raw is not None else self._info_dict
971
1010
  self._ch_pos = _compute_ch_pos(info, self.targets_from)
972
1011
  return self._ch_pos
973
1012
 
@@ -1016,18 +1055,8 @@ class EEGWindowsDataset(_ZarrMixin, RecordDataset):
1016
1055
  if self.targets_from == "metadata":
1017
1056
  y = self.y[index]
1018
1057
  else:
1019
- # The FIFF kind, as get_channel_types() == "misc" but fast per window; from
1020
- # the loaded or the stored info, so a lazy recording is not read.
1021
- info = self._raw.info if self._raw is not None else self._make_mne_info()
1022
- misc_mask = np.array(
1023
- [ch["kind"] == FIFF.FIFFV_MISC_CH for ch in info["chs"]]
1024
- )
1025
- if self.last_target_only:
1026
- y = X[misc_mask, -1]
1027
- else:
1028
- y = X[misc_mask, :]
1029
- y = y.copy()
1030
- X = X[~misc_mask, :]
1058
+ info = self._raw.info if self._raw is not None else self._info_dict
1059
+ X, y = _split_channel_targets(X, info, self.last_target_only)
1031
1060
  if self.return_ch_pos:
1032
1061
  return X, y, crop_inds, self.ch_pos
1033
1062
  return X, y, crop_inds
@@ -1205,10 +1234,11 @@ class WindowsDataset(_ZarrMixin, RecordDataset):
1205
1234
  transform=None,
1206
1235
  targets_from="metadata",
1207
1236
  last_target_only=True,
1237
+ mne_state=None,
1208
1238
  ):
1209
1239
  """Create a lazy Zarr-backed WindowsDataset (internal API)."""
1210
1240
  obj = cls._init_zarr_base(
1211
- zarr_path, group_name, description, info_dict, transform
1241
+ zarr_path, group_name, description, info_dict, transform, mne_state
1212
1242
  )
1213
1243
  obj.target_name = target_name
1214
1244
  obj._fast_disk = False
@@ -1228,22 +1258,11 @@ class WindowsDataset(_ZarrMixin, RecordDataset):
1228
1258
  @property
1229
1259
  def windows(self):
1230
1260
  if self._windows is None and self._zarr_data is not None:
1231
- info = self._make_mne_info()
1232
- targets = self.metadata["target"].values
1233
- event_ids = (
1234
- targets
1235
- if np.issubdtype(targets.dtype, np.integer)
1236
- else np.ones(len(self.metadata), dtype=int)
1237
- )
1238
- events = np.column_stack(
1239
- [
1240
- self.metadata["i_start_in_trial"].values.astype(int),
1241
- np.zeros(len(self.metadata), dtype=int),
1242
- event_ids,
1243
- ]
1244
- )
1245
- self.windows = mne.EpochsArray(
1246
- self._zarr_data, info, events=events, metadata=self.metadata
1261
+ self.windows = _epochs_from_zarr(
1262
+ self._zarr_data,
1263
+ self._make_mne_info(),
1264
+ self.metadata,
1265
+ self._mne_state or {},
1247
1266
  )
1248
1267
  return self._windows
1249
1268
 
@@ -1262,11 +1281,7 @@ class WindowsDataset(_ZarrMixin, RecordDataset):
1262
1281
  ``targets_from="channels"``). All-zero/NaN when no montage is set.
1263
1282
  """
1264
1283
  if self._ch_pos is None:
1265
- info = (
1266
- self._windows.info
1267
- if self._windows is not None
1268
- else self._make_mne_info()
1269
- )
1284
+ info = self._windows.info if self._windows is not None else self._info_dict
1270
1285
  self._ch_pos = _compute_ch_pos(info, self.targets_from)
1271
1286
  return self._ch_pos
1272
1287
 
@@ -1312,17 +1327,8 @@ class WindowsDataset(_ZarrMixin, RecordDataset):
1312
1327
  if self.targets_from == "metadata":
1313
1328
  y = self.y[index]
1314
1329
  else:
1315
- info = (
1316
- self._windows.info
1317
- if self._windows is not None
1318
- else self._make_mne_info()
1319
- )
1320
- misc_mask = np.asarray(info.get_channel_types()) == "misc"
1321
- if self.last_target_only:
1322
- y = X[misc_mask, -1]
1323
- else:
1324
- y = X[misc_mask, :]
1325
- X = X[~misc_mask, :]
1330
+ info = self._windows.info if self._windows is not None else self._info_dict
1331
+ X, y = _split_channel_targets(X, info, self.last_target_only)
1326
1332
  # necessary to cast as list to get list of three tensors from batch,
1327
1333
  # otherwise get single 2d-tensor...
1328
1334
  crop_inds = self.crop_inds[index].tolist()
@@ -55,10 +55,12 @@ from ..registry import get_dataset_class, get_dataset_type
55
55
  from . import hub_format, hub_validation
56
56
  from .hub_io import (
57
57
  _create_compressor,
58
+ _epochs_from_zarr,
58
59
  _load_eegwindows_from_zarr,
59
60
  _load_raw_from_zarr,
60
61
  _load_windows_from_zarr,
61
62
  _prepare_info_for_json,
63
+ _raw_from_zarr,
62
64
  _save_eegwindows_to_zarr,
63
65
  _save_raw_to_zarr,
64
66
  _save_windows_to_zarr,
@@ -786,66 +788,38 @@ class HubDatasetMixin:
786
788
  for i_ds, ds in enumerate(self.datasets):
787
789
  grp = root.create_group(f"recording_{i_ds}")
788
790
 
789
- if dataset_type == "WindowsDataset":
790
- # Extract data from WindowsDataset
791
- data = ds.windows.get_data()
792
- metadata = ds.windows.metadata
793
- description = ds.description
794
- info_dict = prepared_infos[i_ds]
795
- target_name = ds.target_name if hasattr(ds, "target_name") else None
791
+ # Same as BaseConcatDataset._save_description: a missing description
792
+ # is stored as empty and values JSON cannot hold, such as the Path of
793
+ # a BIDS recording, are stored as strings.
794
+ description = ds.description
795
+ if description is None:
796
+ description = pd.Series(dtype=object)
797
+ grp.attrs["description"] = json.loads(
798
+ description.to_json(date_format="iso", default_handler=str)
799
+ )
800
+ grp.attrs["info"] = prepared_infos[i_ds]
801
+ target_name = getattr(ds, "target_name", None)
802
+ if target_name is not None:
803
+ grp.attrs["target_name"] = target_name
796
804
 
797
- # Save using inlined function
798
- _save_windows_to_zarr(
799
- grp,
800
- data,
801
- metadata,
802
- description,
803
- info_dict,
804
- compressor,
805
- target_name,
806
- )
805
+ if dataset_type == "WindowsDataset":
806
+ _save_windows_to_zarr(grp, ds.windows, compressor)
807
807
  grp.attrs["targets_from"] = ds.targets_from
808
808
  grp.attrs["last_target_only"] = ds.last_target_only
809
809
 
810
810
  elif dataset_type == "EEGWindowsDataset":
811
- # Get continuous raw data and metadata from EEGWindowsDataset
812
- raw = ds.raw
813
- metadata = ds.metadata
814
- description = ds.description
815
- info_dict = prepared_infos[i_ds]
816
- targets_from = ds.targets_from
817
- last_target_only = ds.last_target_only
818
-
819
- # Save using inlined function (saves continuous raw directly)
820
811
  _save_eegwindows_to_zarr(
821
812
  grp,
822
- raw,
823
- metadata,
824
- description,
825
- info_dict,
826
- targets_from,
827
- last_target_only,
813
+ ds.raw,
814
+ ds.metadata,
815
+ ds.targets_from,
816
+ ds.last_target_only,
828
817
  compressor,
829
818
  chunk_size,
830
819
  )
831
820
 
832
821
  elif dataset_type == "RawDataset":
833
- # Get continuous raw data from RawDataset
834
- raw = ds.raw
835
- description = ds.description
836
- info_dict = prepared_infos[i_ds]
837
- target_name = ds.target_name if hasattr(ds, "target_name") else None
838
-
839
- # Save using inlined function
840
- _save_raw_to_zarr(
841
- grp,
842
- raw,
843
- description,
844
- info_dict,
845
- target_name,
846
- compressor,
847
- chunk_size,
848
- )
822
+ _save_raw_to_zarr(grp, ds.raw, compressor, chunk_size)
849
823
 
850
824
  def _get_format_info_inline(self):
851
825
  """Get format info (inline implementation).
@@ -911,6 +885,10 @@ class HubDatasetMixin:
911
885
  for i_ds in range(n_datasets):
912
886
  grp = root[f"recording_{i_ds}"]
913
887
  group_name = f"recording_{i_ds}"
888
+ # First sample, annotations and events; absent in older stores.
889
+ state = dict(grp.attrs.get("mne", {}))
890
+ if "events" in grp:
891
+ state["events"] = grp["events"][:]
914
892
 
915
893
  if dataset_type == "WindowsDataset":
916
894
  # Load using inlined function
@@ -924,21 +902,7 @@ class HubDatasetMixin:
924
902
  if preload:
925
903
  # Convert to MNE objects and create dataset
926
904
  info = mne.Info.from_json_dict(info_dict)
927
- targets = metadata["target"].values
928
- if np.issubdtype(targets.dtype, np.integer):
929
- event_ids = targets
930
- else:
931
- event_ids = np.ones(len(metadata), dtype=int)
932
- events = np.column_stack(
933
- [
934
- metadata["i_start_in_trial"].values.astype(int),
935
- np.zeros(len(metadata), dtype=int),
936
- event_ids,
937
- ]
938
- )
939
- epochs = mne.EpochsArray(
940
- data, info, events=events, metadata=metadata
941
- )
905
+ epochs = _epochs_from_zarr(data, info, metadata, state)
942
906
  ds = WindowsDataset(
943
907
  epochs,
944
908
  description,
@@ -957,6 +921,7 @@ class HubDatasetMixin:
957
921
  target_name=target_name,
958
922
  targets_from=targets_from,
959
923
  last_target_only=last_target_only,
924
+ mne_state=state,
960
925
  )
961
926
 
962
927
  elif dataset_type == "EEGWindowsDataset":
@@ -974,7 +939,7 @@ class HubDatasetMixin:
974
939
  # Convert to MNE objects and create dataset
975
940
  # Data is already in continuous format [n_channels, n_timepoints]
976
941
  info = mne.Info.from_json_dict(info_dict)
977
- raw = mne.io.RawArray(data, info)
942
+ raw = _raw_from_zarr(data, info, state)
978
943
  ds = EEGWindowsDataset(
979
944
  raw=raw,
980
945
  metadata=metadata,
@@ -991,6 +956,7 @@ class HubDatasetMixin:
991
956
  info_dict=info_dict,
992
957
  targets_from=targets_from,
993
958
  last_target_only=last_target_only,
959
+ mne_state=state,
994
960
  )
995
961
 
996
962
  elif dataset_type == "RawDataset":
@@ -1003,7 +969,7 @@ class HubDatasetMixin:
1003
969
  # Convert to MNE objects and create dataset
1004
970
  # Data is in continuous format [n_channels, n_timepoints]
1005
971
  info = mne.Info.from_json_dict(info_dict)
1006
- raw = mne.io.RawArray(data, info)
972
+ raw = _raw_from_zarr(data, info, state)
1007
973
  ds = RawDataset(raw, description)
1008
974
  if target_name is not None:
1009
975
  ds.target_name = target_name
@@ -1014,6 +980,7 @@ class HubDatasetMixin:
1014
980
  description=description,
1015
981
  info_dict=info_dict,
1016
982
  target_name=target_name,
983
+ mne_state=state,
1017
984
  )
1018
985
 
1019
986
  else: