braindecode 0.8__tar.gz → 1.3.0.dev176481332__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.

Potentially problematic release.


This version of braindecode might be problematic. Click here for more details.

Files changed (325) hide show
  1. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/LICENSE.txt +1 -1
  2. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/MANIFEST.in +3 -0
  3. braindecode-1.3.0.dev176481332/NOTICE.txt +20 -0
  4. {braindecode-0.8/braindecode.egg-info → braindecode-1.3.0.dev176481332}/PKG-INFO +36 -42
  5. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/README.rst +10 -34
  6. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/__init__.py +1 -2
  7. braindecode-1.3.0.dev176481332/braindecode/augmentation/__init__.py +50 -0
  8. braindecode-1.3.0.dev176481332/braindecode/augmentation/base.py +222 -0
  9. braindecode-1.3.0.dev176481332/braindecode/augmentation/functional.py +1196 -0
  10. braindecode-1.3.0.dev176481332/braindecode/augmentation/transforms.py +1273 -0
  11. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/classifier.py +26 -24
  12. braindecode-1.3.0.dev176481332/braindecode/datasets/__init__.py +42 -0
  13. braindecode-1.3.0.dev176481332/braindecode/datasets/base.py +804 -0
  14. braindecode-1.3.0.dev176481332/braindecode/datasets/bbci.py +694 -0
  15. braindecode-1.3.0.dev176481332/braindecode/datasets/bcicomp.py +194 -0
  16. braindecode-1.3.0.dev176481332/braindecode/datasets/bids.py +245 -0
  17. braindecode-1.3.0.dev176481332/braindecode/datasets/experimental.py +218 -0
  18. braindecode-1.3.0.dev176481332/braindecode/datasets/mne.py +170 -0
  19. braindecode-1.3.0.dev176481332/braindecode/datasets/moabb.py +209 -0
  20. braindecode-1.3.0.dev176481332/braindecode/datasets/nmt.py +311 -0
  21. braindecode-1.3.0.dev176481332/braindecode/datasets/sleep_physio_challe_18.py +413 -0
  22. braindecode-1.3.0.dev176481332/braindecode/datasets/sleep_physionet.py +125 -0
  23. braindecode-1.3.0.dev176481332/braindecode/datasets/tuh.py +588 -0
  24. braindecode-1.3.0.dev176481332/braindecode/datasets/xy.py +95 -0
  25. braindecode-1.3.0.dev176481332/braindecode/datautil/__init__.py +52 -0
  26. braindecode-1.3.0.dev176481332/braindecode/datautil/serialization.py +358 -0
  27. braindecode-1.3.0.dev176481332/braindecode/datautil/util.py +41 -0
  28. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/eegneuralnet.py +65 -47
  29. braindecode-1.3.0.dev176481332/braindecode/functional/__init__.py +22 -0
  30. braindecode-1.3.0.dev176481332/braindecode/functional/functions.py +254 -0
  31. braindecode-1.3.0.dev176481332/braindecode/functional/initialization.py +46 -0
  32. braindecode-1.3.0.dev176481332/braindecode/models/__init__.py +104 -0
  33. braindecode-1.3.0.dev176481332/braindecode/models/atcnet.py +826 -0
  34. braindecode-1.3.0.dev176481332/braindecode/models/attentionbasenet.py +731 -0
  35. braindecode-1.3.0.dev176481332/braindecode/models/attn_sleep.py +547 -0
  36. braindecode-1.3.0.dev176481332/braindecode/models/base.py +574 -0
  37. braindecode-1.3.0.dev176481332/braindecode/models/bendr.py +469 -0
  38. braindecode-1.3.0.dev176481332/braindecode/models/biot.py +506 -0
  39. braindecode-1.3.0.dev176481332/braindecode/models/contrawr.py +319 -0
  40. braindecode-1.3.0.dev176481332/braindecode/models/ctnet.py +541 -0
  41. braindecode-1.3.0.dev176481332/braindecode/models/deep4.py +376 -0
  42. braindecode-1.3.0.dev176481332/braindecode/models/deepsleepnet.py +417 -0
  43. braindecode-1.3.0.dev176481332/braindecode/models/eegconformer.py +470 -0
  44. braindecode-1.3.0.dev176481332/braindecode/models/eeginception_erp.py +379 -0
  45. braindecode-1.3.0.dev176481332/braindecode/models/eeginception_mi.py +379 -0
  46. braindecode-1.3.0.dev176481332/braindecode/models/eegitnet.py +302 -0
  47. braindecode-1.3.0.dev176481332/braindecode/models/eegminer.py +256 -0
  48. braindecode-1.3.0.dev176481332/braindecode/models/eegnet.py +359 -0
  49. braindecode-1.3.0.dev176481332/braindecode/models/eegnex.py +354 -0
  50. braindecode-1.3.0.dev176481332/braindecode/models/eegsimpleconv.py +201 -0
  51. braindecode-1.3.0.dev176481332/braindecode/models/eegtcnet.py +337 -0
  52. braindecode-1.3.0.dev176481332/braindecode/models/fbcnet.py +223 -0
  53. braindecode-1.3.0.dev176481332/braindecode/models/fblightconvnet.py +315 -0
  54. braindecode-1.3.0.dev176481332/braindecode/models/fbmsnet.py +326 -0
  55. braindecode-1.3.0.dev176481332/braindecode/models/hybrid.py +126 -0
  56. braindecode-1.3.0.dev176481332/braindecode/models/ifnet.py +443 -0
  57. braindecode-1.3.0.dev176481332/braindecode/models/labram.py +1292 -0
  58. braindecode-1.3.0.dev176481332/braindecode/models/msvtnet.py +377 -0
  59. braindecode-1.3.0.dev176481332/braindecode/models/patchedtransformer.py +640 -0
  60. braindecode-1.3.0.dev176481332/braindecode/models/sccnet.py +280 -0
  61. braindecode-1.3.0.dev176481332/braindecode/models/shallow_fbcsp.py +210 -0
  62. braindecode-1.3.0.dev176481332/braindecode/models/signal_jepa.py +1095 -0
  63. braindecode-1.3.0.dev176481332/braindecode/models/sinc_shallow.py +340 -0
  64. braindecode-1.3.0.dev176481332/braindecode/models/sleep_stager_blanco_2020.py +169 -0
  65. braindecode-1.3.0.dev176481332/braindecode/models/sleep_stager_chambon_2018.py +159 -0
  66. braindecode-1.3.0.dev176481332/braindecode/models/sparcnet.py +426 -0
  67. braindecode-1.3.0.dev176481332/braindecode/models/sstdpn.py +869 -0
  68. braindecode-1.3.0.dev176481332/braindecode/models/summary.csv +42 -0
  69. braindecode-1.3.0.dev176481332/braindecode/models/syncnet.py +234 -0
  70. braindecode-1.3.0.dev176481332/braindecode/models/tcn.py +275 -0
  71. braindecode-1.3.0.dev176481332/braindecode/models/tidnet.py +397 -0
  72. braindecode-1.3.0.dev176481332/braindecode/models/tsinception.py +295 -0
  73. braindecode-1.3.0.dev176481332/braindecode/models/usleep.py +439 -0
  74. braindecode-1.3.0.dev176481332/braindecode/models/util.py +132 -0
  75. braindecode-1.3.0.dev176481332/braindecode/modules/__init__.py +84 -0
  76. braindecode-1.3.0.dev176481332/braindecode/modules/activation.py +60 -0
  77. braindecode-1.3.0.dev176481332/braindecode/modules/attention.py +760 -0
  78. braindecode-1.3.0.dev176481332/braindecode/modules/blocks.py +108 -0
  79. braindecode-1.3.0.dev176481332/braindecode/modules/convolution.py +277 -0
  80. braindecode-1.3.0.dev176481332/braindecode/modules/filter.py +629 -0
  81. braindecode-1.3.0.dev176481332/braindecode/modules/layers.py +132 -0
  82. braindecode-1.3.0.dev176481332/braindecode/modules/linear.py +49 -0
  83. braindecode-1.3.0.dev176481332/braindecode/modules/parametrization.py +38 -0
  84. braindecode-1.3.0.dev176481332/braindecode/modules/stats.py +77 -0
  85. braindecode-1.3.0.dev176481332/braindecode/modules/util.py +76 -0
  86. braindecode-1.3.0.dev176481332/braindecode/modules/wrapper.py +73 -0
  87. braindecode-1.3.0.dev176481332/braindecode/preprocessing/__init__.py +61 -0
  88. braindecode-1.3.0.dev176481332/braindecode/preprocessing/eegprep_preprocess.py +1202 -0
  89. braindecode-1.3.0.dev176481332/braindecode/preprocessing/mne_preprocess.py +77 -0
  90. braindecode-1.3.0.dev176481332/braindecode/preprocessing/preprocess.py +481 -0
  91. braindecode-1.3.0.dev176481332/braindecode/preprocessing/util.py +166 -0
  92. braindecode-1.3.0.dev176481332/braindecode/preprocessing/windowers.py +1037 -0
  93. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/regressor.py +23 -12
  94. braindecode-1.3.0.dev176481332/braindecode/samplers/__init__.py +18 -0
  95. braindecode-1.3.0.dev176481332/braindecode/samplers/base.py +399 -0
  96. braindecode-1.3.0.dev176481332/braindecode/samplers/ssl.py +263 -0
  97. braindecode-1.3.0.dev176481332/braindecode/training/__init__.py +23 -0
  98. braindecode-1.3.0.dev176481332/braindecode/training/callbacks.py +23 -0
  99. braindecode-1.3.0.dev176481332/braindecode/training/losses.py +105 -0
  100. braindecode-1.3.0.dev176481332/braindecode/training/scoring.py +477 -0
  101. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/util.py +55 -59
  102. braindecode-1.3.0.dev176481332/braindecode/version.py +1 -0
  103. braindecode-1.3.0.dev176481332/braindecode/visualization/__init__.py +8 -0
  104. braindecode-1.3.0.dev176481332/braindecode/visualization/confusion_matrices.py +289 -0
  105. braindecode-1.3.0.dev176481332/braindecode/visualization/gradients.py +62 -0
  106. {braindecode-0.8 → braindecode-1.3.0.dev176481332/braindecode.egg-info}/PKG-INFO +36 -42
  107. braindecode-1.3.0.dev176481332/braindecode.egg-info/SOURCES.txt +137 -0
  108. braindecode-1.3.0.dev176481332/braindecode.egg-info/requires.txt +55 -0
  109. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/Makefile +6 -1
  110. braindecode-1.3.0.dev176481332/docs/api.rst +598 -0
  111. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/conf.py +198 -137
  112. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/help.rst +7 -19
  113. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/index.rst +5 -4
  114. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/install/install.rst +6 -4
  115. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/install/install_pip.rst +6 -4
  116. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/install/install_source.rst +6 -4
  117. braindecode-1.3.0.dev176481332/docs/models/categorization/attention.rst +31 -0
  118. braindecode-1.3.0.dev176481332/docs/models/categorization/channel.rst +31 -0
  119. braindecode-1.3.0.dev176481332/docs/models/categorization/convolution.rst +33 -0
  120. braindecode-1.3.0.dev176481332/docs/models/categorization/filterbank.rst +31 -0
  121. braindecode-1.3.0.dev176481332/docs/models/categorization/gnn.rst +27 -0
  122. braindecode-1.3.0.dev176481332/docs/models/categorization/interpretable.rst +31 -0
  123. braindecode-1.3.0.dev176481332/docs/models/categorization/lbm.rst +31 -0
  124. braindecode-1.3.0.dev176481332/docs/models/categorization/recurrent.rst +31 -0
  125. braindecode-1.3.0.dev176481332/docs/models/categorization/spd.rst +31 -0
  126. braindecode-1.3.0.dev176481332/docs/models/models.rst +78 -0
  127. braindecode-1.3.0.dev176481332/docs/models/models_categorization.rst +201 -0
  128. braindecode-1.3.0.dev176481332/docs/models/models_table.rst +191 -0
  129. braindecode-1.3.0.dev176481332/docs/models/models_visualization.rst +31 -0
  130. braindecode-1.3.0.dev176481332/docs/sg_execution_times.rst +112 -0
  131. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/whats_new.rst +191 -16
  132. braindecode-1.3.0.dev176481332/pyproject.toml +134 -0
  133. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/setup.cfg +8 -0
  134. braindecode-0.8/braindecode/version.py +0 -1
  135. braindecode-0.8/braindecode.egg-info/SOURCES.txt +0 -210
  136. braindecode-0.8/braindecode.egg-info/requires.txt +0 -34
  137. braindecode-0.8/docs/_build/html/_downloads/090305d06248840b75133975e5121f41/plot_sleep_staging_chambon2018.ipynb +0 -291
  138. braindecode-0.8/docs/_build/html/_downloads/0f2bf063e08b7d05b80e0004fcbbb6f9/benchmark_lazy_eager_loading.ipynb +0 -183
  139. braindecode-0.8/docs/_build/html/_downloads/10fc813a8f78253f4bf301264950f5c1/plot_bcic_iv_4_ecog_cropped.ipynb +0 -338
  140. braindecode-0.8/docs/_build/html/_downloads/1c6590d134fa0befda654e89aa55b2ac/plot_benchmark_preprocessing.ipynb +0 -104
  141. braindecode-0.8/docs/_build/html/_downloads/1d879df548fa18be8c23d9ca0dc008d4/plot_data_augmentation.ipynb +0 -259
  142. braindecode-0.8/docs/_build/html/_downloads/2466f8ec5c733d0bd65e187b45d875cc/plot_data_augmentation_search.ipynb +0 -302
  143. braindecode-0.8/docs/_build/html/_downloads/263464a28477cf8decb861ae6e2e9be7/plot_how_train_test_and_tune.ipynb +0 -375
  144. braindecode-0.8/docs/_build/html/_downloads/3862cafd7f0d815e434319ffe525afc8/plot_bcic_iv_2a_moabb_cropped.ipynb +0 -226
  145. braindecode-0.8/docs/_build/html/_downloads/408ca4ffd0ea1f76faa9ef602734ac94/plot_tuh_eeg_corpus.ipynb +0 -187
  146. braindecode-0.8/docs/_build/html/_downloads/75a73c7d94f3a671fd3dec28f4031ead/plot_regression.ipynb +0 -212
  147. braindecode-0.8/docs/_build/html/_downloads/84fbcd59a346e5e56758285122dc69e2/plot_sleep_staging_eldele2021.ipynb +0 -291
  148. braindecode-0.8/docs/_build/html/_downloads/8616a7f968141825e56ab3e3d59be449/plot_tuh_discrete_multitarget.ipynb +0 -169
  149. braindecode-0.8/docs/_build/html/_downloads/8b5ba06718764b959e8dea1dd0bb97df/plot_sleep_staging_usleep.ipynb +0 -255
  150. braindecode-0.8/docs/_build/html/_downloads/91651c9d4fde110b4a53f5775a91acc5/plot_mne_dataset_example.ipynb +0 -104
  151. braindecode-0.8/docs/_build/html/_downloads/9a4447462c3b255ba7e5ca212bbadd52/plot_bcic_iv_2a_moabb_trial.ipynb +0 -253
  152. braindecode-0.8/docs/_build/html/_downloads/a39e4245738e55e0eb7084c545ed05bc/plot_hyperparameter_tuning_with_scikit-learn.ipynb +0 -257
  153. braindecode-0.8/docs/_build/html/_downloads/a6249715d3c30cb41c4af85938cca008/plot_moabb_dataset_example.ipynb +0 -140
  154. braindecode-0.8/docs/_build/html/_downloads/a7ccc5c1d1d2775e08c053bb25c81a91/plot_bcic_iv_4_ecog_trial.ipynb +0 -369
  155. braindecode-0.8/docs/_build/html/_downloads/a86d0c5f3a882a069df1683a708d3e25/plot_train_in_pure_pytorch_and_pytorch_lightning.ipynb +0 -243
  156. braindecode-0.8/docs/_build/html/_downloads/aa8426d97090e7b3062c4e4732c3214a/plot_relative_positioning.ipynb +0 -266
  157. braindecode-0.8/docs/_build/html/_downloads/b9d19304ecd233ea7a79d4365316ea49/plot_load_save_datasets.ipynb +0 -169
  158. braindecode-0.8/docs/_build/html/_downloads/f3c89d39e947a121c7920b4d415413a2/plot_split_dataset.ipynb +0 -180
  159. braindecode-0.8/docs/_build/html/_downloads/f7b38cac92c078838442753121efc297/plot_custom_dataset_example.ipynb +0 -133
  160. braindecode-0.8/docs/_build/html/_downloads/fff46913db5173d3ae22c1113acffb45/plot_basic_training_epochs.ipynb +0 -219
  161. braindecode-0.8/docs/api.rst +0 -256
  162. braindecode-0.8/docs/auto_examples/advanced_training/index.rst +0 -98
  163. braindecode-0.8/docs/auto_examples/advanced_training/plot_bcic_iv_4_ecog_cropped.ipynb +0 -338
  164. braindecode-0.8/docs/auto_examples/advanced_training/plot_bcic_iv_4_ecog_cropped.rst +0 -755
  165. braindecode-0.8/docs/auto_examples/advanced_training/plot_data_augmentation.ipynb +0 -259
  166. braindecode-0.8/docs/auto_examples/advanced_training/plot_data_augmentation.rst +0 -587
  167. braindecode-0.8/docs/auto_examples/advanced_training/plot_data_augmentation_search.ipynb +0 -302
  168. braindecode-0.8/docs/auto_examples/advanced_training/plot_data_augmentation_search.rst +0 -720
  169. braindecode-0.8/docs/auto_examples/advanced_training/plot_relative_positioning.ipynb +0 -266
  170. braindecode-0.8/docs/auto_examples/advanced_training/plot_relative_positioning.rst +0 -858
  171. braindecode-0.8/docs/auto_examples/advanced_training/sg_execution_times.rst +0 -19
  172. braindecode-0.8/docs/auto_examples/applied_examples/index.rst +0 -116
  173. braindecode-0.8/docs/auto_examples/applied_examples/plot_bcic_iv_4_ecog_trial.ipynb +0 -369
  174. braindecode-0.8/docs/auto_examples/applied_examples/plot_bcic_iv_4_ecog_trial.rst +0 -688
  175. braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_chambon2018.ipynb +0 -291
  176. braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_chambon2018.rst +0 -697
  177. braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_eldele2021.ipynb +0 -291
  178. braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_eldele2021.rst +0 -793
  179. braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_usleep.ipynb +0 -255
  180. braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_usleep.rst +0 -711
  181. braindecode-0.8/docs/auto_examples/applied_examples/plot_tuh_eeg_corpus.ipynb +0 -187
  182. braindecode-0.8/docs/auto_examples/applied_examples/plot_tuh_eeg_corpus.rst +0 -474
  183. braindecode-0.8/docs/auto_examples/applied_examples/sg_execution_times.rst +0 -21
  184. braindecode-0.8/docs/auto_examples/datasets_io/benchmark_lazy_eager_loading.ipynb +0 -183
  185. braindecode-0.8/docs/auto_examples/datasets_io/benchmark_lazy_eager_loading.rst +0 -431
  186. braindecode-0.8/docs/auto_examples/datasets_io/index.rst +0 -170
  187. braindecode-0.8/docs/auto_examples/datasets_io/plot_benchmark_preprocessing.ipynb +0 -104
  188. braindecode-0.8/docs/auto_examples/datasets_io/plot_benchmark_preprocessing.rst +0 -603
  189. braindecode-0.8/docs/auto_examples/datasets_io/plot_custom_dataset_example.ipynb +0 -133
  190. braindecode-0.8/docs/auto_examples/datasets_io/plot_custom_dataset_example.rst +0 -328
  191. braindecode-0.8/docs/auto_examples/datasets_io/plot_load_save_datasets.ipynb +0 -169
  192. braindecode-0.8/docs/auto_examples/datasets_io/plot_load_save_datasets.rst +0 -505
  193. braindecode-0.8/docs/auto_examples/datasets_io/plot_mne_dataset_example.ipynb +0 -104
  194. braindecode-0.8/docs/auto_examples/datasets_io/plot_mne_dataset_example.rst +0 -357
  195. braindecode-0.8/docs/auto_examples/datasets_io/plot_moabb_dataset_example.ipynb +0 -140
  196. braindecode-0.8/docs/auto_examples/datasets_io/plot_moabb_dataset_example.rst +0 -394
  197. braindecode-0.8/docs/auto_examples/datasets_io/plot_split_dataset.ipynb +0 -180
  198. braindecode-0.8/docs/auto_examples/datasets_io/plot_split_dataset.rst +0 -675
  199. braindecode-0.8/docs/auto_examples/datasets_io/plot_tuh_discrete_multitarget.ipynb +0 -169
  200. braindecode-0.8/docs/auto_examples/datasets_io/plot_tuh_discrete_multitarget.rst +0 -374
  201. braindecode-0.8/docs/auto_examples/datasets_io/sg_execution_times.rst +0 -27
  202. braindecode-0.8/docs/auto_examples/index.rst +0 -526
  203. braindecode-0.8/docs/auto_examples/model_building/index.rst +0 -152
  204. braindecode-0.8/docs/auto_examples/model_building/plot_basic_training_epochs.ipynb +0 -219
  205. braindecode-0.8/docs/auto_examples/model_building/plot_basic_training_epochs.rst +0 -588
  206. braindecode-0.8/docs/auto_examples/model_building/plot_bcic_iv_2a_moabb_cropped.ipynb +0 -226
  207. braindecode-0.8/docs/auto_examples/model_building/plot_bcic_iv_2a_moabb_cropped.rst +0 -649
  208. braindecode-0.8/docs/auto_examples/model_building/plot_bcic_iv_2a_moabb_trial.ipynb +0 -253
  209. braindecode-0.8/docs/auto_examples/model_building/plot_bcic_iv_2a_moabb_trial.rst +0 -591
  210. braindecode-0.8/docs/auto_examples/model_building/plot_how_train_test_and_tune.ipynb +0 -375
  211. braindecode-0.8/docs/auto_examples/model_building/plot_how_train_test_and_tune.rst +0 -1044
  212. braindecode-0.8/docs/auto_examples/model_building/plot_hyperparameter_tuning_with_scikit-learn.ipynb +0 -257
  213. braindecode-0.8/docs/auto_examples/model_building/plot_hyperparameter_tuning_with_scikit-learn.rst +0 -724
  214. braindecode-0.8/docs/auto_examples/model_building/plot_regression.ipynb +0 -212
  215. braindecode-0.8/docs/auto_examples/model_building/plot_regression.rst +0 -549
  216. braindecode-0.8/docs/auto_examples/model_building/plot_train_in_pure_pytorch_and_pytorch_lightning.ipynb +0 -243
  217. braindecode-0.8/docs/auto_examples/model_building/plot_train_in_pure_pytorch_and_pytorch_lightning.rst +0 -698
  218. braindecode-0.8/docs/auto_examples/model_building/sg_execution_times.rst +0 -25
  219. braindecode-0.8/docs/generated/braindecode.augmentation.AugmentedDataLoader.rst +0 -21
  220. braindecode-0.8/docs/generated/braindecode.augmentation.BandstopFilter.rst +0 -129
  221. braindecode-0.8/docs/generated/braindecode.augmentation.ChannelsDropout.rst +0 -129
  222. braindecode-0.8/docs/generated/braindecode.augmentation.ChannelsShuffle.rst +0 -129
  223. braindecode-0.8/docs/generated/braindecode.augmentation.ChannelsSymmetry.rst +0 -129
  224. braindecode-0.8/docs/generated/braindecode.augmentation.Compose.rst +0 -122
  225. braindecode-0.8/docs/generated/braindecode.augmentation.FTSurrogate.rst +0 -129
  226. braindecode-0.8/docs/generated/braindecode.augmentation.FrequencyShift.rst +0 -129
  227. braindecode-0.8/docs/generated/braindecode.augmentation.GaussianNoise.rst +0 -129
  228. braindecode-0.8/docs/generated/braindecode.augmentation.IdentityTransform.rst +0 -124
  229. braindecode-0.8/docs/generated/braindecode.augmentation.Mixup.rst +0 -129
  230. braindecode-0.8/docs/generated/braindecode.augmentation.SensorsRotation.rst +0 -129
  231. braindecode-0.8/docs/generated/braindecode.augmentation.SensorsXRotation.rst +0 -113
  232. braindecode-0.8/docs/generated/braindecode.augmentation.SensorsYRotation.rst +0 -113
  233. braindecode-0.8/docs/generated/braindecode.augmentation.SensorsZRotation.rst +0 -113
  234. braindecode-0.8/docs/generated/braindecode.augmentation.SignFlip.rst +0 -124
  235. braindecode-0.8/docs/generated/braindecode.augmentation.SmoothTimeMask.rst +0 -129
  236. braindecode-0.8/docs/generated/braindecode.augmentation.TimeReverse.rst +0 -124
  237. braindecode-0.8/docs/generated/braindecode.augmentation.Transform.rst +0 -127
  238. braindecode-0.8/docs/generated/braindecode.augmentation.functional.bandstop_filter.rst +0 -12
  239. braindecode-0.8/docs/generated/braindecode.augmentation.functional.channels_dropout.rst +0 -12
  240. braindecode-0.8/docs/generated/braindecode.augmentation.functional.channels_permute.rst +0 -12
  241. braindecode-0.8/docs/generated/braindecode.augmentation.functional.channels_shuffle.rst +0 -12
  242. braindecode-0.8/docs/generated/braindecode.augmentation.functional.frequency_shift.rst +0 -12
  243. braindecode-0.8/docs/generated/braindecode.augmentation.functional.ft_surrogate.rst +0 -12
  244. braindecode-0.8/docs/generated/braindecode.augmentation.functional.gaussian_noise.rst +0 -12
  245. braindecode-0.8/docs/generated/braindecode.augmentation.functional.identity.rst +0 -12
  246. braindecode-0.8/docs/generated/braindecode.augmentation.functional.mixup.rst +0 -12
  247. braindecode-0.8/docs/generated/braindecode.augmentation.functional.sensors_rotation.rst +0 -12
  248. braindecode-0.8/docs/generated/braindecode.augmentation.functional.sign_flip.rst +0 -12
  249. braindecode-0.8/docs/generated/braindecode.augmentation.functional.smooth_time_mask.rst +0 -12
  250. braindecode-0.8/docs/generated/braindecode.augmentation.functional.time_reverse.rst +0 -12
  251. braindecode-0.8/docs/generated/braindecode.classifier.EEGClassifier.rst +0 -150
  252. braindecode-0.8/docs/generated/braindecode.datasets.BCICompetitionIVDataset4.rst +0 -42
  253. braindecode-0.8/docs/generated/braindecode.datasets.BNCI2014001.rst +0 -29
  254. braindecode-0.8/docs/generated/braindecode.datasets.BaseConcatDataset.rst +0 -55
  255. braindecode-0.8/docs/generated/braindecode.datasets.BaseDataset.rst +0 -32
  256. braindecode-0.8/docs/generated/braindecode.datasets.HGD.rst +0 -29
  257. braindecode-0.8/docs/generated/braindecode.datasets.MOABBDataset.rst +0 -29
  258. braindecode-0.8/docs/generated/braindecode.datasets.SleepPhysionet.rst +0 -29
  259. braindecode-0.8/docs/generated/braindecode.datasets.TUH.rst +0 -29
  260. braindecode-0.8/docs/generated/braindecode.datasets.TUHAbnormal.rst +0 -29
  261. braindecode-0.8/docs/generated/braindecode.datasets.WindowsDataset.rst +0 -32
  262. braindecode-0.8/docs/generated/braindecode.datasets.create_from_X_y.rst +0 -12
  263. braindecode-0.8/docs/generated/braindecode.datasets.create_from_mne_epochs.rst +0 -12
  264. braindecode-0.8/docs/generated/braindecode.datasets.create_from_mne_raw.rst +0 -12
  265. braindecode-0.8/docs/generated/braindecode.datautil.load_concat_dataset.rst +0 -12
  266. braindecode-0.8/docs/generated/braindecode.datautil.save_concat_dataset.rst +0 -12
  267. braindecode-0.8/docs/generated/braindecode.models.ATCNet.rst +0 -126
  268. braindecode-0.8/docs/generated/braindecode.models.Deep4Net.rst +0 -123
  269. braindecode-0.8/docs/generated/braindecode.models.DeepSleepNet.rst +0 -126
  270. braindecode-0.8/docs/generated/braindecode.models.EEGConformer.rst +0 -133
  271. braindecode-0.8/docs/generated/braindecode.models.EEGITNet.rst +0 -123
  272. braindecode-0.8/docs/generated/braindecode.models.EEGInception.rst +0 -123
  273. braindecode-0.8/docs/generated/braindecode.models.EEGInceptionERP.rst +0 -123
  274. braindecode-0.8/docs/generated/braindecode.models.EEGInceptionMI.rst +0 -126
  275. braindecode-0.8/docs/generated/braindecode.models.EEGModuleMixin.rst +0 -53
  276. braindecode-0.8/docs/generated/braindecode.models.EEGNetv1.rst +0 -123
  277. braindecode-0.8/docs/generated/braindecode.models.EEGNetv4.rst +0 -123
  278. braindecode-0.8/docs/generated/braindecode.models.EEGResNet.rst +0 -123
  279. braindecode-0.8/docs/generated/braindecode.models.HybridNet.rst +0 -126
  280. braindecode-0.8/docs/generated/braindecode.models.ShallowFBCSPNet.rst +0 -123
  281. braindecode-0.8/docs/generated/braindecode.models.SleepStagerBlanco2020.rst +0 -126
  282. braindecode-0.8/docs/generated/braindecode.models.SleepStagerChambon2018.rst +0 -126
  283. braindecode-0.8/docs/generated/braindecode.models.SleepStagerEldele2021.rst +0 -126
  284. braindecode-0.8/docs/generated/braindecode.models.TCN.rst +0 -126
  285. braindecode-0.8/docs/generated/braindecode.models.TIDNet.rst +0 -126
  286. braindecode-0.8/docs/generated/braindecode.models.TimeDistributed.rst +0 -120
  287. braindecode-0.8/docs/generated/braindecode.models.USleep.rst +0 -126
  288. braindecode-0.8/docs/generated/braindecode.models.get_output_shape.rst +0 -12
  289. braindecode-0.8/docs/generated/braindecode.preprocessing.Crop.rst +0 -21
  290. braindecode-0.8/docs/generated/braindecode.preprocessing.DropChannels.rst +0 -21
  291. braindecode-0.8/docs/generated/braindecode.preprocessing.Filter.rst +0 -21
  292. braindecode-0.8/docs/generated/braindecode.preprocessing.Pick.rst +0 -21
  293. braindecode-0.8/docs/generated/braindecode.preprocessing.Preprocessor.rst +0 -32
  294. braindecode-0.8/docs/generated/braindecode.preprocessing.Resample.rst +0 -21
  295. braindecode-0.8/docs/generated/braindecode.preprocessing.SetEEGReference.rst +0 -21
  296. braindecode-0.8/docs/generated/braindecode.preprocessing.create_fixed_length_windows.rst +0 -12
  297. braindecode-0.8/docs/generated/braindecode.preprocessing.create_windows_from_events.rst +0 -12
  298. braindecode-0.8/docs/generated/braindecode.preprocessing.create_windows_from_target_channels.rst +0 -12
  299. braindecode-0.8/docs/generated/braindecode.preprocessing.exponential_moving_demean.rst +0 -12
  300. braindecode-0.8/docs/generated/braindecode.preprocessing.exponential_moving_standardize.rst +0 -12
  301. braindecode-0.8/docs/generated/braindecode.preprocessing.filterbank.rst +0 -12
  302. braindecode-0.8/docs/generated/braindecode.preprocessing.preprocess.rst +0 -12
  303. braindecode-0.8/docs/generated/braindecode.preprocessing.scale.rst +0 -12
  304. braindecode-0.8/docs/generated/braindecode.regressor.EEGRegressor.rst +0 -145
  305. braindecode-0.8/docs/generated/braindecode.samplers.BalancedSequenceSampler.rst +0 -36
  306. braindecode-0.8/docs/generated/braindecode.samplers.RecordingSampler.rst +0 -39
  307. braindecode-0.8/docs/generated/braindecode.samplers.RelativePositioningSampler.rst +0 -36
  308. braindecode-0.8/docs/generated/braindecode.samplers.SequenceSampler.rst +0 -23
  309. braindecode-0.8/docs/generated/braindecode.training.CroppedLoss.rst +0 -120
  310. braindecode-0.8/docs/generated/braindecode.training.CroppedTimeSeriesEpochScoring.rst +0 -52
  311. braindecode-0.8/docs/generated/braindecode.training.CroppedTrialEpochScoring.rst +0 -57
  312. braindecode-0.8/docs/generated/braindecode.training.PostEpochTrainScoring.rst +0 -52
  313. braindecode-0.8/docs/generated/braindecode.training.TimeSeriesLoss.rst +0 -120
  314. braindecode-0.8/docs/generated/braindecode.training.mixup_criterion.rst +0 -12
  315. braindecode-0.8/docs/generated/braindecode.training.predict_trials.rst +0 -12
  316. braindecode-0.8/docs/generated/braindecode.training.trial_preds_from_window_preds.rst +0 -12
  317. braindecode-0.8/docs/generated/braindecode.util.set_random_seeds.rst +0 -12
  318. braindecode-0.8/docs/generated/braindecode.visualization.compute_amplitude_gradients.rst +0 -12
  319. braindecode-0.8/docs/generated/braindecode.visualization.plot_confusion_matrix.rst +0 -12
  320. braindecode-0.8/pyproject.toml +0 -95
  321. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode.egg-info/dependency_links.txt +0 -0
  322. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode.egg-info/top_level.txt +0 -0
  323. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/_templates/autosummary/class.rst +0 -0
  324. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/_templates/autosummary/function.rst +0 -0
  325. {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/cite.rst +0 -0
@@ -1,6 +1,6 @@
1
1
  BSD 3-Clause License
2
2
 
3
- Copyright (c) 2017-2020 Braindecode Developers
3
+ Copyright (c) 2017-currently Braindecode Developers
4
4
  All rights reserved.
5
5
 
6
6
  Redistribution and use in source and binary forms, with or without modification,
@@ -1,5 +1,8 @@
1
1
  include README.rst
2
2
  include LICENSE.txt
3
+ include NOTICE.txt
4
+
5
+ include braindecode/models/summary.csv
3
6
 
4
7
  recursive-include docs *.ipynb *.rst conf.py Makefile
5
8
  recursive-exclude docs *checkpoint.ipynb
@@ -0,0 +1,20 @@
1
+ # BRAINDECODE Notice
2
+
3
+ ## Licensed Components
4
+
5
+ ### BSD-3-Clause Licensed Files
6
+
7
+ All files within the `src/` directory are licensed under the BSD-3-Clause License.
8
+
9
+ ### CC BY-NC 4.0 Licensed Files
10
+
11
+ The following components are licensed under the Creative Commons Attribution-NonCommercial 4.0 International License:
12
+
13
+ - `braindecode/models/eegminer.py`
14
+
15
+ As well as class later imported into the `braindecode.models.module` named as GeneralizedGaussianFilter.
16
+
17
+ ## License Links
18
+
19
+ - [BSD-3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
20
+ - [CC BY-NC 4.0 License](https://creativecommons.org/licenses/by-nc/4.0/)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: braindecode
3
- Version: 0.8
3
+ Version: 1.3.0.dev176481332
4
4
  Summary: Deep learning software to decode EEG, ECG or MEG signals
5
5
  Author-email: Robin Tibor Schirrmeister <robintibor@gmail.com>
6
6
  Maintainer-email: Alexandre Gramfort <agramfort@meta.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Robin Tibor Schirrmeister <robintibor@gmail.com>
@@ -14,36 +14,49 @@ Classifier: Intended Audience :: Developers
14
14
  Classifier: Intended Audience :: Science/Research
15
15
  Classifier: Topic :: Software Development :: Build Tools
16
16
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
- Classifier: License :: OSI Approved :: BSD License
18
- Classifier: Programming Language :: Python :: 3.8
19
- Classifier: Programming Language :: Python :: 3.9
20
17
  Classifier: Programming Language :: Python :: 3.10
21
18
  Classifier: Programming Language :: Python :: 3.11
22
- Requires-Python: >=3.8
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Requires-Python: >=3.10
23
21
  Description-Content-Type: text/x-rst
24
22
  License-File: LICENSE.txt
25
- Requires-Dist: mne
23
+ License-File: NOTICE.txt
24
+ Requires-Dist: mne>=1.10.0
25
+ Requires-Dist: mne_bids>=0.16
26
26
  Requires-Dist: numpy
27
27
  Requires-Dist: pandas
28
28
  Requires-Dist: scipy
29
29
  Requires-Dist: matplotlib
30
30
  Requires-Dist: h5py
31
- Requires-Dist: skorch
32
- Requires-Dist: torch
31
+ Requires-Dist: skorch>=1.2.0
32
+ Requires-Dist: torch<3.0,>=2.0
33
+ Requires-Dist: torchaudio<3.0,>=2.0
33
34
  Requires-Dist: einops
34
35
  Requires-Dist: joblib
35
- Requires-Dist: torchinfo
36
+ Requires-Dist: torchinfo~=1.8
37
+ Requires-Dist: wfdb
38
+ Requires-Dist: h5py
39
+ Requires-Dist: linear_attention_transformer
36
40
  Requires-Dist: docstring_inheritance
37
41
  Provides-Extra: moabb
38
- Requires-Dist: moabb>=1.0.0; extra == "moabb"
42
+ Requires-Dist: moabb>=1.2.0; extra == "moabb"
43
+ Provides-Extra: eegprep
44
+ Requires-Dist: eegprep[eeglabio]>=0.1.1; extra == "eegprep"
45
+ Provides-Extra: hug
46
+ Requires-Dist: huggingface_hub[torch]>=0.20.0; extra == "hug"
39
47
  Provides-Extra: tests
40
48
  Requires-Dist: pytest; extra == "tests"
41
49
  Requires-Dist: pytest-cov; extra == "tests"
42
50
  Requires-Dist: codecov; extra == "tests"
43
51
  Requires-Dist: pytest_cases; extra == "tests"
52
+ Requires-Dist: mypy; extra == "tests"
44
53
  Provides-Extra: docs
45
54
  Requires-Dist: sphinx_gallery; extra == "docs"
46
55
  Requires-Dist: sphinx_rtd_theme; extra == "docs"
56
+ Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
57
+ Requires-Dist: sphinx-autobuild; extra == "docs"
58
+ Requires-Dist: sphinxcontrib-bibtex; extra == "docs"
59
+ Requires-Dist: sphinx_sitemap; extra == "docs"
47
60
  Requires-Dist: pydata_sphinx_theme; extra == "docs"
48
61
  Requires-Dist: numpydoc; extra == "docs"
49
62
  Requires-Dist: memory_profiler; extra == "docs"
@@ -53,6 +66,11 @@ Requires-Dist: sphinx_design; extra == "docs"
53
66
  Requires-Dist: lightning; extra == "docs"
54
67
  Requires-Dist: seaborn; extra == "docs"
55
68
  Requires-Dist: pre-commit; extra == "docs"
69
+ Requires-Dist: openneuro-py; extra == "docs"
70
+ Requires-Dist: plotly; extra == "docs"
71
+ Provides-Extra: all
72
+ Requires-Dist: braindecode[docs,eegprep,hug,moabb,tests]; extra == "all"
73
+ Dynamic: license-file
56
74
 
57
75
  .. image:: https://badges.gitter.im/braindecodechat/community.svg
58
76
  :alt: Join the chat at https://gitter.im/braindecodechat/community
@@ -166,37 +184,13 @@ as well as the `MNE-Python <https://mne.tools>`_ software that is used by braind
166
184
  Licensing
167
185
  ^^^^^^^^^
168
186
 
169
- Braindecode is **BSD-licenced** (BSD-3-Clause):
170
-
171
- This software is OSI Certified Open Source Software.
172
- OSI Certified is a certification mark of the Open Source Initiative.
173
-
174
- Copyright (c) 2011-2022, authors of Braindecode.
175
- All rights reserved.
176
-
177
- Redistribution and use in source and binary forms, with or without
178
- modification, are permitted provided that the following conditions are met:
179
-
180
- * Redistributions of source code must retain the above copyright notice,
181
- this list of conditions and the following disclaimer.
187
+ This project is primarily licensed under the BSD-3-Clause License.
182
188
 
183
- * Redistributions in binary form must reproduce the above copyright notice,
184
- this list of conditions and the following disclaimer in the documentation
185
- and/or other materials provided with the distribution.
189
+ Additional Components
190
+ ~~~~~~~~~~~~~~~~~~~~~
186
191
 
187
- * Neither the names of braindecode authors nor the names of any
188
- contributors may be used to endorse or promote products derived from
189
- this software without specific prior written permission.
192
+ Some components within this repository are licensed under the Creative Commons Attribution-NonCommercial 4.0 International
193
+ License.
190
194
 
191
- **This software is provided by the copyright holders and contributors
192
- "as is" and any express or implied warranties, including, but not
193
- limited to, the implied warranties of merchantability and fitness for
194
- a particular purpose are disclaimed. In no event shall the copyright
195
- owner or contributors be liable for any direct, indirect, incidental,
196
- special, exemplary, or consequential damages (including, but not
197
- limited to, procurement of substitute goods or services; loss of use,
198
- data, or profits; or business interruption) however caused and on any
199
- theory of liability, whether in contract, strict liability, or tort
200
- (including negligence or otherwise) arising in any way out of the use
201
- of this software, even if advised of the possibility of such
202
- damage.**
195
+ Please refer to the ``LICENSE`` and ``NOTICE`` files for more detailed
196
+ information.
@@ -110,37 +110,13 @@ as well as the `MNE-Python <https://mne.tools>`_ software that is used by braind
110
110
  Licensing
111
111
  ^^^^^^^^^
112
112
 
113
- Braindecode is **BSD-licenced** (BSD-3-Clause):
114
-
115
- This software is OSI Certified Open Source Software.
116
- OSI Certified is a certification mark of the Open Source Initiative.
117
-
118
- Copyright (c) 2011-2022, authors of Braindecode.
119
- All rights reserved.
120
-
121
- Redistribution and use in source and binary forms, with or without
122
- modification, are permitted provided that the following conditions are met:
123
-
124
- * Redistributions of source code must retain the above copyright notice,
125
- this list of conditions and the following disclaimer.
126
-
127
- * Redistributions in binary form must reproduce the above copyright notice,
128
- this list of conditions and the following disclaimer in the documentation
129
- and/or other materials provided with the distribution.
130
-
131
- * Neither the names of braindecode authors nor the names of any
132
- contributors may be used to endorse or promote products derived from
133
- this software without specific prior written permission.
134
-
135
- **This software is provided by the copyright holders and contributors
136
- "as is" and any express or implied warranties, including, but not
137
- limited to, the implied warranties of merchantability and fitness for
138
- a particular purpose are disclaimed. In no event shall the copyright
139
- owner or contributors be liable for any direct, indirect, incidental,
140
- special, exemplary, or consequential damages (including, but not
141
- limited to, procurement of substitute goods or services; loss of use,
142
- data, or profits; or business interruption) however caused and on any
143
- theory of liability, whether in contract, strict liability, or tort
144
- (including negligence or otherwise) arising in any way out of the use
145
- of this software, even if advised of the possibility of such
146
- damage.**
113
+ This project is primarily licensed under the BSD-3-Clause License.
114
+
115
+ Additional Components
116
+ ~~~~~~~~~~~~~~~~~~~~~
117
+
118
+ Some components within this repository are licensed under the Creative Commons Attribution-NonCommercial 4.0 International
119
+ License.
120
+
121
+ Please refer to the ``LICENSE`` and ``NOTICE`` files for more detailed
122
+ information.
@@ -1,7 +1,6 @@
1
- from .version import __version__
2
-
3
1
  from .classifier import EEGClassifier
4
2
  from .regressor import EEGRegressor
3
+ from .version import __version__
5
4
 
6
5
  __all__ = [
7
6
  "__version__",
@@ -0,0 +1,50 @@
1
+ """
2
+ Utilities for data augmentation.
3
+ """
4
+
5
+ from . import functional
6
+ from .base import AugmentedDataLoader, Compose, IdentityTransform, Transform
7
+ from .transforms import (
8
+ BandstopFilter,
9
+ ChannelsDropout,
10
+ ChannelsShuffle,
11
+ ChannelsSymmetry,
12
+ FrequencyShift,
13
+ FTSurrogate,
14
+ GaussianNoise,
15
+ MaskEncoding,
16
+ Mixup,
17
+ SegmentationReconstruction,
18
+ SensorsRotation,
19
+ SensorsXRotation,
20
+ SensorsYRotation,
21
+ SensorsZRotation,
22
+ SignFlip,
23
+ SmoothTimeMask,
24
+ TimeReverse,
25
+ )
26
+
27
+ __all__ = [
28
+ "Transform",
29
+ "IdentityTransform",
30
+ "Compose",
31
+ "AugmentedDataLoader",
32
+ "TimeReverse",
33
+ "SignFlip",
34
+ "FTSurrogate",
35
+ "ChannelsShuffle",
36
+ "ChannelsDropout",
37
+ "GaussianNoise",
38
+ "ChannelsSymmetry",
39
+ "SmoothTimeMask",
40
+ "BandstopFilter",
41
+ "FrequencyShift",
42
+ "SensorsRotation",
43
+ "SensorsZRotation",
44
+ "SensorsYRotation",
45
+ "SensorsXRotation",
46
+ "Mixup",
47
+ "SegmentationReconstruction",
48
+ "MaskEncoding",
49
+ "functional",
50
+ ]
@@ -0,0 +1,222 @@
1
+ # Authors: Cédric Rommel <cedric.rommel@inria.fr>
2
+ # Alexandre Gramfort <alexandre.gramfort@inria.fr>
3
+ # Bruno Aristimunha <b.aristimunha@gmail.com>
4
+ # Martin Wimpff <martin.wimpff@iss.uni-stuttgart.de>
5
+ # Valentin Iovene <val@too.gy>
6
+ # License: BSD (3-clause)
7
+
8
+ from numbers import Real
9
+ from typing import Any, Callable, Optional, Union
10
+
11
+ import torch
12
+ from sklearn.utils import check_random_state
13
+ from torch import Tensor, nn
14
+ from torch.utils.data import DataLoader
15
+ from torch.utils.data._utils.collate import default_collate
16
+
17
+ from .functional import identity
18
+
19
+ Batch = list[tuple[torch.Tensor, int, Any]]
20
+ Output = Union[
21
+ # just outputting X
22
+ torch.Tensor,
23
+ # outputting (X, y) where y can be a tensor or tuple of tensors
24
+ tuple[torch.Tensor, Union[torch.Tensor, tuple[torch.Tensor, ...]]],
25
+ ]
26
+ # (X, y) -> (X', y') where y' can be a tensor or a tuple of tensors
27
+ Operation = Callable[
28
+ [torch.Tensor, torch.Tensor],
29
+ tuple[torch.Tensor, Union[torch.Tensor, tuple[torch.Tensor, ...]]],
30
+ ]
31
+
32
+
33
+ class Transform(torch.nn.Module):
34
+ """Basic transform class used for implementing data augmentation
35
+ operations.
36
+
37
+ Parameters
38
+ ----------
39
+ operation : callable
40
+ A function taking arrays X, y (inputs and targets resp.) and
41
+ other required arguments, and returning the transformed X and y.
42
+ probability : float, optional
43
+ Float between 0 and 1 defining the uniform probability of applying the
44
+ operation. Set to 1.0 by default (e.g always apply the operation).
45
+ random_state: int, optional
46
+ Seed to be used to instantiate numpy random number generator instance.
47
+ Used to decide whether or not to transform given the probability
48
+ argument. Defaults to None.
49
+ """
50
+
51
+ operation: Operation
52
+
53
+ def __init__(self, probability=1.0, random_state=None):
54
+ super().__init__()
55
+ if self.forward.__func__ is Transform.forward:
56
+ assert callable(self.operation), "operation should be a ``callable``. "
57
+
58
+ assert isinstance(probability, Real), (
59
+ f"probability should be a ``real``. Got {type(probability)}."
60
+ )
61
+ assert probability <= 1.0 and probability >= 0.0, (
62
+ "probability should be between 0 and 1."
63
+ )
64
+ self._probability = probability
65
+ self.rng = check_random_state(random_state)
66
+
67
+ def get_augmentation_params(self, *batch):
68
+ return dict()
69
+
70
+ def forward(self, X: Tensor, y: Optional[Tensor] = None) -> Output:
71
+ """General forward pass for an augmentation transform.
72
+
73
+ Parameters
74
+ ----------
75
+ X : torch.Tensor
76
+ EEG input example or batch.
77
+ y : torch.Tensor | None
78
+ EEG labels for the example or batch. Defaults to None.
79
+
80
+ Returns
81
+ -------
82
+ torch.Tensor
83
+ Transformed inputs.
84
+ torch.Tensor, optional
85
+ Transformed labels. Only returned when y is not None.
86
+ """
87
+ X = torch.as_tensor(X).float()
88
+
89
+ out_X = X.clone()
90
+ # check if input has a batch dimension
91
+ if len(out_X.shape) < 3:
92
+ out_X = out_X[None, ...]
93
+
94
+ if y is not None:
95
+ y = torch.as_tensor(y).to(out_X.device)
96
+ out_y = y.clone()
97
+ if len(out_y.shape) == 0:
98
+ out_y = out_y.reshape(1)
99
+ else:
100
+ out_y = torch.zeros(out_X.shape[0], device=out_X.device)
101
+
102
+ # Samples a mask setting for each example whether they should stay
103
+ # unchanged or not
104
+ mask = self._get_mask(out_X.shape[0], out_X.device)
105
+ num_valid = mask.sum().long()
106
+
107
+ if num_valid > 0:
108
+ # Uses the mask to define the output
109
+ out_X[mask, ...], tr_y = self.operation(
110
+ out_X[mask, ...],
111
+ out_y[mask],
112
+ **self.get_augmentation_params(out_X[mask, ...], out_y[mask]),
113
+ )
114
+ # Apply the operation defining the Transform to the whole batch
115
+ if isinstance(tr_y, tuple):
116
+ out_y = tuple(tmp_y[mask] for tmp_y in tr_y)
117
+ else:
118
+ out_y[mask] = tr_y
119
+
120
+ # potentially remove empty batch dimension again
121
+ out_X = out_X.reshape_as(X)
122
+ if y is not None:
123
+ return out_X, out_y
124
+ else:
125
+ return out_X
126
+
127
+ def _get_mask(self, batch_size, device) -> torch.Tensor:
128
+ """Samples whether to apply operation or not over the whole batch"""
129
+ return torch.as_tensor(self.probability > self.rng.uniform(size=batch_size)).to(
130
+ device
131
+ )
132
+
133
+ @property
134
+ def probability(self):
135
+ return self._probability
136
+
137
+
138
+ class IdentityTransform(Transform):
139
+ """Identity transform.
140
+
141
+ Transform that does not change the input.
142
+ """
143
+
144
+ operation = staticmethod(identity) # type: ignore[assignment]
145
+ # https://github.com/python/mypy/issues/4574
146
+
147
+
148
+ class Compose(Transform):
149
+ """Transform composition.
150
+
151
+ Callable class allowing to cast a sequence of Transform objects into a
152
+ single one.
153
+
154
+ Parameters
155
+ ----------
156
+ transforms: list
157
+ Sequence of Transforms to be composed.
158
+ """
159
+
160
+ def __init__(self, transforms):
161
+ self.transforms = transforms
162
+ super().__init__()
163
+
164
+ def forward(self, X, y):
165
+ for transform in self.transforms:
166
+ X, y = transform(X, y)
167
+ return X, y
168
+
169
+
170
+ def _make_collateable(transform, device=None):
171
+ """Wraps a transform to make it collateable.
172
+ with device control."""
173
+
174
+ def _collate_fn(batch):
175
+ collated_batch = default_collate(batch)
176
+ X, y = collated_batch[:2]
177
+
178
+ if device is not None:
179
+ X = X.to(device)
180
+ y = y.to(device)
181
+
182
+ return (*transform(X, y), *collated_batch[2:])
183
+
184
+ return _collate_fn
185
+
186
+
187
+ class AugmentedDataLoader(DataLoader):
188
+ """A base dataloader class customized to applying augmentation Transforms.
189
+
190
+ Parameters
191
+ ----------
192
+ dataset : RecordDataset
193
+ The dataset containing the signals.
194
+ transforms : list | Transform, optional
195
+ Transform or sequence of Transform to be applied to each batch.
196
+ device : str | torch.device | None, optional
197
+ Device on which to transform the data. Defaults to None.
198
+ **kwargs : dict, optional
199
+ keyword arguments to pass to standard DataLoader class.
200
+ """
201
+
202
+ def __init__(self, dataset, transforms=None, device=None, **kwargs):
203
+ if "collate_fn" in kwargs:
204
+ raise ValueError(
205
+ "collate_fn cannot be used in this context because it is used "
206
+ "to pass transform"
207
+ )
208
+ if transforms is None or (
209
+ isinstance(transforms, list) and len(transforms) == 0
210
+ ):
211
+ self.collated_tr = _make_collateable(IdentityTransform(), device=device)
212
+ elif isinstance(transforms, (Transform, nn.Module)):
213
+ self.collated_tr = _make_collateable(transforms, device=device)
214
+ elif isinstance(transforms, list):
215
+ self.collated_tr = _make_collateable(Compose(transforms), device=device)
216
+ else:
217
+ raise TypeError(
218
+ "transforms can be either a Transform object "
219
+ "or a list of Transform objects."
220
+ )
221
+
222
+ super().__init__(dataset, collate_fn=self.collated_tr, **kwargs)