braindecode 1.8.1.dev169440825__tar.gz → 1.8.1.dev169484576__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.dev169440825 → braindecode-1.8.1.dev169484576}/NOTICE.txt +2 -1
- {braindecode-1.8.1.dev169440825/braindecode.egg-info → braindecode-1.8.1.dev169484576}/PKG-INFO +2 -2
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/augmentation/__init__.py +4 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/augmentation/base.py +7 -1
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/augmentation/functional.py +181 -13
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/augmentation/transforms.py +156 -3
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/base.py +72 -4
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/chb_mit.py +5 -39
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/mne.py +5 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/siena.py +5 -39
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/sleep_physio_challe_18.py +0 -46
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/tuh.py +2 -1
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/utils.py +37 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datautil/serialization.py +11 -4
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/eegneuralnet.py +6 -1
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/functional/__init__.py +16 -1
- braindecode-1.8.1.dev169484576/braindecode/functional/attention.py +152 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/functional/functions.py +106 -1
- braindecode-1.8.1.dev169484576/braindecode/functional/initialization.py +139 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/__init__.py +4 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/atcnet.py +21 -22
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/attn_sleep.py +9 -13
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/axon.py +6 -1
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/barista.py +45 -33
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/base.py +83 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/bendr.py +20 -12
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/biot.py +4 -2
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/brainbert.py +47 -16
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/brainomni.py +23 -16
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/brant.py +18 -7
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/cbramod.py +12 -11
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/codebrain.py +90 -15
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/csbrain.py +36 -17
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/ctnet.py +12 -33
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/dance.py +6 -11
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/deep4.py +6 -2
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/diver1.py +11 -8
- braindecode-1.8.1.dev169484576/braindecode/models/duin.py +459 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eeg_clip.py +71 -9
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegconformer.py +3 -15
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegdino.py +13 -6
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eeginception_erp.py +4 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegminer.py +4 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegnet.py +4 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegpt.py +25 -149
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/epint.py +30 -10
- braindecode-1.8.1.dev169484576/braindecode/models/gcnsnet.py +338 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/guetschel2026.py +8 -8
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/ifnet.py +20 -24
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/labram.py +17 -32
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/luna.py +29 -73
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/mapa.py +42 -26
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/medformer.py +24 -39
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/mirepnet.py +3 -12
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/mscformer.py +24 -32
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/mvpformer.py +18 -10
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/neuropose.py +18 -18
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/neurorvq.py +107 -39
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/neurorvq_tokenizer.py +60 -14
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/patchedtransformer.py +36 -20
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/popt.py +169 -4
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/reve.py +111 -39
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/sensingdynamics.py +18 -19
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/shallow_fbcsp.py +6 -2
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/signal_jepa.py +18 -7
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/sinc_shallow.py +17 -1
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/sleepfm.py +62 -12
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/sparcnet.py +14 -10
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/steegformer.py +34 -39
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/summary.csv +2 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/tcformer.py +37 -37
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/tidnet.py +13 -4
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/tmsanet.py +20 -9
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/util.py +29 -149
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/vemg2pose.py +20 -22
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/zuna.py +77 -26
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/__init__.py +8 -1
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/attention.py +70 -105
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/blocks.py +111 -7
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/channels.py +77 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/layers.py +47 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/quantization.py +5 -5
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/preprocessing/eegprep_preprocess.py +6 -3
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/preprocessing/preprocess.py +19 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/preprocessing/windowers.py +28 -17
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/regressor.py +6 -1
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/samplers/base.py +73 -63
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/training/losses.py +5 -4
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/training/scoring.py +4 -1
- braindecode-1.8.1.dev169484576/braindecode/version.py +1 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576/braindecode.egg-info}/PKG-INFO +2 -2
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode.egg-info/SOURCES.txt +3 -2
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode.egg-info/requires.txt +1 -1
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/api.rst +24 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/whats_new.rst +143 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/pyproject.toml +2 -2
- braindecode-1.8.1.dev169440825/braindecode/datasets/bids/format.py +0 -717
- braindecode-1.8.1.dev169440825/braindecode/functional/initialization.py +0 -47
- braindecode-1.8.1.dev169440825/braindecode/modules/popt_modules.py +0 -187
- braindecode-1.8.1.dev169440825/braindecode/version.py +0 -1
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/LICENSE.txt +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/MANIFEST.in +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/README.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/__init__.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/classifier.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/collate.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datautil/util.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/functional/_real_dft.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/brainmodule.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/config.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/contrawr.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/dgcnn.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eeginception_mi.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegitnet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegnex.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegsym.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/emg2qwerty.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/meta_neuromotor.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/msvtnet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/sstdpn.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/syncnet.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/tcn.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/tfm_tokenizer.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/models/usleep.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/activation.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/convolution.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/dance_modules.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/filter.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/linear.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/linear_attention.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/parametrization.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/stats.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/util.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/training/__init__.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/util.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/visualization/activations.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/visualization/attribution.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/visualization/frequency.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/visualization/metrics.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/visualization/sanity.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/visualization/topology.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/Makefile +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/agent_docs.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/cite.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/conf.py +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/help.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/index.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/install/install.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/install/install_pip.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/install/install_source.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/models.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/models_categorization.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/models_table.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/docs/user_guide/channel_strategies.rst +0 -0
- {braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/setup.cfg +0 -0
|
@@ -40,13 +40,13 @@ 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`
|
|
@@ -55,6 +55,7 @@ The following components are licensed under the MIT License:
|
|
|
55
55
|
- `braindecode/models/guetschel2026.py`
|
|
56
56
|
- `braindecode/models/tmsanet.py`
|
|
57
57
|
- `braindecode/models/epint.py`
|
|
58
|
+
- `braindecode/models/gcnsnet.py`
|
|
58
59
|
|
|
59
60
|
The `brainomni.py` file is a derivative of `OpenTSLab/BrainOmni` (MIT), whose
|
|
60
61
|
SEANet codec derives from Meta's `facebookresearch/encodec` (MIT). The
|
{braindecode-1.8.1.dev169440825/braindecode.egg-info → braindecode-1.8.1.dev169484576}/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.dev169484576
|
|
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"
|
|
@@ -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.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/augmentation/base.py
RENAMED
|
@@ -171,7 +171,13 @@ class Compose(Transform):
|
|
|
171
171
|
self.transforms = transforms
|
|
172
172
|
super().__init__()
|
|
173
173
|
|
|
174
|
-
def forward(self, X, y):
|
|
174
|
+
def forward(self, X, y=None):
|
|
175
|
+
# like Transform.forward, return only X when no target is given (each
|
|
176
|
+
# transform then returns a single tensor, not an (X, y) pair)
|
|
177
|
+
if y is None:
|
|
178
|
+
for transform in self.transforms:
|
|
179
|
+
X = transform(X)
|
|
180
|
+
return X
|
|
175
181
|
for transform in self.transforms:
|
|
176
182
|
X, y = transform(X, y)
|
|
177
183
|
return X, y
|
|
@@ -19,7 +19,22 @@ 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
|
+
|
|
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)
|
|
23
38
|
|
|
24
39
|
|
|
25
40
|
def identity(X: torch.Tensor, y: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
|
|
@@ -92,10 +107,11 @@ def _new_random_fft_phase_odd(
|
|
|
92
107
|
rng = check_random_state(random_state)
|
|
93
108
|
random_phase = torch.from_numpy(
|
|
94
109
|
2j * np.pi * rng.random((batch_size, c, (n - 1) // 2))
|
|
95
|
-
)
|
|
110
|
+
)
|
|
111
|
+
random_phase = _to_device(random_phase, device)
|
|
96
112
|
return torch.cat(
|
|
97
113
|
[
|
|
98
|
-
torch.zeros((batch_size, c, 1), device=device),
|
|
114
|
+
torch.zeros((batch_size, c, 1), device=device, dtype=random_phase.dtype),
|
|
99
115
|
random_phase,
|
|
100
116
|
-torch.flip(random_phase, [-1]),
|
|
101
117
|
],
|
|
@@ -113,12 +129,13 @@ def _new_random_fft_phase_even(
|
|
|
113
129
|
rng = check_random_state(random_state)
|
|
114
130
|
random_phase = torch.from_numpy(
|
|
115
131
|
2j * np.pi * rng.random((batch_size, c, n // 2 - 1))
|
|
116
|
-
)
|
|
132
|
+
)
|
|
133
|
+
random_phase = _to_device(random_phase, device)
|
|
117
134
|
return torch.cat(
|
|
118
135
|
[
|
|
119
|
-
torch.zeros((batch_size, c, 1), device=device),
|
|
136
|
+
torch.zeros((batch_size, c, 1), device=device, dtype=random_phase.dtype),
|
|
120
137
|
random_phase,
|
|
121
|
-
torch.zeros((batch_size, c, 1), device=device),
|
|
138
|
+
torch.zeros((batch_size, c, 1), device=device, dtype=random_phase.dtype),
|
|
122
139
|
-torch.flip(random_phase, [-1]),
|
|
123
140
|
],
|
|
124
141
|
dim=-1,
|
|
@@ -178,7 +195,7 @@ def ft_surrogate(
|
|
|
178
195
|
and 0 <= phase_noise_magnitude <= 1
|
|
179
196
|
), f"eps must be a float between 0 and 1. Got {phase_noise_magnitude}."
|
|
180
197
|
|
|
181
|
-
f = fft(X.
|
|
198
|
+
f = fft(X.to(_max_float_dtype(X.device)), dim=-1)
|
|
182
199
|
device = X.device
|
|
183
200
|
|
|
184
201
|
n = f.shape[-1]
|
|
@@ -580,6 +597,7 @@ def _frequency_shift(X: torch.Tensor, fs: float, f_shift: float) -> torch.Tensor
|
|
|
580
597
|
_f_shift = torch.as_tensor(f_shift).float()
|
|
581
598
|
else:
|
|
582
599
|
raise ValueError(f"Invalid f_shift type: {type(f_shift)}")
|
|
600
|
+
_f_shift = _f_shift.to(X.device)
|
|
583
601
|
f_shift_stack = _f_shift.repeat(N_padded, n_channels, 1)
|
|
584
602
|
reshaped_f_shift = f_shift_stack.permute(
|
|
585
603
|
*torch.arange(f_shift_stack.ndim - 1, -1, -1)
|
|
@@ -911,7 +929,15 @@ def _rotate_signals(
|
|
|
911
929
|
sensors_positions_matrix: torch.Tensor,
|
|
912
930
|
spherical: bool = True,
|
|
913
931
|
) -> torch.Tensor:
|
|
914
|
-
|
|
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)
|
|
915
941
|
rot_sensors_matrices = [
|
|
916
942
|
rotation.matmul(sensors_positions_matrix) for rotation in rotations
|
|
917
943
|
]
|
|
@@ -921,9 +947,10 @@ def _rotate_signals(
|
|
|
921
947
|
torch.as_tensor(
|
|
922
948
|
_torch_make_interpolation_matrix(
|
|
923
949
|
sensors_positions_matrix.T, rot_sensors_matrix.T
|
|
924
|
-
)
|
|
925
|
-
|
|
926
|
-
|
|
950
|
+
)
|
|
951
|
+
)
|
|
952
|
+
.float()
|
|
953
|
+
.to(X.device)
|
|
927
954
|
for rot_sensors_matrix in rot_sensors_matrices
|
|
928
955
|
]
|
|
929
956
|
)
|
|
@@ -1062,10 +1089,12 @@ def mixup(
|
|
|
1062
1089
|
Online: https://arxiv.org/abs/1710.09412
|
|
1063
1090
|
.. [2] https://github.com/facebookresearch/mixup-cifar10/blob/master/train.py
|
|
1064
1091
|
"""
|
|
1065
|
-
device = X.device
|
|
1066
1092
|
batch_size, n_channels, n_times = X.shape
|
|
1067
1093
|
|
|
1068
|
-
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
|
+
)
|
|
1069
1098
|
y_a = y.clone()
|
|
1070
1099
|
y_b = y[idx_perm].clone()
|
|
1071
1100
|
|
|
@@ -1075,6 +1104,145 @@ def mixup(
|
|
|
1075
1104
|
return X_mix, (y_a, y_b, lam)
|
|
1076
1105
|
|
|
1077
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
|
+
|
|
1078
1246
|
def segmentation_reconstruction(
|
|
1079
1247
|
X: torch.Tensor,
|
|
1080
1248
|
y: torch.Tensor,
|
|
@@ -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
|
|
|
@@ -17,6 +18,7 @@ from braindecode.util import resolve_montage_name
|
|
|
17
18
|
|
|
18
19
|
from .base import Transform
|
|
19
20
|
from .functional import (
|
|
21
|
+
_max_float_dtype,
|
|
20
22
|
amplitude_scale,
|
|
21
23
|
band_rotation,
|
|
22
24
|
bandstop_filter,
|
|
@@ -24,9 +26,11 @@ from .functional import (
|
|
|
24
26
|
channels_permute,
|
|
25
27
|
channels_rereference,
|
|
26
28
|
channels_shuffle,
|
|
29
|
+
cutmix,
|
|
27
30
|
frequency_shift,
|
|
28
31
|
ft_surrogate,
|
|
29
32
|
gaussian_noise,
|
|
33
|
+
label_smoothing,
|
|
30
34
|
mask_encoding,
|
|
31
35
|
mixup,
|
|
32
36
|
segmentation_reconstruction,
|
|
@@ -492,6 +496,7 @@ class SmoothTimeMask(Transform):
|
|
|
492
496
|
size=X.shape[0],
|
|
493
497
|
),
|
|
494
498
|
device=X.device,
|
|
499
|
+
dtype=_max_float_dtype(X.device),
|
|
495
500
|
) * (seq_length - mask_len_samples)
|
|
496
501
|
return {
|
|
497
502
|
"mask_start_per_sample": mask_start,
|
|
@@ -673,7 +678,11 @@ class FrequencyShift(Transform):
|
|
|
673
678
|
return super().get_augmentation_params(*batch)
|
|
674
679
|
X = batch[0]
|
|
675
680
|
|
|
676
|
-
u = torch.as_tensor(
|
|
681
|
+
u = torch.as_tensor(
|
|
682
|
+
self.rng.uniform(size=X.shape[0]),
|
|
683
|
+
device=X.device,
|
|
684
|
+
dtype=_max_float_dtype(X.device),
|
|
685
|
+
)
|
|
677
686
|
max_delta_freq = self.max_delta_freq
|
|
678
687
|
if isinstance(max_delta_freq, torch.Tensor):
|
|
679
688
|
max_delta_freq = max_delta_freq.to(X.device)
|
|
@@ -831,7 +840,10 @@ class SensorsRotation(Transform):
|
|
|
831
840
|
if isinstance(max_degrees, torch.Tensor):
|
|
832
841
|
max_degrees = max_degrees.to(X.device)
|
|
833
842
|
random_angles = (
|
|
834
|
-
torch.as_tensor(u, device=X.device)
|
|
843
|
+
torch.as_tensor(u, device=X.device, dtype=_max_float_dtype(X.device))
|
|
844
|
+
* 2
|
|
845
|
+
* max_degrees
|
|
846
|
+
- max_degrees
|
|
835
847
|
)
|
|
836
848
|
return {
|
|
837
849
|
"sensors_positions_matrix": self.sensors_positions_matrix,
|
|
@@ -1095,6 +1107,147 @@ class Mixup(Transform):
|
|
|
1095
1107
|
}
|
|
1096
1108
|
|
|
1097
1109
|
|
|
1110
|
+
class CutMix(Mixup):
|
|
1111
|
+
"""Implements CutMix for EEG data.
|
|
1112
|
+
|
|
1113
|
+
A random time region of each example is replaced by the same region of
|
|
1114
|
+
a shuffled example of the batch, see [1]_. As in the reference code [2]_,
|
|
1115
|
+
a coefficient ``lam`` is drawn from a Beta distribution, the region is
|
|
1116
|
+
``(1 - lam) * n_times`` long (the 1-D analogue of the cut area ratio
|
|
1117
|
+
``1 - lam``) around a uniformly drawn center, it is clipped at the trial
|
|
1118
|
+
boundaries, and ``lam`` is then recomputed from the pasted length.
|
|
1119
|
+
|
|
1120
|
+
Like :class:`Mixup`, it applies to whole batches and returns targets
|
|
1121
|
+
``(y_a, y_b, lam)`` for :func:`braindecode.training.mixup_criterion`.
|
|
1122
|
+
|
|
1123
|
+
Parameters
|
|
1124
|
+
----------
|
|
1125
|
+
alpha : float
|
|
1126
|
+
Parameter of the Beta distribution of ``lam``. ``alpha <= 0`` cuts
|
|
1127
|
+
nothing.
|
|
1128
|
+
beta_per_sample : bool (default=False)
|
|
1129
|
+
By default, one ``lam`` per batch is drawn. If True, one per sample.
|
|
1130
|
+
random_state : int | numpy.random.Generator, optional
|
|
1131
|
+
Seed to be used to instantiate numpy random number generator instance.
|
|
1132
|
+
Defaults to None.
|
|
1133
|
+
|
|
1134
|
+
References
|
|
1135
|
+
----------
|
|
1136
|
+
.. [1] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun,
|
|
1137
|
+
Junsuk Choe, Youngjoon Yoo (2019). CutMix: Regularization Strategy
|
|
1138
|
+
to Train Strong Classifiers with Localizable Features. In 2019
|
|
1139
|
+
IEEE/CVF International Conference on Computer Vision (ICCV)
|
|
1140
|
+
Online: https://arxiv.org/abs/1905.04899
|
|
1141
|
+
.. [2] https://github.com/clovaai/CutMix-PyTorch/blob/master/train.py
|
|
1142
|
+
"""
|
|
1143
|
+
|
|
1144
|
+
operation = staticmethod(cutmix) # type: ignore[assignment]
|
|
1145
|
+
|
|
1146
|
+
def get_augmentation_params(self, *batch):
|
|
1147
|
+
"""Return idx_perm and the cut_t_start, cut_t_len of each region."""
|
|
1148
|
+
params = super().get_augmentation_params(*batch)
|
|
1149
|
+
lam = params.pop("lam")
|
|
1150
|
+
n_times = batch[0].shape[-1]
|
|
1151
|
+
half = ((1 - lam) * n_times).long() // 2
|
|
1152
|
+
center = torch.as_tensor(self.rng.randint(n_times, size=len(lam)))
|
|
1153
|
+
center = center.to(lam.device)
|
|
1154
|
+
start = (center - half).clamp(min=0)
|
|
1155
|
+
end = (center + half).clamp(max=n_times)
|
|
1156
|
+
return dict(params, cut_t_start=start, cut_t_len=end - start)
|
|
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.
|
|
1177
|
+
|
|
1178
|
+
Parameters
|
|
1179
|
+
----------
|
|
1180
|
+
epsilon : float
|
|
1181
|
+
Smoothing parameter between 0 and 1: the weight of the uniform
|
|
1182
|
+
distribution mixed into the targets. ``0`` disables smoothing.
|
|
1183
|
+
num_classes : int | None, optional
|
|
1184
|
+
Number of classes. Required when the targets are class indices;
|
|
1185
|
+
when the targets are already distributions of shape
|
|
1186
|
+
``batch_size, num_classes``, it must match their last dimension.
|
|
1187
|
+
Defaults to None.
|
|
1188
|
+
random_state : int | numpy.random.Generator, optional
|
|
1189
|
+
Seed to be used to instantiate numpy random number generator
|
|
1190
|
+
instance. The transform is deterministic, so the seed only feeds
|
|
1191
|
+
the application-probability machinery, which is inactive here.
|
|
1192
|
+
Defaults to None.
|
|
1193
|
+
|
|
1194
|
+
References
|
|
1195
|
+
----------
|
|
1196
|
+
.. [1] Christian Szegedy, Vincent Vanhoucke, Jonathon Shlens and
|
|
1197
|
+
Zbigniew Wojna (2016). Rethinking the Inception Architecture for
|
|
1198
|
+
Computer Vision. In 2016 IEEE Conference on Computer Vision and
|
|
1199
|
+
Pattern Recognition (CVPR), pp. 2818-2826.
|
|
1200
|
+
Online: https://arxiv.org/abs/1512.00567
|
|
1201
|
+
"""
|
|
1202
|
+
|
|
1203
|
+
operation = staticmethod(label_smoothing) # type: ignore[assignment]
|
|
1204
|
+
|
|
1205
|
+
def __init__(self, epsilon, num_classes=None, random_state=None):
|
|
1206
|
+
super().__init__(
|
|
1207
|
+
probability=1.0, # LabelSmoothing has to be applied to whole batches
|
|
1208
|
+
random_state=random_state,
|
|
1209
|
+
)
|
|
1210
|
+
if not isinstance(epsilon, Real) or not 0.0 <= float(epsilon) <= 1.0:
|
|
1211
|
+
raise ValueError(
|
|
1212
|
+
f"epsilon should be a real number between 0 and 1. Got {epsilon!r}."
|
|
1213
|
+
)
|
|
1214
|
+
if num_classes is not None and (
|
|
1215
|
+
not isinstance(num_classes, int)
|
|
1216
|
+
or isinstance(num_classes, bool)
|
|
1217
|
+
or num_classes < 2
|
|
1218
|
+
):
|
|
1219
|
+
raise ValueError(
|
|
1220
|
+
f"num_classes should be an integer of at least 2. Got {num_classes!r}."
|
|
1221
|
+
)
|
|
1222
|
+
self.epsilon = epsilon
|
|
1223
|
+
self.num_classes = num_classes
|
|
1224
|
+
|
|
1225
|
+
def get_augmentation_params(self, *batch):
|
|
1226
|
+
"""Return transform parameters.
|
|
1227
|
+
|
|
1228
|
+
Parameters
|
|
1229
|
+
----------
|
|
1230
|
+
X : tensor.Tensor
|
|
1231
|
+
The data.
|
|
1232
|
+
y : tensor.Tensor
|
|
1233
|
+
The labels.
|
|
1234
|
+
|
|
1235
|
+
Returns
|
|
1236
|
+
-------
|
|
1237
|
+
params : dict
|
|
1238
|
+
Contains
|
|
1239
|
+
|
|
1240
|
+
* epsilon : float
|
|
1241
|
+
Smoothing parameter between 0 and 1.
|
|
1242
|
+
* num_classes : int | None
|
|
1243
|
+
The number of classes.
|
|
1244
|
+
"""
|
|
1245
|
+
return {
|
|
1246
|
+
"epsilon": self.epsilon,
|
|
1247
|
+
"num_classes": self.num_classes,
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
|
|
1098
1251
|
class SegmentationReconstruction(Transform):
|
|
1099
1252
|
"""Segmentation Reconstruction from Lotte (2015) [Lotte2015]_.
|
|
1100
1253
|
|
|
@@ -1283,7 +1436,7 @@ class MaskEncoding(Transform):
|
|
|
1283
1436
|
)
|
|
1284
1437
|
|
|
1285
1438
|
time_start = self.rng.randint(
|
|
1286
|
-
0, n_times - segment_length, (batch_size, self.n_segments)
|
|
1439
|
+
0, n_times - segment_length + 1, (batch_size, self.n_segments)
|
|
1287
1440
|
)
|
|
1288
1441
|
time_start = torch.from_numpy(time_start)
|
|
1289
1442
|
|
{braindecode-1.8.1.dev169440825 → braindecode-1.8.1.dev169484576}/braindecode/datasets/base.py
RENAMED
|
@@ -634,7 +634,9 @@ class RecordDataset(Dataset[tuple[np.ndarray, int | str, tuple[int, int, int]]])
|
|
|
634
634
|
f"'{key}' already in description. Please "
|
|
635
635
|
f"rename or set overwrite to True."
|
|
636
636
|
)
|
|
637
|
-
|
|
637
|
+
# drop on a copy: windows datasets share the description
|
|
638
|
+
# Series of the dataset they were created from
|
|
639
|
+
self._description = self._description.drop(key)
|
|
638
640
|
self._description = pd.concat([self.description, description])
|
|
639
641
|
|
|
640
642
|
@property
|
|
@@ -1281,6 +1283,49 @@ class WindowsDataset(_ZarrMixin, RecordDataset):
|
|
|
1281
1283
|
)
|
|
1282
1284
|
|
|
1283
1285
|
|
|
1286
|
+
def _lazy_source_files(ds) -> list:
|
|
1287
|
+
"""Return the files ``ds`` still reads its signal from (none once preloaded)."""
|
|
1288
|
+
signal = ds.raw if hasattr(ds, "raw") else getattr(ds, "windows", None)
|
|
1289
|
+
if signal is None or getattr(signal, "preload", True):
|
|
1290
|
+
return []
|
|
1291
|
+
files = list(
|
|
1292
|
+
getattr(signal, "filenames", None) or [getattr(signal, "filename", None)]
|
|
1293
|
+
)
|
|
1294
|
+
raw = getattr(signal, "_raw", None)
|
|
1295
|
+
if isinstance(raw, mne.io.BaseRaw) and not raw.preload:
|
|
1296
|
+
files += raw.filenames # mne.Epochs of a lazily read Raw read through it
|
|
1297
|
+
return [f for f in files if f is not None]
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
def _dir_key(directory):
|
|
1301
|
+
"""Identify a directory by device and inode, whatever its spelling."""
|
|
1302
|
+
stat = os.stat(directory)
|
|
1303
|
+
return stat.st_dev, stat.st_ino
|
|
1304
|
+
|
|
1305
|
+
|
|
1306
|
+
def _overwrite_conflicts(datasets, path, offset):
|
|
1307
|
+
"""Yield ``(i_ds, i_target, target_dir)`` for each dataset ``i_ds`` that
|
|
1308
|
+
lazily reads from inside ``target_dir = path/<i_target + offset>``, which
|
|
1309
|
+
``save(overwrite=True)`` deletes before writing dataset ``i_target``.
|
|
1310
|
+
"""
|
|
1311
|
+
targets = {}
|
|
1312
|
+
for i in range(len(datasets)):
|
|
1313
|
+
target_dir = os.path.join(path, str(i + offset))
|
|
1314
|
+
if os.path.isdir(target_dir):
|
|
1315
|
+
targets[_dir_key(target_dir)] = (i, target_dir)
|
|
1316
|
+
if not targets:
|
|
1317
|
+
return
|
|
1318
|
+
for i_ds, ds in enumerate(datasets):
|
|
1319
|
+
for file in _lazy_source_files(ds):
|
|
1320
|
+
# ancestors of the name and of the file it links to (DataLad)
|
|
1321
|
+
parents = {
|
|
1322
|
+
*Path(os.path.abspath(file)).parents,
|
|
1323
|
+
*Path(os.path.realpath(file)).parents,
|
|
1324
|
+
}
|
|
1325
|
+
for key in {_dir_key(p) for p in parents if p.is_dir()} & targets.keys():
|
|
1326
|
+
yield (i_ds, *targets[key])
|
|
1327
|
+
|
|
1328
|
+
|
|
1284
1329
|
@register_dataset
|
|
1285
1330
|
class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
1286
1331
|
"""A base class for concatenated datasets.
|
|
@@ -1518,7 +1563,9 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1518
1563
|
metadata : pd.DataFrame
|
|
1519
1564
|
DataFrame containing as many rows as there are windows in the
|
|
1520
1565
|
BaseConcatDataset, with the metadata and description information
|
|
1521
|
-
for each window
|
|
1566
|
+
for each window, and an ``i_dataset`` column giving the position
|
|
1567
|
+
in ``datasets`` of the dataset (recording) each window comes from.
|
|
1568
|
+
Samplers use it to keep recordings apart.
|
|
1522
1569
|
"""
|
|
1523
1570
|
if not all(
|
|
1524
1571
|
[
|
|
@@ -1544,9 +1591,15 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1544
1591
|
"Dataset descriptions cannot contain the reserved window "
|
|
1545
1592
|
"metadata key 'i_trial_in_dataset'."
|
|
1546
1593
|
)
|
|
1594
|
+
if "i_dataset" in df.columns or "i_dataset" in ds.description:
|
|
1595
|
+
raise ValueError(
|
|
1596
|
+
"Window metadata and dataset descriptions cannot contain the "
|
|
1597
|
+
"key 'i_dataset', which get_metadata() reserves for the "
|
|
1598
|
+
"position of the dataset each window comes from. Rename it."
|
|
1599
|
+
)
|
|
1547
1600
|
|
|
1548
1601
|
all_dfs = list()
|
|
1549
|
-
for ds in self.datasets:
|
|
1602
|
+
for i_ds, ds in enumerate(self.datasets):
|
|
1550
1603
|
if hasattr(ds, "_windows") and ds._windows is not None:
|
|
1551
1604
|
df = ds._windows.metadata
|
|
1552
1605
|
else:
|
|
@@ -1556,6 +1609,7 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1556
1609
|
df = df.copy()
|
|
1557
1610
|
for k, v in ds.description.items():
|
|
1558
1611
|
df[k] = v
|
|
1612
|
+
df["i_dataset"] = i_ds
|
|
1559
1613
|
all_dfs.append(df)
|
|
1560
1614
|
|
|
1561
1615
|
return pd.concat(all_dfs)
|
|
@@ -1848,6 +1902,11 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1848
1902
|
dataset description.
|
|
1849
1903
|
"""
|
|
1850
1904
|
description = pd.DataFrame(description)
|
|
1905
|
+
if len(description.columns) and len(description) != len(self.datasets):
|
|
1906
|
+
raise ValueError(
|
|
1907
|
+
f"Length of values ({len(description)}) does not match "
|
|
1908
|
+
f"number of datasets ({len(self.datasets)})."
|
|
1909
|
+
)
|
|
1851
1910
|
for key, value in description.items():
|
|
1852
1911
|
for ds, value_ in zip(self.datasets, value):
|
|
1853
1912
|
ds.set_description({key: value_}, overwrite=overwrite)
|
|
@@ -1878,7 +1937,9 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1878
1937
|
-raw.fif | -epo.fif and .json files to.
|
|
1879
1938
|
overwrite : bool
|
|
1880
1939
|
Whether to delete old subdirectories that will be saved to in this
|
|
1881
|
-
call.
|
|
1940
|
+
call. If a dataset still reads its data lazily from one of them, a
|
|
1941
|
+
``ValueError`` is raised before anything is deleted: load the data
|
|
1942
|
+
into memory first (``preload=True``) or save to another directory.
|
|
1882
1943
|
offset : int
|
|
1883
1944
|
If provided, the integer is added to the id of the dataset in the
|
|
1884
1945
|
concat. This is useful in the setting of very large datasets, where
|
|
@@ -1891,6 +1952,13 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1891
1952
|
hasattr(self.datasets[0], "raw") or hasattr(self.datasets[0], "windows")
|
|
1892
1953
|
):
|
|
1893
1954
|
raise ValueError("dataset should have either raw or windows attribute")
|
|
1955
|
+
if overwrite:
|
|
1956
|
+
for _, _, target_dir in _overwrite_conflicts(self.datasets, path, offset):
|
|
1957
|
+
raise ValueError(
|
|
1958
|
+
f"Saving with overwrite=True would delete {target_dir} while "
|
|
1959
|
+
"a dataset still reads its data from it. Load the data into "
|
|
1960
|
+
"memory first (preload=True) or save to another directory."
|
|
1961
|
+
)
|
|
1894
1962
|
|
|
1895
1963
|
# Create path if it doesn't exist
|
|
1896
1964
|
os.makedirs(path, exist_ok=True)
|