braindecode 1.8.1.dev176771289__tar.gz → 1.8.1.dev176908150__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.
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/NOTICE.txt +0 -1
- {braindecode-1.8.1.dev176771289/braindecode.egg-info → braindecode-1.8.1.dev176908150}/PKG-INFO +3 -2
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/augmentation/__init__.py +2 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/augmentation/base.py +99 -3
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/augmentation/functional.py +96 -3
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/augmentation/transforms.py +94 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/classifier.py +6 -1
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/bids/datasets.py +32 -8
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/chb_mit.py +5 -39
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/siena.py +5 -39
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/sleep_physio_challe_18.py +0 -46
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/utils.py +37 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/eegneuralnet.py +24 -8
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/functional/__init__.py +19 -1
- braindecode-1.8.1.dev176908150/braindecode/functional/attention.py +152 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/functional/functions.py +106 -1
- braindecode-1.8.1.dev176908150/braindecode/functional/initialization.py +139 -0
- braindecode-1.8.1.dev176908150/braindecode/functional/patches.py +105 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/atcnet.py +10 -14
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/attn_sleep.py +9 -13
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/axon.py +11 -4
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/barista.py +27 -26
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/base.py +53 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/bendr.py +20 -12
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/biot.py +10 -58
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/brainbert.py +49 -17
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/brainmodule.py +1 -1
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/brainomni.py +23 -16
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/brant.py +3 -3
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/cbramod.py +12 -11
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/codebrain.py +1 -1
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/csbrain.py +14 -7
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/ctnet.py +42 -177
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/dance.py +6 -11
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/deep4.py +6 -2
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/diver1.py +11 -8
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/duin.py +23 -14
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegconformer.py +20 -87
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegdino.py +18 -68
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eeginception_erp.py +4 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegminer.py +4 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegnet.py +4 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegpt.py +34 -354
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/epint.py +26 -10
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/ifnet.py +20 -24
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/labram.py +18 -33
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/luna.py +46 -117
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/mapa.py +42 -26
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/medformer.py +32 -56
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/mirepnet.py +27 -88
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/mscformer.py +42 -189
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/mvpformer.py +18 -10
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/neuropose.py +18 -18
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/neurorvq.py +47 -87
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/neurorvq_tokenizer.py +37 -11
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/patchedtransformer.py +37 -22
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/popt.py +169 -4
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/reve.py +10 -10
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/sensingdynamics.py +18 -19
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/shallow_fbcsp.py +6 -2
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/signal_jepa.py +24 -12
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/sinc_shallow.py +15 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/sleepfm.py +3 -3
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/sparcnet.py +14 -10
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/steegformer.py +18 -30
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/tcformer.py +37 -37
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/tidnet.py +13 -4
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/tmsanet.py +20 -9
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/util.py +42 -152
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/vemg2pose.py +20 -22
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/zuna.py +192 -30
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/__init__.py +18 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/attention.py +127 -94
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/blocks.py +47 -51
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/dance_modules.py +5 -3
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/layers.py +234 -2
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/preprocessing/mne_preprocess.py +79 -4
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/regressor.py +6 -1
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/samplers/base.py +27 -17
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/training/scoring.py +33 -18
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/util.py +13 -9
- braindecode-1.8.1.dev176908150/braindecode/version.py +1 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/visualization/frequency.py +11 -7
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150/braindecode.egg-info}/PKG-INFO +3 -2
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode.egg-info/SOURCES.txt +2 -2
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode.egg-info/requires.txt +2 -1
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/api.rst +22 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/whats_new.rst +91 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/pyproject.toml +8 -2
- braindecode-1.8.1.dev176771289/braindecode/datasets/bids/format.py +0 -717
- braindecode-1.8.1.dev176771289/braindecode/functional/initialization.py +0 -47
- braindecode-1.8.1.dev176771289/braindecode/modules/popt_modules.py +0 -187
- braindecode-1.8.1.dev176771289/braindecode/version.py +0 -1
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/LICENSE.txt +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/MANIFEST.in +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/README.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/__init__.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/base.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/collate.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/mne.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/tuh.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datautil/serialization.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datautil/util.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/functional/_real_dft.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/__init__.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/config.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/contrawr.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/dgcnn.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eeg_clip.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eeginception_mi.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegitnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegnex.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegsym.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/emg2qwerty.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/gcnsnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/guetschel2026.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/meta_neuromotor.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/msvtnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/sstdpn.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/summary.csv +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/syncnet.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/tcn.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/tfm_tokenizer.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/models/usleep.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/activation.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/channels.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/convolution.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/filter.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/linear.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/linear_attention.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/parametrization.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/quantization.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/stats.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/util.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/preprocessing/preprocess.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/preprocessing/windowers.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/training/__init__.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/training/losses.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/visualization/activations.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/visualization/attribution.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/visualization/metrics.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/visualization/sanity.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/visualization/topology.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/Makefile +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/agent_docs.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/cite.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/conf.py +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/help.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/index.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/install/install.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/install/install_pip.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/install/install_source.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/models.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/models_categorization.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/models_table.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/docs/user_guide/channel_strategies.rst +0 -0
- {braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/setup.cfg +0 -0
|
@@ -47,7 +47,6 @@ The following components are licensed under the MIT License:
|
|
|
47
47
|
- `braindecode/models/mirepnet.py`
|
|
48
48
|
- `braindecode/models/popt.py`
|
|
49
49
|
- `braindecode/models/tfm_tokenizer.py`
|
|
50
|
-
- `braindecode/modules/popt_modules.py`
|
|
51
50
|
- `braindecode/models/brainomni.py`
|
|
52
51
|
- `braindecode/modules/quantization.py`
|
|
53
52
|
- `braindecode/modules/linear_attention.py`
|
{braindecode-1.8.1.dev176771289/braindecode.egg-info → braindecode-1.8.1.dev176908150}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: braindecode
|
|
3
|
-
Version: 1.8.1.
|
|
3
|
+
Version: 1.8.1.dev176908150
|
|
4
4
|
Summary: Deep learning software to decode EEG, ECG or MEG signals
|
|
5
5
|
Author-email: Robin Tibor Schirrmeister <robintibor@gmail.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Alexandre Gramfort <agramfort@meta.com>
|
|
6
6
|
Maintainer-email: Alexandre Gramfort <agramfort@meta.com>, Bruno Aristimunha Pinto <b.aristimunha@gmail.com>, Robin Tibor Schirrmeister <robintibor@gmail.com>
|
|
@@ -32,8 +32,8 @@ Requires-Dist: joblib
|
|
|
32
32
|
Requires-Dist: torchinfo
|
|
33
33
|
Requires-Dist: pandas
|
|
34
34
|
Requires-Dist: wfdb>=4.3.1
|
|
35
|
-
Requires-Dist: linear_attention_transformer
|
|
36
35
|
Requires-Dist: docstring_inheritance
|
|
36
|
+
Requires-Dist: einops
|
|
37
37
|
Requires-Dist: pydantic>=2.0
|
|
38
38
|
Provides-Extra: moabb
|
|
39
39
|
Requires-Dist: moabb>=1.4.3; extra == "moabb"
|
|
@@ -50,6 +50,7 @@ Provides-Extra: tests
|
|
|
50
50
|
Requires-Dist: pytest<9.1; extra == "tests"
|
|
51
51
|
Requires-Dist: pytest-cov; extra == "tests"
|
|
52
52
|
Requires-Dist: pytest-xdist>=3.8.0; extra == "tests"
|
|
53
|
+
Requires-Dist: pytest-timeout; extra == "tests"
|
|
53
54
|
Requires-Dist: codecov; extra == "tests"
|
|
54
55
|
Requires-Dist: pytest_cases; extra == "tests"
|
|
55
56
|
Requires-Dist: mypy; extra == "tests"
|
|
@@ -14,6 +14,7 @@ from .transforms import (
|
|
|
14
14
|
FrequencyShift,
|
|
15
15
|
FTSurrogate,
|
|
16
16
|
GaussianNoise,
|
|
17
|
+
LabelSmoothing,
|
|
17
18
|
MaskEncoding,
|
|
18
19
|
Mixup,
|
|
19
20
|
SegmentationReconstruction,
|
|
@@ -40,6 +41,7 @@ __all__ = [
|
|
|
40
41
|
"CutMix",
|
|
41
42
|
"ChannelsDropout",
|
|
42
43
|
"GaussianNoise",
|
|
44
|
+
"LabelSmoothing",
|
|
43
45
|
"ChannelsSymmetry",
|
|
44
46
|
"SmoothTimeMask",
|
|
45
47
|
"BandstopFilter",
|
{braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/augmentation/base.py
RENAMED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
from numbers import Real
|
|
10
10
|
from typing import Any, Callable, Optional, Union
|
|
11
11
|
|
|
12
|
+
import numpy as np
|
|
12
13
|
import torch
|
|
13
14
|
from sklearn.utils import check_random_state
|
|
14
15
|
from torch import Tensor, nn
|
|
15
|
-
from torch.utils.data import DataLoader
|
|
16
|
+
from torch.utils.data import DataLoader, get_worker_info
|
|
16
17
|
from torch.utils.data._utils.collate import default_collate
|
|
17
18
|
|
|
18
19
|
from .functional import identity
|
|
@@ -191,6 +192,59 @@ def _as_mixed_target(y, lam_dtype):
|
|
|
191
192
|
return y, y, lam
|
|
192
193
|
|
|
193
194
|
|
|
195
|
+
def _transform_rngs(transform):
|
|
196
|
+
"""Return the ``RandomState`` objects of a transform, in a fixed order.
|
|
197
|
+
|
|
198
|
+
Walks the transform, its submodules and the ``transforms`` of a
|
|
199
|
+
:class:`Compose`, and lists each ``rng`` once (pooled transforms of
|
|
200
|
+
:class:`braindecode.augmentation.TrivialAugment` share theirs). The global
|
|
201
|
+
numpy generator, used with ``random_state=None``, is included: a spawned
|
|
202
|
+
worker receives a pickled copy of it, which torch does not reseed.
|
|
203
|
+
"""
|
|
204
|
+
rngs, seen, stack = [], set(), [transform]
|
|
205
|
+
while stack:
|
|
206
|
+
tr = stack.pop(0)
|
|
207
|
+
if id(tr) in seen:
|
|
208
|
+
continue
|
|
209
|
+
seen.add(id(tr))
|
|
210
|
+
# Compose forwards to its children without using its inherited RNG.
|
|
211
|
+
rng = None if type(tr) is Compose else getattr(tr, "rng", None)
|
|
212
|
+
if isinstance(rng, np.random.RandomState) and id(rng) not in seen:
|
|
213
|
+
seen.add(id(rng))
|
|
214
|
+
rngs.append(rng)
|
|
215
|
+
children = list(getattr(tr, "transforms", None) or [])
|
|
216
|
+
if isinstance(tr, nn.Module):
|
|
217
|
+
children += list(tr.children())
|
|
218
|
+
stack.extend(children)
|
|
219
|
+
return rngs
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def _assert_stackable(items, name):
|
|
223
|
+
# Fixed expansion concatenates the clean originals with the transformed
|
|
224
|
+
# copies, so every copy must keep the original's shape except along the
|
|
225
|
+
# batch dimension. A transform that reshapes X or y (e.g. one returning
|
|
226
|
+
# class distributions instead of class indices) would otherwise fail deep
|
|
227
|
+
# inside torch.cat with a bare dimension-mismatch RuntimeError.
|
|
228
|
+
reference = items[0]
|
|
229
|
+
for item in items[1:]:
|
|
230
|
+
pairs = (
|
|
231
|
+
zip(reference, item)
|
|
232
|
+
if isinstance(reference, (tuple, list))
|
|
233
|
+
else [(reference, item)]
|
|
234
|
+
)
|
|
235
|
+
for ref_part, part in pairs:
|
|
236
|
+
if part.dim() != ref_part.dim() or part.shape[1:] != ref_part.shape[1:]:
|
|
237
|
+
raise ValueError(
|
|
238
|
+
f"The transform returned {name} with shape "
|
|
239
|
+
f"{tuple(part.shape)} instead of {tuple(ref_part.shape)}: "
|
|
240
|
+
f"the fixed-expansion mode (n_augmentation > 0) keeps the "
|
|
241
|
+
f"clean originals and concatenates the transformed "
|
|
242
|
+
f"copies, so it cannot accommodate a transform that "
|
|
243
|
+
f"changes the shape of {name}. Use n_augmentation = 0 "
|
|
244
|
+
f"(in-place augmentation) instead."
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
194
248
|
class _AugmentationCollate:
|
|
195
249
|
"""Collate that applies a transform to each batch, with optional expansion.
|
|
196
250
|
|
|
@@ -211,15 +265,44 @@ class _AugmentationCollate:
|
|
|
211
265
|
``(1 + n_augmentation)`` times the original size. When the transform
|
|
212
266
|
mixes targets, as :class:`braindecode.augmentation.Mixup` does, ``y``
|
|
213
267
|
stays the ``(y_a, y_b, lam)`` triple and the clean originals get a
|
|
214
|
-
mixing coefficient of one.
|
|
268
|
+
mixing coefficient of one. In this mode a transform that changes the
|
|
269
|
+
shape of ``X`` or ``y`` is rejected with a clear
|
|
270
|
+
:class:`ValueError`, as its copies cannot be concatenated with the
|
|
271
|
+
clean originals.
|
|
215
272
|
"""
|
|
216
273
|
|
|
217
274
|
def __init__(self, transform, device=None, n_augmentation=0):
|
|
218
275
|
self.transform = transform
|
|
219
276
|
self.device = device
|
|
220
277
|
self.n_augmentation = n_augmentation
|
|
278
|
+
self.worker_seeds = None
|
|
279
|
+
self._worker_rngs_seeded = False
|
|
280
|
+
|
|
281
|
+
def draw_worker_seeds(self):
|
|
282
|
+
"""Draw, from each generator of the transform, a seed for the workers.
|
|
283
|
+
|
|
284
|
+
Called in the main process when a multi-process iteration starts. A
|
|
285
|
+
worker receives a copy of the transform whose generators are in the
|
|
286
|
+
state of the main process; without a new seed, every worker, and every
|
|
287
|
+
epoch, would draw the same augmentations.
|
|
288
|
+
"""
|
|
289
|
+
self.worker_seeds = [
|
|
290
|
+
int(rng.randint(2**31)) for rng in _transform_rngs(self.transform)
|
|
291
|
+
]
|
|
292
|
+
|
|
293
|
+
def _seed_worker_rngs(self):
|
|
294
|
+
if self._worker_rngs_seeded or self.worker_seeds is None:
|
|
295
|
+
return
|
|
296
|
+
worker_info = get_worker_info()
|
|
297
|
+
if worker_info is None:
|
|
298
|
+
return
|
|
299
|
+
self._worker_rngs_seeded = True
|
|
300
|
+
rngs = _transform_rngs(self.transform)
|
|
301
|
+
for rng, seed in zip(rngs, self.worker_seeds):
|
|
302
|
+
rng.seed(np.random.SeedSequence([seed, worker_info.id]).generate_state(1))
|
|
221
303
|
|
|
222
304
|
def __call__(self, batch):
|
|
305
|
+
self._seed_worker_rngs()
|
|
223
306
|
collated = default_collate(batch)
|
|
224
307
|
X, y = collated[:2]
|
|
225
308
|
if self.device is not None:
|
|
@@ -239,13 +322,16 @@ class _AugmentationCollate:
|
|
|
239
322
|
for aug_y in ys
|
|
240
323
|
if isinstance(aug_y, (tuple, list)) and len(aug_y) == 3
|
|
241
324
|
]
|
|
325
|
+
_assert_stackable(xs, "X")
|
|
242
326
|
if mixed_ys:
|
|
243
327
|
# a target-mixing transform such as Mixup returns (y_a, y_b, lam),
|
|
244
328
|
# so the parts are concatenated one by one and the untouched copies
|
|
245
329
|
# are given a mixing coefficient of one
|
|
246
330
|
lam_dtype = mixed_ys[0][2].dtype
|
|
247
331
|
ys = [_as_mixed_target(aug_y, lam_dtype) for aug_y in ys]
|
|
332
|
+
_assert_stackable(ys, "y")
|
|
248
333
|
return torch.cat(xs), tuple(torch.cat(part) for part in zip(*ys))
|
|
334
|
+
_assert_stackable(ys, "y")
|
|
249
335
|
return torch.cat(xs), torch.cat(ys)
|
|
250
336
|
|
|
251
337
|
|
|
@@ -268,7 +354,10 @@ class AugmentedDataLoader(DataLoader):
|
|
|
268
354
|
the clean originals are kept and ``n_augmentation`` independently
|
|
269
355
|
transformed copies are appended. This expresses augmentations defined as
|
|
270
356
|
a fixed set-expansion (e.g. the EEG-Inception MI 6x training set,
|
|
271
|
-
``n_augmentation=5``). In this mode batches are returned as ``(X, y)
|
|
357
|
+
``n_augmentation=5``). In this mode batches are returned as ``(X, y)``
|
|
358
|
+
and transforms that change the shape of ``X`` or ``y`` are rejected
|
|
359
|
+
with a :class:`ValueError`, as their copies cannot be concatenated
|
|
360
|
+
with the clean originals.
|
|
272
361
|
**kwargs : dict, optional
|
|
273
362
|
keyword arguments to pass to standard DataLoader class.
|
|
274
363
|
"""
|
|
@@ -301,3 +390,10 @@ class AugmentedDataLoader(DataLoader):
|
|
|
301
390
|
transform, device=device, n_augmentation=n_augmentation
|
|
302
391
|
)
|
|
303
392
|
super().__init__(dataset, collate_fn=self.collated_tr, **kwargs)
|
|
393
|
+
|
|
394
|
+
def __iter__(self):
|
|
395
|
+
# the workers get a copy of the transform; give them new seeds so that
|
|
396
|
+
# seeded transforms differ across workers and epochs
|
|
397
|
+
if self.num_workers > 0:
|
|
398
|
+
self.collated_tr.draw_worker_seeds()
|
|
399
|
+
return super().__iter__()
|
|
@@ -19,7 +19,7 @@ from mne.filter import notch_filter
|
|
|
19
19
|
from scipy.interpolate import Rbf
|
|
20
20
|
from sklearn.utils import check_random_state
|
|
21
21
|
from torch.fft import fft, ifft
|
|
22
|
-
from torch.nn.functional import pad
|
|
22
|
+
from torch.nn.functional import one_hot, pad
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def _max_float_dtype(device: torch.device | str) -> torch.dtype:
|
|
@@ -1089,10 +1089,12 @@ def mixup(
|
|
|
1089
1089
|
Online: https://arxiv.org/abs/1710.09412
|
|
1090
1090
|
.. [2] https://github.com/facebookresearch/mixup-cifar10/blob/master/train.py
|
|
1091
1091
|
"""
|
|
1092
|
-
device = X.device
|
|
1093
1092
|
batch_size, n_channels, n_times = X.shape
|
|
1094
1093
|
|
|
1095
|
-
X_mix =
|
|
1094
|
+
X_mix = X.new_zeros(
|
|
1095
|
+
(batch_size, n_channels, n_times),
|
|
1096
|
+
dtype=X.dtype if X.is_floating_point() else torch.get_default_dtype(),
|
|
1097
|
+
)
|
|
1096
1098
|
y_a = y.clone()
|
|
1097
1099
|
y_b = y[idx_perm].clone()
|
|
1098
1100
|
|
|
@@ -1150,6 +1152,97 @@ def cutmix(
|
|
|
1150
1152
|
return X_mix, (y.clone(), y[idx_perm].clone(), lam)
|
|
1151
1153
|
|
|
1152
1154
|
|
|
1155
|
+
def label_smoothing(
|
|
1156
|
+
X: torch.Tensor,
|
|
1157
|
+
y: torch.Tensor,
|
|
1158
|
+
epsilon: float,
|
|
1159
|
+
num_classes: int | None = None,
|
|
1160
|
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
|
1161
|
+
"""Smooth targets toward the uniform distribution over the classes.
|
|
1162
|
+
|
|
1163
|
+
See [1]_ for details.
|
|
1164
|
+
|
|
1165
|
+
Parameters
|
|
1166
|
+
----------
|
|
1167
|
+
X : torch.Tensor
|
|
1168
|
+
EEG data in form ``batch_size, n_channels, n_times``. Returned
|
|
1169
|
+
unchanged.
|
|
1170
|
+
y : torch.Tensor
|
|
1171
|
+
Target of length ``batch_size`` holding class indices (float values
|
|
1172
|
+
are accepted when they are integral), or a floating-point tensor of
|
|
1173
|
+
shape ``batch_size, num_classes`` holding target distributions.
|
|
1174
|
+
epsilon : float
|
|
1175
|
+
Smoothing parameter between 0 and 1: the weight of the uniform
|
|
1176
|
+
distribution mixed into the targets. ``0`` returns the unsmoothed
|
|
1177
|
+
targets.
|
|
1178
|
+
num_classes : int | None, optional
|
|
1179
|
+
Number of classes. Required when ``y`` holds class indices; when
|
|
1180
|
+
``y`` already holds distributions, it must match the size of the
|
|
1181
|
+
last dimension of ``y``. Defaults to None.
|
|
1182
|
+
|
|
1183
|
+
Returns
|
|
1184
|
+
-------
|
|
1185
|
+
tuple
|
|
1186
|
+
``X``, ``y``. Where ``X`` is unchanged and ``y`` is a
|
|
1187
|
+
floating-point tensor of shape ``batch_size, num_classes`` whose
|
|
1188
|
+
rows sum to one.
|
|
1189
|
+
|
|
1190
|
+
References
|
|
1191
|
+
----------
|
|
1192
|
+
.. [1] Christian Szegedy, Vincent Vanhoucke, Jonathon Shlens and
|
|
1193
|
+
Zbigniew Wojna (2016). Rethinking the Inception Architecture for
|
|
1194
|
+
Computer Vision. In 2016 IEEE Conference on Computer Vision and
|
|
1195
|
+
Pattern Recognition (CVPR), pp. 2818-2826.
|
|
1196
|
+
Online: https://arxiv.org/abs/1512.00567
|
|
1197
|
+
"""
|
|
1198
|
+
if not isinstance(epsilon, Real) or not 0.0 <= float(epsilon) <= 1.0:
|
|
1199
|
+
raise ValueError(
|
|
1200
|
+
f"epsilon should be a real number between 0 and 1. Got {epsilon!r}."
|
|
1201
|
+
)
|
|
1202
|
+
if num_classes is not None and (
|
|
1203
|
+
not isinstance(num_classes, int)
|
|
1204
|
+
or isinstance(num_classes, bool)
|
|
1205
|
+
or num_classes < 2
|
|
1206
|
+
):
|
|
1207
|
+
raise ValueError(
|
|
1208
|
+
f"num_classes should be an integer of at least 2. Got {num_classes!r}."
|
|
1209
|
+
)
|
|
1210
|
+
|
|
1211
|
+
if y.dim() == 1:
|
|
1212
|
+
# class-index targets: smooth their one-hot encoding
|
|
1213
|
+
if num_classes is None:
|
|
1214
|
+
raise ValueError("num_classes is required when y holds class indices.")
|
|
1215
|
+
if not torch.all(y == y.floor()):
|
|
1216
|
+
raise ValueError(
|
|
1217
|
+
"y holds non-integral values; class-index targets should be "
|
|
1218
|
+
"integers or integral floats."
|
|
1219
|
+
)
|
|
1220
|
+
if y.numel() > 0 and (y.min() < 0 or y.max() >= num_classes):
|
|
1221
|
+
raise ValueError(f"y holds class indices outside [0, {num_classes}).")
|
|
1222
|
+
one_hot_y = one_hot(y.long(), num_classes).to(dtype=X.dtype)
|
|
1223
|
+
return X, one_hot_y * (1.0 - epsilon) + epsilon / num_classes
|
|
1224
|
+
|
|
1225
|
+
if y.is_floating_point() and y.dim() >= 2:
|
|
1226
|
+
# target distributions: interpolate them toward the uniform one
|
|
1227
|
+
n_classes = y.shape[-1]
|
|
1228
|
+
if num_classes is not None and num_classes != n_classes:
|
|
1229
|
+
raise ValueError(
|
|
1230
|
+
f"num_classes ({num_classes}) does not match the size of the "
|
|
1231
|
+
f"last dimension of y ({n_classes})."
|
|
1232
|
+
)
|
|
1233
|
+
if n_classes < 2:
|
|
1234
|
+
raise ValueError(
|
|
1235
|
+
f"y should hold distributions over at least 2 classes. Got {n_classes}."
|
|
1236
|
+
)
|
|
1237
|
+
return X, y * (1.0 - epsilon) + epsilon / n_classes
|
|
1238
|
+
|
|
1239
|
+
raise ValueError(
|
|
1240
|
+
"y should hold class indices or floating-point target distributions "
|
|
1241
|
+
f"with a class dimension; got dtype {y.dtype} and shape "
|
|
1242
|
+
f"{tuple(y.shape)}."
|
|
1243
|
+
)
|
|
1244
|
+
|
|
1245
|
+
|
|
1153
1246
|
def segmentation_reconstruction(
|
|
1154
1247
|
X: torch.Tensor,
|
|
1155
1248
|
y: torch.Tensor,
|
|
@@ -30,6 +30,7 @@ from .functional import (
|
|
|
30
30
|
frequency_shift,
|
|
31
31
|
ft_surrogate,
|
|
32
32
|
gaussian_noise,
|
|
33
|
+
label_smoothing,
|
|
33
34
|
mask_encoding,
|
|
34
35
|
mixup,
|
|
35
36
|
segmentation_reconstruction,
|
|
@@ -1155,6 +1156,99 @@ class CutMix(Mixup):
|
|
|
1155
1156
|
return dict(params, cut_t_start=start, cut_t_len=end - start)
|
|
1156
1157
|
|
|
1157
1158
|
|
|
1159
|
+
class LabelSmoothing(Transform):
|
|
1160
|
+
"""Label smoothing from Szegedy et al. (2016) [1]_.
|
|
1161
|
+
|
|
1162
|
+
Replaces each target with its convex combination with the uniform
|
|
1163
|
+
distribution over the classes, penalizing over-confident predictions.
|
|
1164
|
+
The signals are returned unchanged; only the targets change.
|
|
1165
|
+
|
|
1166
|
+
The smoothed targets are floating-point distributions of shape
|
|
1167
|
+
``batch_size, num_classes`` (each row sums to one), so the training
|
|
1168
|
+
loss must accept target distributions, e.g. soft cross-entropy
|
|
1169
|
+
``-(y * torch.log_softmax(logits, dim=-1)).sum(-1).mean()`` or
|
|
1170
|
+
``torch.nn.KLDivLoss``. The transform composes before target-mixing
|
|
1171
|
+
transforms such as :class:`braindecode.augmentation.Mixup`, whose
|
|
1172
|
+
fractional-target path then mixes the smoothed distributions. The
|
|
1173
|
+
fixed-expansion mode (``n_augmentation > 0``) of
|
|
1174
|
+
:class:`braindecode.augmentation.AugmentedDataLoader` is not supported:
|
|
1175
|
+
it cannot concatenate the unsmoothed original targets with the reshaped
|
|
1176
|
+
smoothed copies and rejects the combination with a :class:`ValueError`
|
|
1177
|
+
pointing to ``n_augmentation = 0``.
|
|
1178
|
+
|
|
1179
|
+
Parameters
|
|
1180
|
+
----------
|
|
1181
|
+
epsilon : float
|
|
1182
|
+
Smoothing parameter between 0 and 1: the weight of the uniform
|
|
1183
|
+
distribution mixed into the targets. ``0`` disables smoothing.
|
|
1184
|
+
num_classes : int | None, optional
|
|
1185
|
+
Number of classes. Required when the targets are class indices;
|
|
1186
|
+
when the targets are already distributions of shape
|
|
1187
|
+
``batch_size, num_classes``, it must match their last dimension.
|
|
1188
|
+
Defaults to None.
|
|
1189
|
+
random_state : int | numpy.random.Generator, optional
|
|
1190
|
+
Seed to be used to instantiate numpy random number generator
|
|
1191
|
+
instance. The transform is deterministic, so the seed only feeds
|
|
1192
|
+
the application-probability machinery, which is inactive here.
|
|
1193
|
+
Defaults to None.
|
|
1194
|
+
|
|
1195
|
+
References
|
|
1196
|
+
----------
|
|
1197
|
+
.. [1] Christian Szegedy, Vincent Vanhoucke, Jonathon Shlens and
|
|
1198
|
+
Zbigniew Wojna (2016). Rethinking the Inception Architecture for
|
|
1199
|
+
Computer Vision. In 2016 IEEE Conference on Computer Vision and
|
|
1200
|
+
Pattern Recognition (CVPR), pp. 2818-2826.
|
|
1201
|
+
Online: https://arxiv.org/abs/1512.00567
|
|
1202
|
+
"""
|
|
1203
|
+
|
|
1204
|
+
operation = staticmethod(label_smoothing) # type: ignore[assignment]
|
|
1205
|
+
|
|
1206
|
+
def __init__(self, epsilon, num_classes=None, random_state=None):
|
|
1207
|
+
super().__init__(
|
|
1208
|
+
probability=1.0, # LabelSmoothing has to be applied to whole batches
|
|
1209
|
+
random_state=random_state,
|
|
1210
|
+
)
|
|
1211
|
+
if not isinstance(epsilon, Real) or not 0.0 <= float(epsilon) <= 1.0:
|
|
1212
|
+
raise ValueError(
|
|
1213
|
+
f"epsilon should be a real number between 0 and 1. Got {epsilon!r}."
|
|
1214
|
+
)
|
|
1215
|
+
if num_classes is not None and (
|
|
1216
|
+
not isinstance(num_classes, int)
|
|
1217
|
+
or isinstance(num_classes, bool)
|
|
1218
|
+
or num_classes < 2
|
|
1219
|
+
):
|
|
1220
|
+
raise ValueError(
|
|
1221
|
+
f"num_classes should be an integer of at least 2. Got {num_classes!r}."
|
|
1222
|
+
)
|
|
1223
|
+
self.epsilon = epsilon
|
|
1224
|
+
self.num_classes = num_classes
|
|
1225
|
+
|
|
1226
|
+
def get_augmentation_params(self, *batch):
|
|
1227
|
+
"""Return transform parameters.
|
|
1228
|
+
|
|
1229
|
+
Parameters
|
|
1230
|
+
----------
|
|
1231
|
+
X : tensor.Tensor
|
|
1232
|
+
The data.
|
|
1233
|
+
y : tensor.Tensor
|
|
1234
|
+
The labels.
|
|
1235
|
+
|
|
1236
|
+
Returns
|
|
1237
|
+
-------
|
|
1238
|
+
params : dict
|
|
1239
|
+
Contains
|
|
1240
|
+
|
|
1241
|
+
* epsilon : float
|
|
1242
|
+
Smoothing parameter between 0 and 1.
|
|
1243
|
+
* num_classes : int | None
|
|
1244
|
+
The number of classes.
|
|
1245
|
+
"""
|
|
1246
|
+
return {
|
|
1247
|
+
"epsilon": self.epsilon,
|
|
1248
|
+
"num_classes": self.num_classes,
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
|
|
1158
1252
|
class SegmentationReconstruction(Transform):
|
|
1159
1253
|
"""Segmentation Reconstruction from Lotte (2015) [Lotte2015]_.
|
|
1160
1254
|
|
|
@@ -33,7 +33,12 @@ class EEGClassifier(_EEGNeuralNet, NeuralNetClassifier):
|
|
|
33
33
|
|
|
34
34
|
cropped: bool (default=False)
|
|
35
35
|
Defines whether torch model passed to this class is cropped or not.
|
|
36
|
-
Currently used for callbacks definition.
|
|
36
|
+
Currently used for callbacks definition. For input without window
|
|
37
|
+
indices (such as numpy arrays), scoring callbacks treat each example
|
|
38
|
+
as a separate trial and average its temporal predictions. To aggregate
|
|
39
|
+
multiple windows of the same trial, pass a window dataset retaining
|
|
40
|
+
its window indices. Cross-validation splits must keep windows from
|
|
41
|
+
the same trial together.
|
|
37
42
|
|
|
38
43
|
callbacks: None or list of strings or list of Callback instances (default=None)
|
|
39
44
|
More callbacks, in addition to those returned by
|
|
@@ -224,15 +224,39 @@ class BIDSEpochsDataset(BIDSDataset):
|
|
|
224
224
|
)
|
|
225
225
|
|
|
226
226
|
def _set_metadata(self, epochs: mne.BaseEpochs) -> None:
|
|
227
|
-
# events = mne.events_from_annotations(epochs
|
|
228
227
|
n_times = epochs.times.shape[0]
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if annotations is not None:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
228
|
+
id_events = {v: k for k, v in epochs.event_id.items()}
|
|
229
|
+
target = [id_events[event_id] for event_id in epochs.events[:, -1]]
|
|
230
|
+
if epochs.annotations is not None and len(epochs.annotations) > 0:
|
|
231
|
+
# Match triggers on the original recording's sample clock, even if
|
|
232
|
+
# epochs have been cropped past time zero, decimated or resampled.
|
|
233
|
+
onset_samples = np.round(
|
|
234
|
+
epochs.annotations.onset * epochs._raw_sfreq
|
|
235
|
+
).astype(int)
|
|
236
|
+
at_zero = []
|
|
237
|
+
for sample in epochs.events[:, 0]:
|
|
238
|
+
matches = np.flatnonzero(onset_samples == sample)
|
|
239
|
+
if len(matches) == 0:
|
|
240
|
+
# FIF stores onsets as float32. Only the quantization bins
|
|
241
|
+
# containing this sample's half-sample boundaries can move
|
|
242
|
+
# a valid onset to an adjacent rounded sample on readback.
|
|
243
|
+
boundaries = np.asarray(
|
|
244
|
+
[
|
|
245
|
+
(sample - 0.5) / epochs._raw_sfreq,
|
|
246
|
+
(sample + 0.5) / epochs._raw_sfreq,
|
|
247
|
+
],
|
|
248
|
+
dtype=np.float32,
|
|
249
|
+
).astype(float)
|
|
250
|
+
matches = np.flatnonzero(
|
|
251
|
+
np.isin(epochs.annotations.onset, boundaries)
|
|
252
|
+
& (np.abs(onset_samples - sample) == 1)
|
|
253
|
+
)
|
|
254
|
+
at_zero.append(matches)
|
|
255
|
+
if all(len(matches) == 1 for matches in at_zero):
|
|
256
|
+
indices = [matches[0] for matches in at_zero]
|
|
257
|
+
# A boundary annotation cannot label two neighboring events.
|
|
258
|
+
if len(set(indices)) == len(set(epochs.events[:, 0])):
|
|
259
|
+
target = epochs.annotations.description[indices].tolist()
|
|
236
260
|
metadata_dict = {
|
|
237
261
|
"i_window_in_trial": np.zeros(len(epochs)),
|
|
238
262
|
"i_start_in_trial": np.zeros(len(epochs)),
|
{braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/chb_mit.py
RENAMED
|
@@ -16,12 +16,7 @@ It reorganizes the file structure to comply with the BIDS specification. To this
|
|
|
16
16
|
# License: BSD (3-clause)
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
-
from
|
|
20
|
-
|
|
21
|
-
from mne.datasets import fetch_dataset
|
|
22
|
-
|
|
23
|
-
from braindecode.datasets import BIDSDataset
|
|
24
|
-
from braindecode.datasets.utils import _correct_dataset_path
|
|
19
|
+
from braindecode.datasets.utils import _ZenodoBIDSDataset
|
|
25
20
|
|
|
26
21
|
CHB_MIT_URL = "https://zenodo.org/records/10259996/files/BIDS_CHB-MIT.zip"
|
|
27
22
|
CHB_MIT_archive_name = "chb_mit_bids.zip"
|
|
@@ -38,7 +33,7 @@ CHB_MIT_dataset_params = {
|
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
|
|
41
|
-
class CHBMIT(
|
|
36
|
+
class CHBMIT(_ZenodoBIDSDataset):
|
|
42
37
|
"""The Children's Hospital Boston EEG Dataset.
|
|
43
38
|
|
|
44
39
|
This database, collected at the Children's Hospital Boston, consists of EEG recordings
|
|
@@ -129,35 +124,6 @@ class CHBMIT(BIDSDataset):
|
|
|
129
124
|
.. footbibliography::
|
|
130
125
|
"""
|
|
131
126
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
path_root = fetch_dataset(
|
|
136
|
-
dataset_params=CHB_MIT_dataset_params,
|
|
137
|
-
path=None,
|
|
138
|
-
processor="unzip",
|
|
139
|
-
force_update=False,
|
|
140
|
-
)
|
|
141
|
-
# First time we fetch the dataset, we need to move the files to the
|
|
142
|
-
# correct directory.
|
|
143
|
-
path_root = _correct_dataset_path(
|
|
144
|
-
path_root, CHB_MIT_archive_name, "BIDS_CHB-MIT"
|
|
145
|
-
)
|
|
146
|
-
else:
|
|
147
|
-
# Validate that the provided root is a valid BIDS dataset
|
|
148
|
-
if not Path(f"{root}/participants.tsv").exists():
|
|
149
|
-
raise ValueError(
|
|
150
|
-
f"The provided root directory {root} does not contain a valid "
|
|
151
|
-
"BIDS dataset (missing participants.tsv). Please ensure the "
|
|
152
|
-
"root points directly to the BIDS dataset directory."
|
|
153
|
-
)
|
|
154
|
-
path_root = root
|
|
155
|
-
|
|
156
|
-
kwargs["root"] = path_root
|
|
157
|
-
|
|
158
|
-
super().__init__(
|
|
159
|
-
*args,
|
|
160
|
-
extensions=".edf",
|
|
161
|
-
check=False,
|
|
162
|
-
**kwargs,
|
|
163
|
-
)
|
|
127
|
+
_dataset_params = CHB_MIT_dataset_params
|
|
128
|
+
_archive_name = CHB_MIT_archive_name
|
|
129
|
+
_unzipped_dir = "BIDS_CHB-MIT"
|
{braindecode-1.8.1.dev176771289 → braindecode-1.8.1.dev176908150}/braindecode/datasets/siena.py
RENAMED
|
@@ -15,12 +15,7 @@ It reorganizes the file structure to comply with the BIDS specification. To this
|
|
|
15
15
|
# License: BSD (3-clause)
|
|
16
16
|
from __future__ import annotations
|
|
17
17
|
|
|
18
|
-
from
|
|
19
|
-
|
|
20
|
-
from mne.datasets import fetch_dataset
|
|
21
|
-
|
|
22
|
-
from braindecode.datasets import BIDSDataset
|
|
23
|
-
from braindecode.datasets.utils import _correct_dataset_path
|
|
18
|
+
from braindecode.datasets.utils import _ZenodoBIDSDataset
|
|
24
19
|
|
|
25
20
|
SIENA_URL = "https://zenodo.org/records/10640762/files/BIDS_Siena.zip"
|
|
26
21
|
SIENA_archive_name = "SIENA.zip"
|
|
@@ -37,7 +32,7 @@ SIENA_dataset_params = {
|
|
|
37
32
|
}
|
|
38
33
|
|
|
39
34
|
|
|
40
|
-
class SIENA(
|
|
35
|
+
class SIENA(_ZenodoBIDSDataset):
|
|
41
36
|
"""The Siena EEG Dataset.
|
|
42
37
|
|
|
43
38
|
The database consists of EEG recordings of 14 patients acquired at the Unit of Neurology
|
|
@@ -128,35 +123,6 @@ class SIENA(BIDSDataset):
|
|
|
128
123
|
automated seizure detection algorithms. Epilepsia, 66, 14-24.
|
|
129
124
|
"""
|
|
130
125
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
path_root = fetch_dataset(
|
|
135
|
-
dataset_params=SIENA_dataset_params,
|
|
136
|
-
path=None,
|
|
137
|
-
processor="unzip",
|
|
138
|
-
force_update=False,
|
|
139
|
-
)
|
|
140
|
-
# First time we fetch the dataset, we need to move the files to the
|
|
141
|
-
# correct directory.
|
|
142
|
-
path_root = _correct_dataset_path(
|
|
143
|
-
path_root, SIENA_archive_name, "BIDS_Siena"
|
|
144
|
-
)
|
|
145
|
-
else:
|
|
146
|
-
# Validate that the provided root is a valid BIDS dataset
|
|
147
|
-
if not Path(f"{root}/participants.tsv").exists():
|
|
148
|
-
raise ValueError(
|
|
149
|
-
f"The provided root directory {root} does not contain a valid "
|
|
150
|
-
"BIDS dataset (missing participants.tsv). Please ensure the "
|
|
151
|
-
"root points directly to the BIDS dataset directory."
|
|
152
|
-
)
|
|
153
|
-
path_root = root
|
|
154
|
-
|
|
155
|
-
kwargs["root"] = path_root
|
|
156
|
-
|
|
157
|
-
super().__init__(
|
|
158
|
-
*args,
|
|
159
|
-
extensions=".edf",
|
|
160
|
-
check=False,
|
|
161
|
-
**kwargs,
|
|
162
|
-
)
|
|
126
|
+
_dataset_params = SIENA_dataset_params
|
|
127
|
+
_archive_name = SIENA_archive_name
|
|
128
|
+
_unzipped_dir = "BIDS_Siena"
|
|
@@ -57,52 +57,6 @@ def ensure_metafiles_exist():
|
|
|
57
57
|
_download_if_missing(file_path, url)
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def _update_pc18_sleep_records(fname=PC18_RECORDS):
|
|
61
|
-
"""Create CSV file with information about available PC18 recordings."""
|
|
62
|
-
# Load and massage the checksums.
|
|
63
|
-
sha_train_df = pd.read_csv(
|
|
64
|
-
PC18_SHA1_TRAINING,
|
|
65
|
-
sep=" ",
|
|
66
|
-
header=None,
|
|
67
|
-
names=["sha", "fname"],
|
|
68
|
-
engine="python",
|
|
69
|
-
)
|
|
70
|
-
sha_test_df = pd.read_csv(
|
|
71
|
-
PC18_SHA1_TEST, sep=" ", header=None, names=["sha", "fname"], engine="python"
|
|
72
|
-
)
|
|
73
|
-
sha_train_df["Split"] = "training"
|
|
74
|
-
sha_test_df["Split"] = "test"
|
|
75
|
-
sha_df = pd.concat([sha_train_df, sha_test_df], axis=0, ignore_index=True)
|
|
76
|
-
select_records = (
|
|
77
|
-
sha_df.fname.str.startswith("tr") | sha_df.fname.str.startswith("te")
|
|
78
|
-
) & ~sha_df.fname.str.endswith("arousal.mat")
|
|
79
|
-
sha_df = sha_df[select_records]
|
|
80
|
-
sha_df["Record"] = sha_df["fname"].str.split("/", expand=True)[0]
|
|
81
|
-
sha_df["fname"] = sha_df[["Split", "fname"]].agg("/".join, axis=1)
|
|
82
|
-
|
|
83
|
-
# Load and massage the data.
|
|
84
|
-
data = pd.read_csv(PC18_INFO)
|
|
85
|
-
|
|
86
|
-
data = data.reset_index().rename({"index": "Subject"}, axis=1)
|
|
87
|
-
data["Sex"] = (
|
|
88
|
-
data["Sex"].map({"F": "female", "M": "male", "m": "male"}).astype("category")
|
|
89
|
-
)
|
|
90
|
-
data = sha_df.merge(data, on="Record")
|
|
91
|
-
|
|
92
|
-
data["Record type"] = (
|
|
93
|
-
data["fname"]
|
|
94
|
-
.str.split(".", expand=True)[1]
|
|
95
|
-
.map({"hea": "Header", "mat": "PSG", "arousal": "Arousal"})
|
|
96
|
-
.astype("category")
|
|
97
|
-
)
|
|
98
|
-
data = data[
|
|
99
|
-
["Subject", "Record", "Record type", "Split", "Age", "Sex", "sha", "fname"]
|
|
100
|
-
].sort_values(by="Subject")
|
|
101
|
-
|
|
102
|
-
# Save the data.
|
|
103
|
-
data.to_csv(fname, index=False)
|
|
104
|
-
|
|
105
|
-
|
|
106
60
|
def _data_path(path=None):
|
|
107
61
|
"""Get path to local copy of PC18 dataset."""
|
|
108
62
|
key = "PC18_DATASET_PATH"
|