Braindecode 1.8.1.dev182015723__tar.gz → 1.8.1.dev182197904__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.dev182015723 → braindecode-1.8.1.dev182197904}/NOTICE.txt +4 -1
- {braindecode-1.8.1.dev182015723/braindecode.egg-info → braindecode-1.8.1.dev182197904}/PKG-INFO +3 -2
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/augmentation/__init__.py +4 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/augmentation/base.py +106 -4
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/augmentation/functional.py +187 -15
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/augmentation/transforms.py +157 -3
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/classifier.py +6 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/base.py +236 -12
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/bids/datasets.py +32 -8
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/chb_mit.py +5 -39
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/mne.py +5 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/siena.py +5 -39
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/sleep_physio_challe_18.py +0 -46
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/tuh.py +22 -14
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/utils.py +37 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datautil/serialization.py +21 -10
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datautil/util.py +3 -2
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/eegneuralnet.py +30 -9
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/functional/__init__.py +19 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/functional/_real_dft.py +55 -0
- braindecode-1.8.1.dev182197904/braindecode/functional/attention.py +152 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/functional/functions.py +153 -19
- braindecode-1.8.1.dev182197904/braindecode/functional/initialization.py +139 -0
- braindecode-1.8.1.dev182197904/braindecode/functional/patches.py +105 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/__init__.py +8 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/atcnet.py +21 -22
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/attn_sleep.py +13 -19
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/axon.py +63 -15
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/barista.py +48 -35
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/base.py +117 -15
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/bendr.py +20 -12
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/biot.py +17 -60
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/brainbert.py +49 -17
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/brainmodule.py +13 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/brainomni.py +37 -20
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/brant.py +24 -12
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/cbramod.py +12 -11
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/codebrain.py +132 -19
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/contrawr.py +23 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/csbrain.py +105 -49
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/ctnet.py +52 -173
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/dance.py +6 -11
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/deep4.py +16 -3
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/dgcnn.py +7 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/diver1.py +61 -66
- braindecode-1.8.1.dev182197904/braindecode/models/duin.py +463 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eeg_clip.py +71 -9
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegconformer.py +39 -90
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegdino.py +18 -68
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eeginception_erp.py +4 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eeginception_mi.py +7 -3
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegminer.py +4 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegnet.py +4 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegnex.py +20 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegpt.py +34 -348
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegsym.py +85 -17
- braindecode-1.8.1.dev182197904/braindecode/models/epint.py +331 -0
- braindecode-1.8.1.dev182197904/braindecode/models/gcnsnet.py +338 -0
- braindecode-1.8.1.dev182197904/braindecode/models/guetschel2026.py +775 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/ifnet.py +20 -24
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/labram.py +51 -47
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/luna.py +64 -134
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/mapa.py +50 -28
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/medformer.py +95 -84
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/meta_neuromotor.py +57 -32
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/mirepnet.py +42 -92
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/mscformer.py +63 -190
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/msvtnet.py +123 -6
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/mvpformer.py +64 -66
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/neuropose.py +18 -18
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/neurorvq.py +161 -100
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/neurorvq_tokenizer.py +120 -70
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/patchedtransformer.py +38 -28
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/popt.py +169 -4
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/reve.py +129 -33
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/sensingdynamics.py +18 -19
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/shallow_fbcsp.py +6 -2
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/signal_jepa.py +106 -11
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/sinc_shallow.py +17 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/sleep_stager_blanco_2020.py +13 -6
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/sleepfm.py +63 -13
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/sparcnet.py +14 -10
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/steegformer.py +34 -39
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/summary.csv +4 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/tcformer.py +37 -37
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/tcn.py +5 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/tfm_tokenizer.py +44 -3
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/tidnet.py +30 -4
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/tmsanet.py +20 -9
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/usleep.py +3 -2
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/util.py +177 -173
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/vemg2pose.py +20 -22
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/zuna.py +201 -31
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/__init__.py +20 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/attention.py +169 -27
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/blocks.py +52 -7
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/channels.py +77 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/dance_modules.py +25 -11
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/filter.py +79 -44
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/layers.py +274 -3
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/quantization.py +17 -13
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/preprocessing/eegprep_preprocess.py +6 -3
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/preprocessing/mne_preprocess.py +79 -4
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/preprocessing/preprocess.py +30 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/preprocessing/windowers.py +33 -21
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/regressor.py +6 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/samplers/base.py +100 -80
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/training/losses.py +5 -4
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/training/scoring.py +33 -18
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/util.py +13 -9
- braindecode-1.8.1.dev182197904/braindecode/version.py +1 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/visualization/frequency.py +11 -7
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904/braindecode.egg-info}/PKG-INFO +3 -2
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode.egg-info/SOURCES.txt +6 -2
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode.egg-info/requires.txt +2 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/api.rst +36 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/user_guide/channel_strategies.rst +1 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/whats_new.rst +295 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/pyproject.toml +8 -2
- braindecode-1.8.1.dev182015723/braindecode/datasets/bids/format.py +0 -717
- braindecode-1.8.1.dev182015723/braindecode/functional/initialization.py +0 -47
- braindecode-1.8.1.dev182015723/braindecode/modules/popt_modules.py +0 -187
- braindecode-1.8.1.dev182015723/braindecode/version.py +0 -1
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/LICENSE.txt +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/MANIFEST.in +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/README.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/__init__.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/collate.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/config.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegitnet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/emg2qwerty.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/sstdpn.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/syncnet.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/activation.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/convolution.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/linear.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/linear_attention.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/parametrization.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/stats.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/util.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/training/__init__.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/visualization/activations.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/visualization/attribution.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/visualization/metrics.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/visualization/sanity.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode/visualization/topology.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/Makefile +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/agent_docs.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/cite.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/conf.py +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/help.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/index.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/install/install.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/install/install_pip.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/install/install_source.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/models.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/models_categorization.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/models_table.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/setup.cfg +0 -0
|
@@ -40,19 +40,22 @@ The following components are licensed under the MIT License:
|
|
|
40
40
|
|
|
41
41
|
- `braindecode/models/ctnet.py`
|
|
42
42
|
- `braindecode/models/dance.py`
|
|
43
|
+
- `braindecode/models/duin.py`
|
|
43
44
|
- `braindecode/models/medformer.py`
|
|
44
45
|
- `braindecode/models/tcformer.py`
|
|
45
46
|
- `braindecode/models/ifnet.py`
|
|
46
47
|
- `braindecode/models/mirepnet.py`
|
|
47
48
|
- `braindecode/models/popt.py`
|
|
48
49
|
- `braindecode/models/tfm_tokenizer.py`
|
|
49
|
-
- `braindecode/modules/popt_modules.py`
|
|
50
50
|
- `braindecode/models/brainomni.py`
|
|
51
51
|
- `braindecode/modules/quantization.py`
|
|
52
52
|
- `braindecode/modules/linear_attention.py`
|
|
53
53
|
- `braindecode/models/seizure_transformer.py`
|
|
54
54
|
- `docs/_static/model/seizure_transformer_arch.png`
|
|
55
|
+
- `braindecode/models/guetschel2026.py`
|
|
55
56
|
- `braindecode/models/tmsanet.py`
|
|
57
|
+
- `braindecode/models/epint.py`
|
|
58
|
+
- `braindecode/models/gcnsnet.py`
|
|
56
59
|
|
|
57
60
|
The `brainomni.py` file is a derivative of `OpenTSLab/BrainOmni` (MIT), whose
|
|
58
61
|
SEANet codec derives from Meta's `facebookresearch/encodec` (MIT). The
|
{braindecode-1.8.1.dev182015723/braindecode.egg-info → braindecode-1.8.1.dev182197904}/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.dev182197904
|
|
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"
|
|
@@ -10,9 +10,11 @@ from .transforms import (
|
|
|
10
10
|
ChannelsReref,
|
|
11
11
|
ChannelsShuffle,
|
|
12
12
|
ChannelsSymmetry,
|
|
13
|
+
CutMix,
|
|
13
14
|
FrequencyShift,
|
|
14
15
|
FTSurrogate,
|
|
15
16
|
GaussianNoise,
|
|
17
|
+
LabelSmoothing,
|
|
16
18
|
MaskEncoding,
|
|
17
19
|
Mixup,
|
|
18
20
|
SegmentationReconstruction,
|
|
@@ -36,8 +38,10 @@ __all__ = [
|
|
|
36
38
|
"SignFlip",
|
|
37
39
|
"FTSurrogate",
|
|
38
40
|
"ChannelsShuffle",
|
|
41
|
+
"CutMix",
|
|
39
42
|
"ChannelsDropout",
|
|
40
43
|
"GaussianNoise",
|
|
44
|
+
"LabelSmoothing",
|
|
41
45
|
"ChannelsSymmetry",
|
|
42
46
|
"SmoothTimeMask",
|
|
43
47
|
"BandstopFilter",
|
{braindecode-1.8.1.dev182015723 → braindecode-1.8.1.dev182197904}/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
|
|
@@ -171,7 +172,13 @@ class Compose(Transform):
|
|
|
171
172
|
self.transforms = transforms
|
|
172
173
|
super().__init__()
|
|
173
174
|
|
|
174
|
-
def forward(self, X, y):
|
|
175
|
+
def forward(self, X, y=None):
|
|
176
|
+
# like Transform.forward, return only X when no target is given (each
|
|
177
|
+
# transform then returns a single tensor, not an (X, y) pair)
|
|
178
|
+
if y is None:
|
|
179
|
+
for transform in self.transforms:
|
|
180
|
+
X = transform(X)
|
|
181
|
+
return X
|
|
175
182
|
for transform in self.transforms:
|
|
176
183
|
X, y = transform(X, y)
|
|
177
184
|
return X, y
|
|
@@ -185,6 +192,59 @@ def _as_mixed_target(y, lam_dtype):
|
|
|
185
192
|
return y, y, lam
|
|
186
193
|
|
|
187
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
|
+
|
|
188
248
|
class _AugmentationCollate:
|
|
189
249
|
"""Collate that applies a transform to each batch, with optional expansion.
|
|
190
250
|
|
|
@@ -205,15 +265,44 @@ class _AugmentationCollate:
|
|
|
205
265
|
``(1 + n_augmentation)`` times the original size. When the transform
|
|
206
266
|
mixes targets, as :class:`braindecode.augmentation.Mixup` does, ``y``
|
|
207
267
|
stays the ``(y_a, y_b, lam)`` triple and the clean originals get a
|
|
208
|
-
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.
|
|
209
272
|
"""
|
|
210
273
|
|
|
211
274
|
def __init__(self, transform, device=None, n_augmentation=0):
|
|
212
275
|
self.transform = transform
|
|
213
276
|
self.device = device
|
|
214
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))
|
|
215
303
|
|
|
216
304
|
def __call__(self, batch):
|
|
305
|
+
self._seed_worker_rngs()
|
|
217
306
|
collated = default_collate(batch)
|
|
218
307
|
X, y = collated[:2]
|
|
219
308
|
if self.device is not None:
|
|
@@ -233,13 +322,16 @@ class _AugmentationCollate:
|
|
|
233
322
|
for aug_y in ys
|
|
234
323
|
if isinstance(aug_y, (tuple, list)) and len(aug_y) == 3
|
|
235
324
|
]
|
|
325
|
+
_assert_stackable(xs, "X")
|
|
236
326
|
if mixed_ys:
|
|
237
327
|
# a target-mixing transform such as Mixup returns (y_a, y_b, lam),
|
|
238
328
|
# so the parts are concatenated one by one and the untouched copies
|
|
239
329
|
# are given a mixing coefficient of one
|
|
240
330
|
lam_dtype = mixed_ys[0][2].dtype
|
|
241
331
|
ys = [_as_mixed_target(aug_y, lam_dtype) for aug_y in ys]
|
|
332
|
+
_assert_stackable(ys, "y")
|
|
242
333
|
return torch.cat(xs), tuple(torch.cat(part) for part in zip(*ys))
|
|
334
|
+
_assert_stackable(ys, "y")
|
|
243
335
|
return torch.cat(xs), torch.cat(ys)
|
|
244
336
|
|
|
245
337
|
|
|
@@ -262,7 +354,10 @@ class AugmentedDataLoader(DataLoader):
|
|
|
262
354
|
the clean originals are kept and ``n_augmentation`` independently
|
|
263
355
|
transformed copies are appended. This expresses augmentations defined as
|
|
264
356
|
a fixed set-expansion (e.g. the EEG-Inception MI 6x training set,
|
|
265
|
-
``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.
|
|
266
361
|
**kwargs : dict, optional
|
|
267
362
|
keyword arguments to pass to standard DataLoader class.
|
|
268
363
|
"""
|
|
@@ -295,3 +390,10 @@ class AugmentedDataLoader(DataLoader):
|
|
|
295
390
|
transform, device=device, n_augmentation=n_augmentation
|
|
296
391
|
)
|
|
297
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__()
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# Gustavo Rodrigues <gustavenrique01@gmail.com>
|
|
4
4
|
# Bruna Lopes <brunajaflopes@gmail.com>
|
|
5
5
|
# Sarthak Tayal <sarthaktayal2@gmail.com>
|
|
6
|
+
# Anton Soloviev <anton@praviel.com>
|
|
6
7
|
#
|
|
7
8
|
# License: BSD (3-clause)
|
|
8
9
|
|
|
@@ -18,7 +19,22 @@ from mne.filter import notch_filter
|
|
|
18
19
|
from scipy.interpolate import Rbf
|
|
19
20
|
from sklearn.utils import check_random_state
|
|
20
21
|
from torch.fft import fft, ifft
|
|
21
|
-
from torch.nn.functional import pad
|
|
22
|
+
from torch.nn.functional import one_hot, pad
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _max_float_dtype(device: torch.device | str) -> torch.dtype:
|
|
26
|
+
"""float64, or float32 on Apple MPS, which has no float64."""
|
|
27
|
+
return torch.float32 if torch.device(device).type == "mps" else torch.float64
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _to_device(t: torch.Tensor, device: torch.device | str) -> torch.Tensor:
|
|
31
|
+
"""Move ``t`` to ``device``, in single precision on MPS (no float64 there)."""
|
|
32
|
+
if torch.device(device).type == "mps":
|
|
33
|
+
if t.dtype == torch.float64:
|
|
34
|
+
return t.float().to(device)
|
|
35
|
+
if t.dtype == torch.complex128:
|
|
36
|
+
return t.to(torch.complex64).to(device)
|
|
37
|
+
return t.to(device)
|
|
22
38
|
|
|
23
39
|
|
|
24
40
|
def identity(X: torch.Tensor, y: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
|
|
@@ -91,10 +107,11 @@ def _new_random_fft_phase_odd(
|
|
|
91
107
|
rng = check_random_state(random_state)
|
|
92
108
|
random_phase = torch.from_numpy(
|
|
93
109
|
2j * np.pi * rng.random((batch_size, c, (n - 1) // 2))
|
|
94
|
-
)
|
|
110
|
+
)
|
|
111
|
+
random_phase = _to_device(random_phase, device)
|
|
95
112
|
return torch.cat(
|
|
96
113
|
[
|
|
97
|
-
torch.zeros((batch_size, c, 1), device=device),
|
|
114
|
+
torch.zeros((batch_size, c, 1), device=device, dtype=random_phase.dtype),
|
|
98
115
|
random_phase,
|
|
99
116
|
-torch.flip(random_phase, [-1]),
|
|
100
117
|
],
|
|
@@ -112,12 +129,13 @@ def _new_random_fft_phase_even(
|
|
|
112
129
|
rng = check_random_state(random_state)
|
|
113
130
|
random_phase = torch.from_numpy(
|
|
114
131
|
2j * np.pi * rng.random((batch_size, c, n // 2 - 1))
|
|
115
|
-
)
|
|
132
|
+
)
|
|
133
|
+
random_phase = _to_device(random_phase, device)
|
|
116
134
|
return torch.cat(
|
|
117
135
|
[
|
|
118
|
-
torch.zeros((batch_size, c, 1), device=device),
|
|
136
|
+
torch.zeros((batch_size, c, 1), device=device, dtype=random_phase.dtype),
|
|
119
137
|
random_phase,
|
|
120
|
-
torch.zeros((batch_size, c, 1), device=device),
|
|
138
|
+
torch.zeros((batch_size, c, 1), device=device, dtype=random_phase.dtype),
|
|
121
139
|
-torch.flip(random_phase, [-1]),
|
|
122
140
|
],
|
|
123
141
|
dim=-1,
|
|
@@ -177,7 +195,7 @@ def ft_surrogate(
|
|
|
177
195
|
and 0 <= phase_noise_magnitude <= 1
|
|
178
196
|
), f"eps must be a float between 0 and 1. Got {phase_noise_magnitude}."
|
|
179
197
|
|
|
180
|
-
f = fft(X.
|
|
198
|
+
f = fft(X.to(_max_float_dtype(X.device)), dim=-1)
|
|
181
199
|
device = X.device
|
|
182
200
|
|
|
183
201
|
n = f.shape[-1]
|
|
@@ -579,6 +597,7 @@ def _frequency_shift(X: torch.Tensor, fs: float, f_shift: float) -> torch.Tensor
|
|
|
579
597
|
_f_shift = torch.as_tensor(f_shift).float()
|
|
580
598
|
else:
|
|
581
599
|
raise ValueError(f"Invalid f_shift type: {type(f_shift)}")
|
|
600
|
+
_f_shift = _f_shift.to(X.device)
|
|
582
601
|
f_shift_stack = _f_shift.repeat(N_padded, n_channels, 1)
|
|
583
602
|
reshaped_f_shift = f_shift_stack.permute(
|
|
584
603
|
*torch.arange(f_shift_stack.ndim - 1, -1, -1)
|
|
@@ -910,7 +929,15 @@ def _rotate_signals(
|
|
|
910
929
|
sensors_positions_matrix: torch.Tensor,
|
|
911
930
|
spherical: bool = True,
|
|
912
931
|
) -> torch.Tensor:
|
|
913
|
-
|
|
932
|
+
if X.device.type == "mps":
|
|
933
|
+
# MPS has no float64: compute the small (n_chans x n_chans) spherical
|
|
934
|
+
# spline matrices on CPU in double precision, only move the result
|
|
935
|
+
# (two separate steps: a combined device + dtype .to() from MPS
|
|
936
|
+
# returns zeros with some torch versions)
|
|
937
|
+
sensors_positions_matrix = sensors_positions_matrix.cpu().double()
|
|
938
|
+
rotations = [rotation.cpu().double() for rotation in rotations]
|
|
939
|
+
else:
|
|
940
|
+
sensors_positions_matrix = sensors_positions_matrix.to(X.device)
|
|
914
941
|
rot_sensors_matrices = [
|
|
915
942
|
rotation.matmul(sensors_positions_matrix) for rotation in rotations
|
|
916
943
|
]
|
|
@@ -920,9 +947,10 @@ def _rotate_signals(
|
|
|
920
947
|
torch.as_tensor(
|
|
921
948
|
_torch_make_interpolation_matrix(
|
|
922
949
|
sensors_positions_matrix.T, rot_sensors_matrix.T
|
|
923
|
-
)
|
|
924
|
-
|
|
925
|
-
|
|
950
|
+
)
|
|
951
|
+
)
|
|
952
|
+
.float()
|
|
953
|
+
.to(X.device)
|
|
926
954
|
for rot_sensors_matrix in rot_sensors_matrices
|
|
927
955
|
]
|
|
928
956
|
)
|
|
@@ -931,7 +959,7 @@ def _rotate_signals(
|
|
|
931
959
|
transformed_X = X.clone()
|
|
932
960
|
sensors_positions = list(sensors_positions_matrix)
|
|
933
961
|
for s, rot_sensors_matrix in enumerate(rot_sensors_matrices):
|
|
934
|
-
rot_sensors_positions = list(rot_sensors_matrix
|
|
962
|
+
rot_sensors_positions = list(rot_sensors_matrix)
|
|
935
963
|
for time in range(X.shape[-1]):
|
|
936
964
|
interpolator_t = Rbf(*sensors_positions, X[s, :, time])
|
|
937
965
|
transformed_X[s, :, time] = torch.from_numpy(
|
|
@@ -1061,10 +1089,12 @@ def mixup(
|
|
|
1061
1089
|
Online: https://arxiv.org/abs/1710.09412
|
|
1062
1090
|
.. [2] https://github.com/facebookresearch/mixup-cifar10/blob/master/train.py
|
|
1063
1091
|
"""
|
|
1064
|
-
device = X.device
|
|
1065
1092
|
batch_size, n_channels, n_times = X.shape
|
|
1066
1093
|
|
|
1067
|
-
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
|
+
)
|
|
1068
1098
|
y_a = y.clone()
|
|
1069
1099
|
y_b = y[idx_perm].clone()
|
|
1070
1100
|
|
|
@@ -1074,6 +1104,145 @@ def mixup(
|
|
|
1074
1104
|
return X_mix, (y_a, y_b, lam)
|
|
1075
1105
|
|
|
1076
1106
|
|
|
1107
|
+
def cutmix(
|
|
1108
|
+
X: torch.Tensor,
|
|
1109
|
+
y: torch.Tensor,
|
|
1110
|
+
idx_perm: torch.Tensor,
|
|
1111
|
+
cut_t_start: torch.Tensor,
|
|
1112
|
+
cut_t_len: torch.Tensor,
|
|
1113
|
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
|
1114
|
+
"""Paste a time region of shuffled examples into the original examples.
|
|
1115
|
+
|
|
1116
|
+
See [1]_ for details.
|
|
1117
|
+
|
|
1118
|
+
Parameters
|
|
1119
|
+
----------
|
|
1120
|
+
X : torch.Tensor
|
|
1121
|
+
EEG data in form ``batch_size, n_channels, n_times``
|
|
1122
|
+
y : torch.Tensor
|
|
1123
|
+
Target of length ``batch_size``
|
|
1124
|
+
idx_perm : torch.Tensor
|
|
1125
|
+
Permuted indices of example that are mixed into original examples.
|
|
1126
|
+
cut_t_start : torch.Tensor
|
|
1127
|
+
Start index of the pasted time region for each example.
|
|
1128
|
+
cut_t_len : torch.Tensor
|
|
1129
|
+
Length of the pasted time region for each example.
|
|
1130
|
+
|
|
1131
|
+
Returns
|
|
1132
|
+
-------
|
|
1133
|
+
tuple
|
|
1134
|
+
``X``, ``y``. Where ``X`` is augmented and ``y`` is a tuple of length
|
|
1135
|
+
3 containing the labels of the two mixed examples and the fraction of
|
|
1136
|
+
each example kept from the original, ``1 - cut_t_len / n_times``.
|
|
1137
|
+
|
|
1138
|
+
References
|
|
1139
|
+
----------
|
|
1140
|
+
.. [1] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun,
|
|
1141
|
+
Junsuk Choe, Youngjoon Yoo (2019). CutMix: Regularization Strategy
|
|
1142
|
+
to Train Strong Classifiers with Localizable Features. In 2019
|
|
1143
|
+
IEEE/CVF International Conference on Computer Vision (ICCV)
|
|
1144
|
+
Online: https://arxiv.org/abs/1905.04899
|
|
1145
|
+
"""
|
|
1146
|
+
n_times = X.shape[-1]
|
|
1147
|
+
t = torch.arange(n_times, device=X.device)
|
|
1148
|
+
start = cut_t_start[:, None]
|
|
1149
|
+
in_cut = (t >= start) & (t < start + cut_t_len[:, None])
|
|
1150
|
+
X_mix = torch.where(in_cut[:, None], X[idx_perm], X)
|
|
1151
|
+
lam = (n_times - cut_t_len).to(X.dtype) / n_times
|
|
1152
|
+
return X_mix, (y.clone(), y[idx_perm].clone(), lam)
|
|
1153
|
+
|
|
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
|
+
|
|
1077
1246
|
def segmentation_reconstruction(
|
|
1078
1247
|
X: torch.Tensor,
|
|
1079
1248
|
y: torch.Tensor,
|
|
@@ -1093,7 +1262,8 @@ def segmentation_reconstruction(
|
|
|
1093
1262
|
y : torch.Tensor
|
|
1094
1263
|
EEG labels for the example or batch.
|
|
1095
1264
|
n_segments : int
|
|
1096
|
-
Number of segments to use in the batch.
|
|
1265
|
+
Number of segments to use in the batch. Any remaining samples are
|
|
1266
|
+
included in the last segment.
|
|
1097
1267
|
data_classes : list[tuple[int, torch.Tensor]]
|
|
1098
1268
|
List of tuples. Each tuple contains the class index and the corresponding EEG data.
|
|
1099
1269
|
rand_indices : array-like
|
|
@@ -1133,6 +1303,8 @@ def segmentation_reconstruction(
|
|
|
1133
1303
|
for idx_segment in range(n_segments):
|
|
1134
1304
|
start = idx_segment * segment_size
|
|
1135
1305
|
end = (idx_segment + 1) * segment_size
|
|
1306
|
+
if idx_segment == n_segments - 1:
|
|
1307
|
+
end = window_size
|
|
1136
1308
|
|
|
1137
1309
|
# Perform the data augmentation
|
|
1138
1310
|
X_aug[np.arange(n_trials), :, start:end] = X_class[
|