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.
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/LICENSE.txt +1 -1
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/MANIFEST.in +3 -0
- braindecode-1.3.0.dev176481332/NOTICE.txt +20 -0
- {braindecode-0.8/braindecode.egg-info → braindecode-1.3.0.dev176481332}/PKG-INFO +36 -42
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/README.rst +10 -34
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/__init__.py +1 -2
- braindecode-1.3.0.dev176481332/braindecode/augmentation/__init__.py +50 -0
- braindecode-1.3.0.dev176481332/braindecode/augmentation/base.py +222 -0
- braindecode-1.3.0.dev176481332/braindecode/augmentation/functional.py +1196 -0
- braindecode-1.3.0.dev176481332/braindecode/augmentation/transforms.py +1273 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/classifier.py +26 -24
- braindecode-1.3.0.dev176481332/braindecode/datasets/__init__.py +42 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/base.py +804 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/bbci.py +694 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/bcicomp.py +194 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/bids.py +245 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/experimental.py +218 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/mne.py +170 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/moabb.py +209 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/nmt.py +311 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/sleep_physio_challe_18.py +413 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/sleep_physionet.py +125 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/tuh.py +588 -0
- braindecode-1.3.0.dev176481332/braindecode/datasets/xy.py +95 -0
- braindecode-1.3.0.dev176481332/braindecode/datautil/__init__.py +52 -0
- braindecode-1.3.0.dev176481332/braindecode/datautil/serialization.py +358 -0
- braindecode-1.3.0.dev176481332/braindecode/datautil/util.py +41 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/eegneuralnet.py +65 -47
- braindecode-1.3.0.dev176481332/braindecode/functional/__init__.py +22 -0
- braindecode-1.3.0.dev176481332/braindecode/functional/functions.py +254 -0
- braindecode-1.3.0.dev176481332/braindecode/functional/initialization.py +46 -0
- braindecode-1.3.0.dev176481332/braindecode/models/__init__.py +104 -0
- braindecode-1.3.0.dev176481332/braindecode/models/atcnet.py +826 -0
- braindecode-1.3.0.dev176481332/braindecode/models/attentionbasenet.py +731 -0
- braindecode-1.3.0.dev176481332/braindecode/models/attn_sleep.py +547 -0
- braindecode-1.3.0.dev176481332/braindecode/models/base.py +574 -0
- braindecode-1.3.0.dev176481332/braindecode/models/bendr.py +469 -0
- braindecode-1.3.0.dev176481332/braindecode/models/biot.py +506 -0
- braindecode-1.3.0.dev176481332/braindecode/models/contrawr.py +319 -0
- braindecode-1.3.0.dev176481332/braindecode/models/ctnet.py +541 -0
- braindecode-1.3.0.dev176481332/braindecode/models/deep4.py +376 -0
- braindecode-1.3.0.dev176481332/braindecode/models/deepsleepnet.py +417 -0
- braindecode-1.3.0.dev176481332/braindecode/models/eegconformer.py +470 -0
- braindecode-1.3.0.dev176481332/braindecode/models/eeginception_erp.py +379 -0
- braindecode-1.3.0.dev176481332/braindecode/models/eeginception_mi.py +379 -0
- braindecode-1.3.0.dev176481332/braindecode/models/eegitnet.py +302 -0
- braindecode-1.3.0.dev176481332/braindecode/models/eegminer.py +256 -0
- braindecode-1.3.0.dev176481332/braindecode/models/eegnet.py +359 -0
- braindecode-1.3.0.dev176481332/braindecode/models/eegnex.py +354 -0
- braindecode-1.3.0.dev176481332/braindecode/models/eegsimpleconv.py +201 -0
- braindecode-1.3.0.dev176481332/braindecode/models/eegtcnet.py +337 -0
- braindecode-1.3.0.dev176481332/braindecode/models/fbcnet.py +223 -0
- braindecode-1.3.0.dev176481332/braindecode/models/fblightconvnet.py +315 -0
- braindecode-1.3.0.dev176481332/braindecode/models/fbmsnet.py +326 -0
- braindecode-1.3.0.dev176481332/braindecode/models/hybrid.py +126 -0
- braindecode-1.3.0.dev176481332/braindecode/models/ifnet.py +443 -0
- braindecode-1.3.0.dev176481332/braindecode/models/labram.py +1292 -0
- braindecode-1.3.0.dev176481332/braindecode/models/msvtnet.py +377 -0
- braindecode-1.3.0.dev176481332/braindecode/models/patchedtransformer.py +640 -0
- braindecode-1.3.0.dev176481332/braindecode/models/sccnet.py +280 -0
- braindecode-1.3.0.dev176481332/braindecode/models/shallow_fbcsp.py +210 -0
- braindecode-1.3.0.dev176481332/braindecode/models/signal_jepa.py +1095 -0
- braindecode-1.3.0.dev176481332/braindecode/models/sinc_shallow.py +340 -0
- braindecode-1.3.0.dev176481332/braindecode/models/sleep_stager_blanco_2020.py +169 -0
- braindecode-1.3.0.dev176481332/braindecode/models/sleep_stager_chambon_2018.py +159 -0
- braindecode-1.3.0.dev176481332/braindecode/models/sparcnet.py +426 -0
- braindecode-1.3.0.dev176481332/braindecode/models/sstdpn.py +869 -0
- braindecode-1.3.0.dev176481332/braindecode/models/summary.csv +42 -0
- braindecode-1.3.0.dev176481332/braindecode/models/syncnet.py +234 -0
- braindecode-1.3.0.dev176481332/braindecode/models/tcn.py +275 -0
- braindecode-1.3.0.dev176481332/braindecode/models/tidnet.py +397 -0
- braindecode-1.3.0.dev176481332/braindecode/models/tsinception.py +295 -0
- braindecode-1.3.0.dev176481332/braindecode/models/usleep.py +439 -0
- braindecode-1.3.0.dev176481332/braindecode/models/util.py +132 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/__init__.py +84 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/activation.py +60 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/attention.py +760 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/blocks.py +108 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/convolution.py +277 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/filter.py +629 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/layers.py +132 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/linear.py +49 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/parametrization.py +38 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/stats.py +77 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/util.py +76 -0
- braindecode-1.3.0.dev176481332/braindecode/modules/wrapper.py +73 -0
- braindecode-1.3.0.dev176481332/braindecode/preprocessing/__init__.py +61 -0
- braindecode-1.3.0.dev176481332/braindecode/preprocessing/eegprep_preprocess.py +1202 -0
- braindecode-1.3.0.dev176481332/braindecode/preprocessing/mne_preprocess.py +77 -0
- braindecode-1.3.0.dev176481332/braindecode/preprocessing/preprocess.py +481 -0
- braindecode-1.3.0.dev176481332/braindecode/preprocessing/util.py +166 -0
- braindecode-1.3.0.dev176481332/braindecode/preprocessing/windowers.py +1037 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/regressor.py +23 -12
- braindecode-1.3.0.dev176481332/braindecode/samplers/__init__.py +18 -0
- braindecode-1.3.0.dev176481332/braindecode/samplers/base.py +399 -0
- braindecode-1.3.0.dev176481332/braindecode/samplers/ssl.py +263 -0
- braindecode-1.3.0.dev176481332/braindecode/training/__init__.py +23 -0
- braindecode-1.3.0.dev176481332/braindecode/training/callbacks.py +23 -0
- braindecode-1.3.0.dev176481332/braindecode/training/losses.py +105 -0
- braindecode-1.3.0.dev176481332/braindecode/training/scoring.py +477 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode/util.py +55 -59
- braindecode-1.3.0.dev176481332/braindecode/version.py +1 -0
- braindecode-1.3.0.dev176481332/braindecode/visualization/__init__.py +8 -0
- braindecode-1.3.0.dev176481332/braindecode/visualization/confusion_matrices.py +289 -0
- braindecode-1.3.0.dev176481332/braindecode/visualization/gradients.py +62 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332/braindecode.egg-info}/PKG-INFO +36 -42
- braindecode-1.3.0.dev176481332/braindecode.egg-info/SOURCES.txt +137 -0
- braindecode-1.3.0.dev176481332/braindecode.egg-info/requires.txt +55 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/Makefile +6 -1
- braindecode-1.3.0.dev176481332/docs/api.rst +598 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/conf.py +198 -137
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/help.rst +7 -19
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/index.rst +5 -4
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/install/install.rst +6 -4
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/install/install_pip.rst +6 -4
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/install/install_source.rst +6 -4
- braindecode-1.3.0.dev176481332/docs/models/categorization/attention.rst +31 -0
- braindecode-1.3.0.dev176481332/docs/models/categorization/channel.rst +31 -0
- braindecode-1.3.0.dev176481332/docs/models/categorization/convolution.rst +33 -0
- braindecode-1.3.0.dev176481332/docs/models/categorization/filterbank.rst +31 -0
- braindecode-1.3.0.dev176481332/docs/models/categorization/gnn.rst +27 -0
- braindecode-1.3.0.dev176481332/docs/models/categorization/interpretable.rst +31 -0
- braindecode-1.3.0.dev176481332/docs/models/categorization/lbm.rst +31 -0
- braindecode-1.3.0.dev176481332/docs/models/categorization/recurrent.rst +31 -0
- braindecode-1.3.0.dev176481332/docs/models/categorization/spd.rst +31 -0
- braindecode-1.3.0.dev176481332/docs/models/models.rst +78 -0
- braindecode-1.3.0.dev176481332/docs/models/models_categorization.rst +201 -0
- braindecode-1.3.0.dev176481332/docs/models/models_table.rst +191 -0
- braindecode-1.3.0.dev176481332/docs/models/models_visualization.rst +31 -0
- braindecode-1.3.0.dev176481332/docs/sg_execution_times.rst +112 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/whats_new.rst +191 -16
- braindecode-1.3.0.dev176481332/pyproject.toml +134 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/setup.cfg +8 -0
- braindecode-0.8/braindecode/version.py +0 -1
- braindecode-0.8/braindecode.egg-info/SOURCES.txt +0 -210
- braindecode-0.8/braindecode.egg-info/requires.txt +0 -34
- braindecode-0.8/docs/_build/html/_downloads/090305d06248840b75133975e5121f41/plot_sleep_staging_chambon2018.ipynb +0 -291
- braindecode-0.8/docs/_build/html/_downloads/0f2bf063e08b7d05b80e0004fcbbb6f9/benchmark_lazy_eager_loading.ipynb +0 -183
- braindecode-0.8/docs/_build/html/_downloads/10fc813a8f78253f4bf301264950f5c1/plot_bcic_iv_4_ecog_cropped.ipynb +0 -338
- braindecode-0.8/docs/_build/html/_downloads/1c6590d134fa0befda654e89aa55b2ac/plot_benchmark_preprocessing.ipynb +0 -104
- braindecode-0.8/docs/_build/html/_downloads/1d879df548fa18be8c23d9ca0dc008d4/plot_data_augmentation.ipynb +0 -259
- braindecode-0.8/docs/_build/html/_downloads/2466f8ec5c733d0bd65e187b45d875cc/plot_data_augmentation_search.ipynb +0 -302
- braindecode-0.8/docs/_build/html/_downloads/263464a28477cf8decb861ae6e2e9be7/plot_how_train_test_and_tune.ipynb +0 -375
- braindecode-0.8/docs/_build/html/_downloads/3862cafd7f0d815e434319ffe525afc8/plot_bcic_iv_2a_moabb_cropped.ipynb +0 -226
- braindecode-0.8/docs/_build/html/_downloads/408ca4ffd0ea1f76faa9ef602734ac94/plot_tuh_eeg_corpus.ipynb +0 -187
- braindecode-0.8/docs/_build/html/_downloads/75a73c7d94f3a671fd3dec28f4031ead/plot_regression.ipynb +0 -212
- braindecode-0.8/docs/_build/html/_downloads/84fbcd59a346e5e56758285122dc69e2/plot_sleep_staging_eldele2021.ipynb +0 -291
- braindecode-0.8/docs/_build/html/_downloads/8616a7f968141825e56ab3e3d59be449/plot_tuh_discrete_multitarget.ipynb +0 -169
- braindecode-0.8/docs/_build/html/_downloads/8b5ba06718764b959e8dea1dd0bb97df/plot_sleep_staging_usleep.ipynb +0 -255
- braindecode-0.8/docs/_build/html/_downloads/91651c9d4fde110b4a53f5775a91acc5/plot_mne_dataset_example.ipynb +0 -104
- braindecode-0.8/docs/_build/html/_downloads/9a4447462c3b255ba7e5ca212bbadd52/plot_bcic_iv_2a_moabb_trial.ipynb +0 -253
- braindecode-0.8/docs/_build/html/_downloads/a39e4245738e55e0eb7084c545ed05bc/plot_hyperparameter_tuning_with_scikit-learn.ipynb +0 -257
- braindecode-0.8/docs/_build/html/_downloads/a6249715d3c30cb41c4af85938cca008/plot_moabb_dataset_example.ipynb +0 -140
- braindecode-0.8/docs/_build/html/_downloads/a7ccc5c1d1d2775e08c053bb25c81a91/plot_bcic_iv_4_ecog_trial.ipynb +0 -369
- braindecode-0.8/docs/_build/html/_downloads/a86d0c5f3a882a069df1683a708d3e25/plot_train_in_pure_pytorch_and_pytorch_lightning.ipynb +0 -243
- braindecode-0.8/docs/_build/html/_downloads/aa8426d97090e7b3062c4e4732c3214a/plot_relative_positioning.ipynb +0 -266
- braindecode-0.8/docs/_build/html/_downloads/b9d19304ecd233ea7a79d4365316ea49/plot_load_save_datasets.ipynb +0 -169
- braindecode-0.8/docs/_build/html/_downloads/f3c89d39e947a121c7920b4d415413a2/plot_split_dataset.ipynb +0 -180
- braindecode-0.8/docs/_build/html/_downloads/f7b38cac92c078838442753121efc297/plot_custom_dataset_example.ipynb +0 -133
- braindecode-0.8/docs/_build/html/_downloads/fff46913db5173d3ae22c1113acffb45/plot_basic_training_epochs.ipynb +0 -219
- braindecode-0.8/docs/api.rst +0 -256
- braindecode-0.8/docs/auto_examples/advanced_training/index.rst +0 -98
- braindecode-0.8/docs/auto_examples/advanced_training/plot_bcic_iv_4_ecog_cropped.ipynb +0 -338
- braindecode-0.8/docs/auto_examples/advanced_training/plot_bcic_iv_4_ecog_cropped.rst +0 -755
- braindecode-0.8/docs/auto_examples/advanced_training/plot_data_augmentation.ipynb +0 -259
- braindecode-0.8/docs/auto_examples/advanced_training/plot_data_augmentation.rst +0 -587
- braindecode-0.8/docs/auto_examples/advanced_training/plot_data_augmentation_search.ipynb +0 -302
- braindecode-0.8/docs/auto_examples/advanced_training/plot_data_augmentation_search.rst +0 -720
- braindecode-0.8/docs/auto_examples/advanced_training/plot_relative_positioning.ipynb +0 -266
- braindecode-0.8/docs/auto_examples/advanced_training/plot_relative_positioning.rst +0 -858
- braindecode-0.8/docs/auto_examples/advanced_training/sg_execution_times.rst +0 -19
- braindecode-0.8/docs/auto_examples/applied_examples/index.rst +0 -116
- braindecode-0.8/docs/auto_examples/applied_examples/plot_bcic_iv_4_ecog_trial.ipynb +0 -369
- braindecode-0.8/docs/auto_examples/applied_examples/plot_bcic_iv_4_ecog_trial.rst +0 -688
- braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_chambon2018.ipynb +0 -291
- braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_chambon2018.rst +0 -697
- braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_eldele2021.ipynb +0 -291
- braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_eldele2021.rst +0 -793
- braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_usleep.ipynb +0 -255
- braindecode-0.8/docs/auto_examples/applied_examples/plot_sleep_staging_usleep.rst +0 -711
- braindecode-0.8/docs/auto_examples/applied_examples/plot_tuh_eeg_corpus.ipynb +0 -187
- braindecode-0.8/docs/auto_examples/applied_examples/plot_tuh_eeg_corpus.rst +0 -474
- braindecode-0.8/docs/auto_examples/applied_examples/sg_execution_times.rst +0 -21
- braindecode-0.8/docs/auto_examples/datasets_io/benchmark_lazy_eager_loading.ipynb +0 -183
- braindecode-0.8/docs/auto_examples/datasets_io/benchmark_lazy_eager_loading.rst +0 -431
- braindecode-0.8/docs/auto_examples/datasets_io/index.rst +0 -170
- braindecode-0.8/docs/auto_examples/datasets_io/plot_benchmark_preprocessing.ipynb +0 -104
- braindecode-0.8/docs/auto_examples/datasets_io/plot_benchmark_preprocessing.rst +0 -603
- braindecode-0.8/docs/auto_examples/datasets_io/plot_custom_dataset_example.ipynb +0 -133
- braindecode-0.8/docs/auto_examples/datasets_io/plot_custom_dataset_example.rst +0 -328
- braindecode-0.8/docs/auto_examples/datasets_io/plot_load_save_datasets.ipynb +0 -169
- braindecode-0.8/docs/auto_examples/datasets_io/plot_load_save_datasets.rst +0 -505
- braindecode-0.8/docs/auto_examples/datasets_io/plot_mne_dataset_example.ipynb +0 -104
- braindecode-0.8/docs/auto_examples/datasets_io/plot_mne_dataset_example.rst +0 -357
- braindecode-0.8/docs/auto_examples/datasets_io/plot_moabb_dataset_example.ipynb +0 -140
- braindecode-0.8/docs/auto_examples/datasets_io/plot_moabb_dataset_example.rst +0 -394
- braindecode-0.8/docs/auto_examples/datasets_io/plot_split_dataset.ipynb +0 -180
- braindecode-0.8/docs/auto_examples/datasets_io/plot_split_dataset.rst +0 -675
- braindecode-0.8/docs/auto_examples/datasets_io/plot_tuh_discrete_multitarget.ipynb +0 -169
- braindecode-0.8/docs/auto_examples/datasets_io/plot_tuh_discrete_multitarget.rst +0 -374
- braindecode-0.8/docs/auto_examples/datasets_io/sg_execution_times.rst +0 -27
- braindecode-0.8/docs/auto_examples/index.rst +0 -526
- braindecode-0.8/docs/auto_examples/model_building/index.rst +0 -152
- braindecode-0.8/docs/auto_examples/model_building/plot_basic_training_epochs.ipynb +0 -219
- braindecode-0.8/docs/auto_examples/model_building/plot_basic_training_epochs.rst +0 -588
- braindecode-0.8/docs/auto_examples/model_building/plot_bcic_iv_2a_moabb_cropped.ipynb +0 -226
- braindecode-0.8/docs/auto_examples/model_building/plot_bcic_iv_2a_moabb_cropped.rst +0 -649
- braindecode-0.8/docs/auto_examples/model_building/plot_bcic_iv_2a_moabb_trial.ipynb +0 -253
- braindecode-0.8/docs/auto_examples/model_building/plot_bcic_iv_2a_moabb_trial.rst +0 -591
- braindecode-0.8/docs/auto_examples/model_building/plot_how_train_test_and_tune.ipynb +0 -375
- braindecode-0.8/docs/auto_examples/model_building/plot_how_train_test_and_tune.rst +0 -1044
- braindecode-0.8/docs/auto_examples/model_building/plot_hyperparameter_tuning_with_scikit-learn.ipynb +0 -257
- braindecode-0.8/docs/auto_examples/model_building/plot_hyperparameter_tuning_with_scikit-learn.rst +0 -724
- braindecode-0.8/docs/auto_examples/model_building/plot_regression.ipynb +0 -212
- braindecode-0.8/docs/auto_examples/model_building/plot_regression.rst +0 -549
- braindecode-0.8/docs/auto_examples/model_building/plot_train_in_pure_pytorch_and_pytorch_lightning.ipynb +0 -243
- braindecode-0.8/docs/auto_examples/model_building/plot_train_in_pure_pytorch_and_pytorch_lightning.rst +0 -698
- braindecode-0.8/docs/auto_examples/model_building/sg_execution_times.rst +0 -25
- braindecode-0.8/docs/generated/braindecode.augmentation.AugmentedDataLoader.rst +0 -21
- braindecode-0.8/docs/generated/braindecode.augmentation.BandstopFilter.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.ChannelsDropout.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.ChannelsShuffle.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.ChannelsSymmetry.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.Compose.rst +0 -122
- braindecode-0.8/docs/generated/braindecode.augmentation.FTSurrogate.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.FrequencyShift.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.GaussianNoise.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.IdentityTransform.rst +0 -124
- braindecode-0.8/docs/generated/braindecode.augmentation.Mixup.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.SensorsRotation.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.SensorsXRotation.rst +0 -113
- braindecode-0.8/docs/generated/braindecode.augmentation.SensorsYRotation.rst +0 -113
- braindecode-0.8/docs/generated/braindecode.augmentation.SensorsZRotation.rst +0 -113
- braindecode-0.8/docs/generated/braindecode.augmentation.SignFlip.rst +0 -124
- braindecode-0.8/docs/generated/braindecode.augmentation.SmoothTimeMask.rst +0 -129
- braindecode-0.8/docs/generated/braindecode.augmentation.TimeReverse.rst +0 -124
- braindecode-0.8/docs/generated/braindecode.augmentation.Transform.rst +0 -127
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.bandstop_filter.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.channels_dropout.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.channels_permute.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.channels_shuffle.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.frequency_shift.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.ft_surrogate.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.gaussian_noise.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.identity.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.mixup.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.sensors_rotation.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.sign_flip.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.smooth_time_mask.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.augmentation.functional.time_reverse.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.classifier.EEGClassifier.rst +0 -150
- braindecode-0.8/docs/generated/braindecode.datasets.BCICompetitionIVDataset4.rst +0 -42
- braindecode-0.8/docs/generated/braindecode.datasets.BNCI2014001.rst +0 -29
- braindecode-0.8/docs/generated/braindecode.datasets.BaseConcatDataset.rst +0 -55
- braindecode-0.8/docs/generated/braindecode.datasets.BaseDataset.rst +0 -32
- braindecode-0.8/docs/generated/braindecode.datasets.HGD.rst +0 -29
- braindecode-0.8/docs/generated/braindecode.datasets.MOABBDataset.rst +0 -29
- braindecode-0.8/docs/generated/braindecode.datasets.SleepPhysionet.rst +0 -29
- braindecode-0.8/docs/generated/braindecode.datasets.TUH.rst +0 -29
- braindecode-0.8/docs/generated/braindecode.datasets.TUHAbnormal.rst +0 -29
- braindecode-0.8/docs/generated/braindecode.datasets.WindowsDataset.rst +0 -32
- braindecode-0.8/docs/generated/braindecode.datasets.create_from_X_y.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.datasets.create_from_mne_epochs.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.datasets.create_from_mne_raw.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.datautil.load_concat_dataset.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.datautil.save_concat_dataset.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.models.ATCNet.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.Deep4Net.rst +0 -123
- braindecode-0.8/docs/generated/braindecode.models.DeepSleepNet.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.EEGConformer.rst +0 -133
- braindecode-0.8/docs/generated/braindecode.models.EEGITNet.rst +0 -123
- braindecode-0.8/docs/generated/braindecode.models.EEGInception.rst +0 -123
- braindecode-0.8/docs/generated/braindecode.models.EEGInceptionERP.rst +0 -123
- braindecode-0.8/docs/generated/braindecode.models.EEGInceptionMI.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.EEGModuleMixin.rst +0 -53
- braindecode-0.8/docs/generated/braindecode.models.EEGNetv1.rst +0 -123
- braindecode-0.8/docs/generated/braindecode.models.EEGNetv4.rst +0 -123
- braindecode-0.8/docs/generated/braindecode.models.EEGResNet.rst +0 -123
- braindecode-0.8/docs/generated/braindecode.models.HybridNet.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.ShallowFBCSPNet.rst +0 -123
- braindecode-0.8/docs/generated/braindecode.models.SleepStagerBlanco2020.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.SleepStagerChambon2018.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.SleepStagerEldele2021.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.TCN.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.TIDNet.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.TimeDistributed.rst +0 -120
- braindecode-0.8/docs/generated/braindecode.models.USleep.rst +0 -126
- braindecode-0.8/docs/generated/braindecode.models.get_output_shape.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.preprocessing.Crop.rst +0 -21
- braindecode-0.8/docs/generated/braindecode.preprocessing.DropChannels.rst +0 -21
- braindecode-0.8/docs/generated/braindecode.preprocessing.Filter.rst +0 -21
- braindecode-0.8/docs/generated/braindecode.preprocessing.Pick.rst +0 -21
- braindecode-0.8/docs/generated/braindecode.preprocessing.Preprocessor.rst +0 -32
- braindecode-0.8/docs/generated/braindecode.preprocessing.Resample.rst +0 -21
- braindecode-0.8/docs/generated/braindecode.preprocessing.SetEEGReference.rst +0 -21
- braindecode-0.8/docs/generated/braindecode.preprocessing.create_fixed_length_windows.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.preprocessing.create_windows_from_events.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.preprocessing.create_windows_from_target_channels.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.preprocessing.exponential_moving_demean.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.preprocessing.exponential_moving_standardize.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.preprocessing.filterbank.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.preprocessing.preprocess.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.preprocessing.scale.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.regressor.EEGRegressor.rst +0 -145
- braindecode-0.8/docs/generated/braindecode.samplers.BalancedSequenceSampler.rst +0 -36
- braindecode-0.8/docs/generated/braindecode.samplers.RecordingSampler.rst +0 -39
- braindecode-0.8/docs/generated/braindecode.samplers.RelativePositioningSampler.rst +0 -36
- braindecode-0.8/docs/generated/braindecode.samplers.SequenceSampler.rst +0 -23
- braindecode-0.8/docs/generated/braindecode.training.CroppedLoss.rst +0 -120
- braindecode-0.8/docs/generated/braindecode.training.CroppedTimeSeriesEpochScoring.rst +0 -52
- braindecode-0.8/docs/generated/braindecode.training.CroppedTrialEpochScoring.rst +0 -57
- braindecode-0.8/docs/generated/braindecode.training.PostEpochTrainScoring.rst +0 -52
- braindecode-0.8/docs/generated/braindecode.training.TimeSeriesLoss.rst +0 -120
- braindecode-0.8/docs/generated/braindecode.training.mixup_criterion.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.training.predict_trials.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.training.trial_preds_from_window_preds.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.util.set_random_seeds.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.visualization.compute_amplitude_gradients.rst +0 -12
- braindecode-0.8/docs/generated/braindecode.visualization.plot_confusion_matrix.rst +0 -12
- braindecode-0.8/pyproject.toml +0 -95
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-0.8 → braindecode-1.3.0.dev176481332}/docs/cite.rst +0 -0
|
@@ -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
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: braindecode
|
|
3
|
-
Version: 0.
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
and/or other materials provided with the distribution.
|
|
189
|
+
Additional Components
|
|
190
|
+
~~~~~~~~~~~~~~~~~~~~~
|
|
186
191
|
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
192
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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.
|
|
@@ -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)
|