Braindecode 1.8.1.dev170655981__tar.gz → 1.8.1.dev170976286__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.dev170655981 → braindecode-1.8.1.dev170976286}/NOTICE.txt +27 -2
- {braindecode-1.8.1.dev170655981/braindecode.egg-info → braindecode-1.8.1.dev170976286}/PKG-INFO +5 -1
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/augmentation/__init__.py +4 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/augmentation/base.py +7 -1
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/augmentation/functional.py +91 -12
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/augmentation/transforms.py +248 -3
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/classifier.py +9 -7
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/base.py +236 -12
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/mne.py +5 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/tuh.py +24 -15
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datautil/serialization.py +21 -10
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/eegneuralnet.py +7 -2
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/functional/__init__.py +8 -0
- braindecode-1.8.1.dev170976286/braindecode/functional/_real_dft.py +193 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/functional/functions.py +206 -17
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/__init__.py +43 -14
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/atcnet.py +11 -8
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/attn_sleep.py +9 -15
- braindecode-1.8.1.dev170976286/braindecode/models/axon.py +557 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/barista.py +29 -13
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/base.py +166 -20
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/bendr.py +73 -63
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/biot.py +61 -72
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/brainbert.py +10 -11
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/brainmodule.py +19 -12
- braindecode-1.8.1.dev170976286/braindecode/models/brainomni.py +962 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/brant.py +35 -21
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/cbramod.py +64 -26
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/codebrain.py +202 -84
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/config.py +1 -2
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/contrawr.py +26 -4
- braindecode-1.8.1.dev170976286/braindecode/models/csbrain.py +779 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/ctnet.py +18 -4
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/dance.py +1 -1
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/deep4.py +38 -13
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/dgcnn.py +10 -1
- braindecode-1.8.1.dev170976286/braindecode/models/diver1.py +940 -0
- braindecode-1.8.1.dev170976286/braindecode/models/duin.py +454 -0
- braindecode-1.8.1.dev170976286/braindecode/models/eeg_clip.py +369 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegconformer.py +19 -3
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegdino.py +32 -16
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eeginception_mi.py +48 -17
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegnex.py +20 -1
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegpt.py +80 -111
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegsym.py +102 -24
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/emg2qwerty.py +19 -2
- braindecode-1.8.1.dev170976286/braindecode/models/epint.py +315 -0
- braindecode-1.8.1.dev170976286/braindecode/models/gcnsnet.py +338 -0
- braindecode-1.8.1.dev170976286/braindecode/models/guetschel2026.py +775 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/labram.py +421 -252
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/luna.py +92 -45
- braindecode-1.8.1.dev170976286/braindecode/models/mapa.py +905 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/medformer.py +75 -43
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/meta_neuromotor.py +102 -55
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/mirepnet.py +38 -6
- braindecode-1.8.1.dev170976286/braindecode/models/mscformer.py +522 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/msvtnet.py +127 -8
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/mvpformer.py +181 -189
- braindecode-1.8.1.dev170976286/braindecode/models/neurorvq.py +712 -0
- braindecode-1.8.1.dev170976286/braindecode/models/neurorvq_tokenizer.py +647 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/patchedtransformer.py +3 -8
- braindecode-1.8.1.dev170976286/braindecode/models/popt.py +324 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/reve.py +180 -84
- braindecode-1.8.1.dev170976286/braindecode/models/seizure_transformer.py +407 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/sensingdynamics.py +10 -5
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/shallow_fbcsp.py +15 -8
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/signal_jepa.py +180 -50
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/sinc_shallow.py +2 -1
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/sleep_stager_blanco_2020.py +13 -6
- braindecode-1.8.1.dev170976286/braindecode/models/sleepfm.py +826 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/sstdpn.py +13 -10
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/steegformer.py +26 -13
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/summary.csv +20 -5
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/syncnet.py +2 -2
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/tcformer.py +30 -52
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/tcn.py +5 -0
- braindecode-1.8.1.dev170976286/braindecode/models/tfm_tokenizer.py +450 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/tidnet.py +18 -1
- braindecode-1.8.1.dev170976286/braindecode/models/tmsanet.py +233 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/usleep.py +3 -2
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/util.py +472 -110
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/zuna.py +52 -23
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/__init__.py +7 -2
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/attention.py +153 -29
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/blocks.py +132 -16
- braindecode-1.8.1.dev170976286/braindecode/modules/channels.py +536 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/convolution.py +25 -14
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/dance_modules.py +48 -27
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/filter.py +112 -60
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/layers.py +57 -25
- braindecode-1.8.1.dev170976286/braindecode/modules/linear_attention.py +128 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/parametrization.py +29 -0
- braindecode-1.8.1.dev170976286/braindecode/modules/popt_modules.py +187 -0
- braindecode-1.8.1.dev170976286/braindecode/modules/quantization.py +422 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/stats.py +6 -1
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/preprocessing/eegprep_preprocess.py +6 -3
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/preprocessing/preprocess.py +30 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/preprocessing/windowers.py +33 -21
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/regressor.py +47 -9
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/samplers/base.py +73 -63
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/training/losses.py +12 -6
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/training/scoring.py +22 -10
- braindecode-1.8.1.dev170976286/braindecode/version.py +1 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/visualization/topology.py +1 -1
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286/braindecode.egg-info}/PKG-INFO +5 -1
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode.egg-info/SOURCES.txt +26 -3
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode.egg-info/requires.txt +5 -0
- braindecode-1.8.1.dev170976286/docs/agent_docs.rst +60 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/api.rst +65 -7
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/conf.py +7 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/index.rst +1 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/models_categorization.rst +10 -3
- braindecode-1.8.1.dev170976286/docs/user_guide/channel_strategies.rst +59 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/whats_new.rst +672 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/pyproject.toml +6 -0
- braindecode-1.8.1.dev170655981/braindecode/models/interpolated.py +0 -185
- braindecode-1.8.1.dev170655981/braindecode/modules/interpolation.py +0 -201
- braindecode-1.8.1.dev170655981/braindecode/version.py +0 -1
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/LICENSE.txt +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/MANIFEST.in +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/README.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/__init__.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bids/format.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/chb_mit.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/collate.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/siena.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/utils.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/datautil/util.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/functional/initialization.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eeginception_erp.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegitnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegminer.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/ifnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/neuropose.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/sparcnet.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/models/vemg2pose.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/activation.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/linear.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/util.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/training/__init__.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/util.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/visualization/activations.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/visualization/attribution.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/visualization/frequency.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/visualization/metrics.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode/visualization/sanity.py +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/Makefile +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/cite.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/help.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/install/install.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/install/install_pip.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/install/install_source.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/models.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/models_table.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/setup.cfg +0 -0
|
@@ -13,9 +13,10 @@ The following components are licensed under the Creative Commons Attribution-Non
|
|
|
13
13
|
|
|
14
14
|
- `braindecode/models/eegminer.py`
|
|
15
15
|
- `braindecode/models/meta_neuromotor.py`
|
|
16
|
+
- `braindecode/models/sleepfm.py`
|
|
16
17
|
- `braindecode/models/brainmodule.py`
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
- `braindecode/models/neurorvq.py`
|
|
19
|
+
- `braindecode/models/neurorvq_tokenizer.py`
|
|
19
20
|
|
|
20
21
|
The `meta_neuromotor.py` file is a derivative of
|
|
21
22
|
`facebookresearch/generic-neuromotor-interface`, released by Meta Platforms,
|
|
@@ -39,19 +40,43 @@ The following components are licensed under the MIT License:
|
|
|
39
40
|
|
|
40
41
|
- `braindecode/models/ctnet.py`
|
|
41
42
|
- `braindecode/models/dance.py`
|
|
43
|
+
- `braindecode/models/duin.py`
|
|
42
44
|
- `braindecode/models/medformer.py`
|
|
43
45
|
- `braindecode/models/tcformer.py`
|
|
44
46
|
- `braindecode/models/ifnet.py`
|
|
45
47
|
- `braindecode/models/mirepnet.py`
|
|
48
|
+
- `braindecode/models/popt.py`
|
|
49
|
+
- `braindecode/models/tfm_tokenizer.py`
|
|
50
|
+
- `braindecode/modules/popt_modules.py`
|
|
51
|
+
- `braindecode/models/brainomni.py`
|
|
52
|
+
- `braindecode/modules/quantization.py`
|
|
53
|
+
- `braindecode/modules/linear_attention.py`
|
|
54
|
+
- `braindecode/models/seizure_transformer.py`
|
|
55
|
+
- `docs/_static/model/seizure_transformer_arch.png`
|
|
56
|
+
- `braindecode/models/guetschel2026.py`
|
|
57
|
+
- `braindecode/models/tmsanet.py`
|
|
58
|
+
- `braindecode/models/epint.py`
|
|
59
|
+
- `braindecode/models/gcnsnet.py`
|
|
60
|
+
|
|
61
|
+
The `brainomni.py` file is a derivative of `OpenTSLab/BrainOmni` (MIT), whose
|
|
62
|
+
SEANet codec derives from Meta's `facebookresearch/encodec` (MIT). The
|
|
63
|
+
`quantization.py` module holds the residual vector quantization derived from
|
|
64
|
+
`lucidrains/vector-quantize-pytorch` (MIT) and the BrainOmni port.
|
|
65
|
+
The `linear_attention.py` module is the part of
|
|
66
|
+
`lucidrains/linear-attention-transformer` (MIT) that BIOT and TFMTokenizer run.
|
|
46
67
|
|
|
47
68
|
### Apache-2.0 Licensed Files
|
|
48
69
|
|
|
49
70
|
The following components are licensed under the Apache License 2.0:
|
|
50
71
|
|
|
72
|
+
- `braindecode/models/axon.py`
|
|
51
73
|
- `braindecode/models/mvpformer.py`
|
|
52
74
|
- `braindecode/models/zuna.py`
|
|
53
75
|
- `braindecode/models/luna.py`
|
|
76
|
+
- `braindecode/models/mapa.py`
|
|
54
77
|
- `braindecode/models/brant.py`
|
|
78
|
+
- `braindecode/models/diver1.py`
|
|
79
|
+
- `braindecode/models/mscformer.py`
|
|
55
80
|
|
|
56
81
|
### USC Academic License Files
|
|
57
82
|
|
{braindecode-1.8.1.dev170655981/braindecode.egg-info → braindecode-1.8.1.dev170976286}/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.dev170976286
|
|
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>
|
|
@@ -44,6 +44,8 @@ Requires-Dist: huggingface_hub[torch]>=0.20.0; extra == "hub"
|
|
|
44
44
|
Requires-Dist: zarr>=3.0; extra == "hub"
|
|
45
45
|
Provides-Extra: viz
|
|
46
46
|
Requires-Dist: captum>=0.7.0; extra == "viz"
|
|
47
|
+
Provides-Extra: sae
|
|
48
|
+
Requires-Dist: sae-lens==6.51.3; extra == "sae"
|
|
47
49
|
Provides-Extra: tests
|
|
48
50
|
Requires-Dist: pytest<9.1; extra == "tests"
|
|
49
51
|
Requires-Dist: pytest-cov; extra == "tests"
|
|
@@ -58,6 +60,8 @@ Provides-Extra: typing
|
|
|
58
60
|
Requires-Dist: exca>=0.5.10; extra == "typing"
|
|
59
61
|
Requires-Dist: numpydantic>=1.7; extra == "typing"
|
|
60
62
|
Provides-Extra: docs
|
|
63
|
+
Requires-Dist: pytest<9.1; extra == "docs"
|
|
64
|
+
Requires-Dist: sphinx-markdown-builder==0.6.11; extra == "docs"
|
|
61
65
|
Requires-Dist: sphinx_gallery>=0.17; extra == "docs"
|
|
62
66
|
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
63
67
|
Requires-Dist: sphinx-autodoc-typehints; extra == "docs"
|
|
@@ -10,6 +10,7 @@ from .transforms import (
|
|
|
10
10
|
ChannelsReref,
|
|
11
11
|
ChannelsShuffle,
|
|
12
12
|
ChannelsSymmetry,
|
|
13
|
+
CutMix,
|
|
13
14
|
FrequencyShift,
|
|
14
15
|
FTSurrogate,
|
|
15
16
|
GaussianNoise,
|
|
@@ -23,6 +24,7 @@ from .transforms import (
|
|
|
23
24
|
SignFlip,
|
|
24
25
|
SmoothTimeMask,
|
|
25
26
|
TimeReverse,
|
|
27
|
+
TrivialAugment,
|
|
26
28
|
)
|
|
27
29
|
|
|
28
30
|
__all__ = [
|
|
@@ -30,10 +32,12 @@ __all__ = [
|
|
|
30
32
|
"IdentityTransform",
|
|
31
33
|
"Compose",
|
|
32
34
|
"AugmentedDataLoader",
|
|
35
|
+
"TrivialAugment",
|
|
33
36
|
"TimeReverse",
|
|
34
37
|
"SignFlip",
|
|
35
38
|
"FTSurrogate",
|
|
36
39
|
"ChannelsShuffle",
|
|
40
|
+
"CutMix",
|
|
37
41
|
"ChannelsDropout",
|
|
38
42
|
"GaussianNoise",
|
|
39
43
|
"ChannelsSymmetry",
|
{braindecode-1.8.1.dev170655981 → braindecode-1.8.1.dev170976286}/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
|
|
@@ -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
|
|
|
@@ -21,6 +22,21 @@ from torch.fft import fft, ifft
|
|
|
21
22
|
from torch.nn.functional import pad
|
|
22
23
|
|
|
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)
|
|
38
|
+
|
|
39
|
+
|
|
24
40
|
def identity(X: torch.Tensor, y: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
|
|
25
41
|
"""Identity operation.
|
|
26
42
|
|
|
@@ -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(
|
|
@@ -1074,6 +1102,54 @@ def mixup(
|
|
|
1074
1102
|
return X_mix, (y_a, y_b, lam)
|
|
1075
1103
|
|
|
1076
1104
|
|
|
1105
|
+
def cutmix(
|
|
1106
|
+
X: torch.Tensor,
|
|
1107
|
+
y: torch.Tensor,
|
|
1108
|
+
idx_perm: torch.Tensor,
|
|
1109
|
+
cut_t_start: torch.Tensor,
|
|
1110
|
+
cut_t_len: torch.Tensor,
|
|
1111
|
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
|
1112
|
+
"""Paste a time region of shuffled examples into the original examples.
|
|
1113
|
+
|
|
1114
|
+
See [1]_ for details.
|
|
1115
|
+
|
|
1116
|
+
Parameters
|
|
1117
|
+
----------
|
|
1118
|
+
X : torch.Tensor
|
|
1119
|
+
EEG data in form ``batch_size, n_channels, n_times``
|
|
1120
|
+
y : torch.Tensor
|
|
1121
|
+
Target of length ``batch_size``
|
|
1122
|
+
idx_perm : torch.Tensor
|
|
1123
|
+
Permuted indices of example that are mixed into original examples.
|
|
1124
|
+
cut_t_start : torch.Tensor
|
|
1125
|
+
Start index of the pasted time region for each example.
|
|
1126
|
+
cut_t_len : torch.Tensor
|
|
1127
|
+
Length of the pasted time region for each example.
|
|
1128
|
+
|
|
1129
|
+
Returns
|
|
1130
|
+
-------
|
|
1131
|
+
tuple
|
|
1132
|
+
``X``, ``y``. Where ``X`` is augmented and ``y`` is a tuple of length
|
|
1133
|
+
3 containing the labels of the two mixed examples and the fraction of
|
|
1134
|
+
each example kept from the original, ``1 - cut_t_len / n_times``.
|
|
1135
|
+
|
|
1136
|
+
References
|
|
1137
|
+
----------
|
|
1138
|
+
.. [1] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun,
|
|
1139
|
+
Junsuk Choe, Youngjoon Yoo (2019). CutMix: Regularization Strategy
|
|
1140
|
+
to Train Strong Classifiers with Localizable Features. In 2019
|
|
1141
|
+
IEEE/CVF International Conference on Computer Vision (ICCV)
|
|
1142
|
+
Online: https://arxiv.org/abs/1905.04899
|
|
1143
|
+
"""
|
|
1144
|
+
n_times = X.shape[-1]
|
|
1145
|
+
t = torch.arange(n_times, device=X.device)
|
|
1146
|
+
start = cut_t_start[:, None]
|
|
1147
|
+
in_cut = (t >= start) & (t < start + cut_t_len[:, None])
|
|
1148
|
+
X_mix = torch.where(in_cut[:, None], X[idx_perm], X)
|
|
1149
|
+
lam = (n_times - cut_t_len).to(X.dtype) / n_times
|
|
1150
|
+
return X_mix, (y.clone(), y[idx_perm].clone(), lam)
|
|
1151
|
+
|
|
1152
|
+
|
|
1077
1153
|
def segmentation_reconstruction(
|
|
1078
1154
|
X: torch.Tensor,
|
|
1079
1155
|
y: torch.Tensor,
|
|
@@ -1093,7 +1169,8 @@ def segmentation_reconstruction(
|
|
|
1093
1169
|
y : torch.Tensor
|
|
1094
1170
|
EEG labels for the example or batch.
|
|
1095
1171
|
n_segments : int
|
|
1096
|
-
Number of segments to use in the batch.
|
|
1172
|
+
Number of segments to use in the batch. Any remaining samples are
|
|
1173
|
+
included in the last segment.
|
|
1097
1174
|
data_classes : list[tuple[int, torch.Tensor]]
|
|
1098
1175
|
List of tuples. Each tuple contains the class index and the corresponding EEG data.
|
|
1099
1176
|
rand_indices : array-like
|
|
@@ -1133,6 +1210,8 @@ def segmentation_reconstruction(
|
|
|
1133
1210
|
for idx_segment in range(n_segments):
|
|
1134
1211
|
start = idx_segment * segment_size
|
|
1135
1212
|
end = (idx_segment + 1) * segment_size
|
|
1213
|
+
if idx_segment == n_segments - 1:
|
|
1214
|
+
end = window_size
|
|
1136
1215
|
|
|
1137
1216
|
# Perform the data augmentation
|
|
1138
1217
|
X_aug[np.arange(n_trials), :, start:end] = X_class[
|
|
@@ -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,6 +26,7 @@ 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,
|
|
@@ -492,6 +495,7 @@ class SmoothTimeMask(Transform):
|
|
|
492
495
|
size=X.shape[0],
|
|
493
496
|
),
|
|
494
497
|
device=X.device,
|
|
498
|
+
dtype=_max_float_dtype(X.device),
|
|
495
499
|
) * (seq_length - mask_len_samples)
|
|
496
500
|
return {
|
|
497
501
|
"mask_start_per_sample": mask_start,
|
|
@@ -673,7 +677,11 @@ class FrequencyShift(Transform):
|
|
|
673
677
|
return super().get_augmentation_params(*batch)
|
|
674
678
|
X = batch[0]
|
|
675
679
|
|
|
676
|
-
u = torch.as_tensor(
|
|
680
|
+
u = torch.as_tensor(
|
|
681
|
+
self.rng.uniform(size=X.shape[0]),
|
|
682
|
+
device=X.device,
|
|
683
|
+
dtype=_max_float_dtype(X.device),
|
|
684
|
+
)
|
|
677
685
|
max_delta_freq = self.max_delta_freq
|
|
678
686
|
if isinstance(max_delta_freq, torch.Tensor):
|
|
679
687
|
max_delta_freq = max_delta_freq.to(X.device)
|
|
@@ -831,7 +839,10 @@ class SensorsRotation(Transform):
|
|
|
831
839
|
if isinstance(max_degrees, torch.Tensor):
|
|
832
840
|
max_degrees = max_degrees.to(X.device)
|
|
833
841
|
random_angles = (
|
|
834
|
-
torch.as_tensor(u, device=X.device)
|
|
842
|
+
torch.as_tensor(u, device=X.device, dtype=_max_float_dtype(X.device))
|
|
843
|
+
* 2
|
|
844
|
+
* max_degrees
|
|
845
|
+
- max_degrees
|
|
835
846
|
)
|
|
836
847
|
return {
|
|
837
848
|
"sensors_positions_matrix": self.sensors_positions_matrix,
|
|
@@ -1095,6 +1106,55 @@ class Mixup(Transform):
|
|
|
1095
1106
|
}
|
|
1096
1107
|
|
|
1097
1108
|
|
|
1109
|
+
class CutMix(Mixup):
|
|
1110
|
+
"""Implements CutMix for EEG data.
|
|
1111
|
+
|
|
1112
|
+
A random time region of each example is replaced by the same region of
|
|
1113
|
+
a shuffled example of the batch, see [1]_. As in the reference code [2]_,
|
|
1114
|
+
a coefficient ``lam`` is drawn from a Beta distribution, the region is
|
|
1115
|
+
``(1 - lam) * n_times`` long (the 1-D analogue of the cut area ratio
|
|
1116
|
+
``1 - lam``) around a uniformly drawn center, it is clipped at the trial
|
|
1117
|
+
boundaries, and ``lam`` is then recomputed from the pasted length.
|
|
1118
|
+
|
|
1119
|
+
Like :class:`Mixup`, it applies to whole batches and returns targets
|
|
1120
|
+
``(y_a, y_b, lam)`` for :func:`braindecode.training.mixup_criterion`.
|
|
1121
|
+
|
|
1122
|
+
Parameters
|
|
1123
|
+
----------
|
|
1124
|
+
alpha : float
|
|
1125
|
+
Parameter of the Beta distribution of ``lam``. ``alpha <= 0`` cuts
|
|
1126
|
+
nothing.
|
|
1127
|
+
beta_per_sample : bool (default=False)
|
|
1128
|
+
By default, one ``lam`` per batch is drawn. If True, one per sample.
|
|
1129
|
+
random_state : int | numpy.random.Generator, optional
|
|
1130
|
+
Seed to be used to instantiate numpy random number generator instance.
|
|
1131
|
+
Defaults to None.
|
|
1132
|
+
|
|
1133
|
+
References
|
|
1134
|
+
----------
|
|
1135
|
+
.. [1] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun,
|
|
1136
|
+
Junsuk Choe, Youngjoon Yoo (2019). CutMix: Regularization Strategy
|
|
1137
|
+
to Train Strong Classifiers with Localizable Features. In 2019
|
|
1138
|
+
IEEE/CVF International Conference on Computer Vision (ICCV)
|
|
1139
|
+
Online: https://arxiv.org/abs/1905.04899
|
|
1140
|
+
.. [2] https://github.com/clovaai/CutMix-PyTorch/blob/master/train.py
|
|
1141
|
+
"""
|
|
1142
|
+
|
|
1143
|
+
operation = staticmethod(cutmix) # type: ignore[assignment]
|
|
1144
|
+
|
|
1145
|
+
def get_augmentation_params(self, *batch):
|
|
1146
|
+
"""Return idx_perm and the cut_t_start, cut_t_len of each region."""
|
|
1147
|
+
params = super().get_augmentation_params(*batch)
|
|
1148
|
+
lam = params.pop("lam")
|
|
1149
|
+
n_times = batch[0].shape[-1]
|
|
1150
|
+
half = ((1 - lam) * n_times).long() // 2
|
|
1151
|
+
center = torch.as_tensor(self.rng.randint(n_times, size=len(lam)))
|
|
1152
|
+
center = center.to(lam.device)
|
|
1153
|
+
start = (center - half).clamp(min=0)
|
|
1154
|
+
end = (center + half).clamp(max=n_times)
|
|
1155
|
+
return dict(params, cut_t_start=start, cut_t_len=end - start)
|
|
1156
|
+
|
|
1157
|
+
|
|
1098
1158
|
class SegmentationReconstruction(Transform):
|
|
1099
1159
|
"""Segmentation Reconstruction from Lotte (2015) [Lotte2015]_.
|
|
1100
1160
|
|
|
@@ -1283,7 +1343,7 @@ class MaskEncoding(Transform):
|
|
|
1283
1343
|
)
|
|
1284
1344
|
|
|
1285
1345
|
time_start = self.rng.randint(
|
|
1286
|
-
0, n_times - segment_length, (batch_size, self.n_segments)
|
|
1346
|
+
0, n_times - segment_length + 1, (batch_size, self.n_segments)
|
|
1287
1347
|
)
|
|
1288
1348
|
time_start = torch.from_numpy(time_start)
|
|
1289
1349
|
|
|
@@ -1457,3 +1517,188 @@ class BandRotation(Transform):
|
|
|
1457
1517
|
"circular_jitter": self.circular_jitter,
|
|
1458
1518
|
"random_state": self.rng,
|
|
1459
1519
|
}
|
|
1520
|
+
|
|
1521
|
+
|
|
1522
|
+
class TrivialAugment(Transform):
|
|
1523
|
+
"""Apply one randomly sampled label-preserving augmentation per example.
|
|
1524
|
+
|
|
1525
|
+
For every example, independently samples one transform from the pool
|
|
1526
|
+
below and one of ``num_bins`` strengths evenly spaced between that
|
|
1527
|
+
transform's bounds, as in TrivialAugment [1]_. Examples that draw the
|
|
1528
|
+
same transform and strength are transformed in one call; each pooled
|
|
1529
|
+
transform still draws its own randomness per example.
|
|
1530
|
+
|
|
1531
|
+
Default pool (no assumption on the signal's unit, sampling frequency or
|
|
1532
|
+
montage):
|
|
1533
|
+
|
|
1534
|
+
* :class:`TimeReverse` — no strength parameter.
|
|
1535
|
+
* :class:`SignFlip` — no strength parameter.
|
|
1536
|
+
* :class:`FTSurrogate` — phase noise magnitude, 0.2 to 1.
|
|
1537
|
+
* :class:`ChannelsDropout` — channel drop probability, 0.05 to 0.4.
|
|
1538
|
+
* :class:`ChannelsShuffle` — shuffle probability, 0.1 to 0.75.
|
|
1539
|
+
* :class:`SmoothTimeMask` — mask length as a fraction of the window
|
|
1540
|
+
length, 0.05 to 0.25.
|
|
1541
|
+
* :class:`GaussianNoise` — noise standard deviation as a fraction of the
|
|
1542
|
+
sub-batch standard deviation (volts or microvolts alike), 0.02 to 0.3.
|
|
1543
|
+
* :class:`AmplitudeScale` — scale interval ``(1/s, s)``, ``s`` from 1.25
|
|
1544
|
+
to 2.5.
|
|
1545
|
+
|
|
1546
|
+
``sfreq`` adds :class:`BandstopFilter` (bandwidth 0.5 to 4 Hz, capped
|
|
1547
|
+
2.5 Hz below Nyquist) and :class:`FrequencyShift` (maximum shift 0.5 to
|
|
1548
|
+
2 Hz); ``sensors_positions_matrix`` adds :class:`SensorsRotation` around
|
|
1549
|
+
the z axis (5 to 25 degrees).
|
|
1550
|
+
|
|
1551
|
+
Parameters
|
|
1552
|
+
----------
|
|
1553
|
+
probability : float, optional
|
|
1554
|
+
Probability of augmenting each example. Defaults to 1.0.
|
|
1555
|
+
sfreq : float | None, optional
|
|
1556
|
+
Sampling frequency of the signals, in Hz. Defaults to None.
|
|
1557
|
+
sensors_positions_matrix : array-like | None, optional
|
|
1558
|
+
Sensor positions of shape ``(3, n_channels)`` (see
|
|
1559
|
+
:class:`SensorsRotation`). Defaults to None.
|
|
1560
|
+
num_bins : int, optional
|
|
1561
|
+
Number of strength levels per transform. Defaults to 10.
|
|
1562
|
+
random_state : int | numpy.random.RandomState, optional
|
|
1563
|
+
Seed shared by the per-example sampler and every pooled transform.
|
|
1564
|
+
Defaults to None.
|
|
1565
|
+
|
|
1566
|
+
Attributes
|
|
1567
|
+
----------
|
|
1568
|
+
op_names : list of str
|
|
1569
|
+
Names of the transforms in the pool, in sampling order.
|
|
1570
|
+
|
|
1571
|
+
References
|
|
1572
|
+
----------
|
|
1573
|
+
.. [1] Müller, S. G., & Hutter, F. (2021). TrivialAugment:
|
|
1574
|
+
Tuning-free Yet State-of-the-Art Data Augmentation. Proceedings of
|
|
1575
|
+
the IEEE/CVF International Conference on Computer Vision (ICCV),
|
|
1576
|
+
pp. 774-782.
|
|
1577
|
+
"""
|
|
1578
|
+
|
|
1579
|
+
def __init__(
|
|
1580
|
+
self,
|
|
1581
|
+
probability=1.0,
|
|
1582
|
+
sfreq=None,
|
|
1583
|
+
sensors_positions_matrix=None,
|
|
1584
|
+
num_bins=10,
|
|
1585
|
+
random_state=None,
|
|
1586
|
+
):
|
|
1587
|
+
super().__init__(probability=probability, random_state=random_state)
|
|
1588
|
+
if not isinstance(num_bins, (int, np.integer)) or num_bins < 1:
|
|
1589
|
+
raise ValueError(f"num_bins must be a positive integer, got {num_bins}")
|
|
1590
|
+
self.num_bins = int(num_bins)
|
|
1591
|
+
rng = self.rng
|
|
1592
|
+
# (name, strength bounds or None, make(strength) or None: built per call)
|
|
1593
|
+
specs = [
|
|
1594
|
+
("TimeReverse", None, lambda s: TimeReverse(1.0, random_state=rng)),
|
|
1595
|
+
("SignFlip", None, lambda s: SignFlip(1.0, random_state=rng)),
|
|
1596
|
+
(
|
|
1597
|
+
"FTSurrogate",
|
|
1598
|
+
(0.2, 1.0),
|
|
1599
|
+
lambda s: FTSurrogate(1.0, phase_noise_magnitude=s, random_state=rng),
|
|
1600
|
+
),
|
|
1601
|
+
(
|
|
1602
|
+
"ChannelsDropout",
|
|
1603
|
+
(0.05, 0.4),
|
|
1604
|
+
lambda s: ChannelsDropout(1.0, p_drop=s, random_state=rng),
|
|
1605
|
+
),
|
|
1606
|
+
(
|
|
1607
|
+
"ChannelsShuffle",
|
|
1608
|
+
(0.1, 0.75),
|
|
1609
|
+
lambda s: ChannelsShuffle(1.0, p_shuffle=s, random_state=rng),
|
|
1610
|
+
),
|
|
1611
|
+
("SmoothTimeMask", (0.05, 0.25), None),
|
|
1612
|
+
("GaussianNoise", (0.02, 0.3), None),
|
|
1613
|
+
(
|
|
1614
|
+
"AmplitudeScale",
|
|
1615
|
+
(1.25, 2.5),
|
|
1616
|
+
lambda s: AmplitudeScale(1.0, interval=(1.0 / s, s), random_state=rng),
|
|
1617
|
+
),
|
|
1618
|
+
]
|
|
1619
|
+
if sfreq is not None:
|
|
1620
|
+
nyquist = sfreq / 2.0
|
|
1621
|
+
# BandstopFilter needs bandwidth < nyquist - 2; keep a margin
|
|
1622
|
+
max_bandwidth = min(4.0, nyquist - 2.5)
|
|
1623
|
+
if max_bandwidth <= 0.5:
|
|
1624
|
+
raise ValueError(
|
|
1625
|
+
f"sfreq={sfreq} is too small to sample valid band-stop "
|
|
1626
|
+
"bandwidths (needs at least 6.0 Hz)."
|
|
1627
|
+
)
|
|
1628
|
+
specs += [
|
|
1629
|
+
(
|
|
1630
|
+
"BandstopFilter",
|
|
1631
|
+
(0.5, max_bandwidth),
|
|
1632
|
+
lambda s: BandstopFilter(
|
|
1633
|
+
1.0,
|
|
1634
|
+
sfreq=sfreq,
|
|
1635
|
+
bandwidth=s,
|
|
1636
|
+
max_freq=nyquist,
|
|
1637
|
+
random_state=rng,
|
|
1638
|
+
),
|
|
1639
|
+
),
|
|
1640
|
+
(
|
|
1641
|
+
"FrequencyShift",
|
|
1642
|
+
(0.5, 2.0),
|
|
1643
|
+
lambda s: FrequencyShift(
|
|
1644
|
+
1.0, sfreq=sfreq, max_delta_freq=s, random_state=rng
|
|
1645
|
+
),
|
|
1646
|
+
),
|
|
1647
|
+
]
|
|
1648
|
+
if sensors_positions_matrix is not None:
|
|
1649
|
+
specs.append(
|
|
1650
|
+
(
|
|
1651
|
+
"SensorsRotation",
|
|
1652
|
+
(5.0, 25.0),
|
|
1653
|
+
lambda s: SensorsRotation(
|
|
1654
|
+
1.0,
|
|
1655
|
+
sensors_positions_matrix=sensors_positions_matrix,
|
|
1656
|
+
max_degrees=s,
|
|
1657
|
+
random_state=rng,
|
|
1658
|
+
),
|
|
1659
|
+
)
|
|
1660
|
+
)
|
|
1661
|
+
|
|
1662
|
+
self._pool = []
|
|
1663
|
+
for name, bounds, make in specs:
|
|
1664
|
+
if bounds is None:
|
|
1665
|
+
strengths = [None]
|
|
1666
|
+
else:
|
|
1667
|
+
strengths = np.linspace(*bounds, self.num_bins).tolist()
|
|
1668
|
+
variants = None if make is None else [make(s) for s in strengths]
|
|
1669
|
+
self._pool.append((name, strengths, variants))
|
|
1670
|
+
# pre-built transforms as submodules (pickle, ``.to()``)
|
|
1671
|
+
self._static_transforms = torch.nn.ModuleList(
|
|
1672
|
+
v for _, _, variants in self._pool if variants for v in variants
|
|
1673
|
+
)
|
|
1674
|
+
self.op_names = [name for name, _, _ in self._pool]
|
|
1675
|
+
|
|
1676
|
+
def operation(self, X, y):
|
|
1677
|
+
"""Apply one sampled transform and strength to each example of X."""
|
|
1678
|
+
n_strengths = np.array([len(strengths) for _, strengths, _ in self._pool])
|
|
1679
|
+
op_ids = self.rng.randint(0, len(self._pool), size=X.shape[0])
|
|
1680
|
+
bin_ids = self.rng.randint(0, self.num_bins, size=X.shape[0])
|
|
1681
|
+
# magnitude-free transforms collapse all examples onto bin 0
|
|
1682
|
+
bin_ids[n_strengths[op_ids] == 1] = 0
|
|
1683
|
+
keys = op_ids * self.num_bins + bin_ids
|
|
1684
|
+
|
|
1685
|
+
out_X, out_y = X.clone(), y.clone()
|
|
1686
|
+
for key in np.unique(keys):
|
|
1687
|
+
group = torch.from_numpy(np.flatnonzero(keys == key)).to(X.device)
|
|
1688
|
+
op_i, bin_j = divmod(int(key), self.num_bins)
|
|
1689
|
+
name, strengths, variants = self._pool[op_i]
|
|
1690
|
+
X_sub = X[group]
|
|
1691
|
+
if variants is not None:
|
|
1692
|
+
transform = variants[bin_j]
|
|
1693
|
+
elif name == "SmoothTimeMask":
|
|
1694
|
+
n_mask = max(1, int(round(strengths[bin_j] * X.shape[-1])))
|
|
1695
|
+
transform = SmoothTimeMask(
|
|
1696
|
+
1.0, mask_len_samples=n_mask, random_state=self.rng
|
|
1697
|
+
)
|
|
1698
|
+
else: # GaussianNoise, std relative to the sub-batch (unit-free)
|
|
1699
|
+
std = strengths[bin_j] * X_sub.std().item()
|
|
1700
|
+
transform = GaussianNoise(1.0, std=std, random_state=self.rng)
|
|
1701
|
+
tr_X, tr_y = transform(X_sub, y[group])
|
|
1702
|
+
out_X[group] = tr_X.to(out_X.dtype)
|
|
1703
|
+
out_y[group] = tr_y
|
|
1704
|
+
return out_X, out_y
|
|
@@ -207,15 +207,17 @@ class EEGClassifier(_EEGNeuralNet, NeuralNetClassifier):
|
|
|
207
207
|
|
|
208
208
|
Returns
|
|
209
209
|
-------
|
|
210
|
-
trial_predictions : np.ndarray
|
|
210
|
+
trial_predictions : np.ndarray | list of np.ndarray
|
|
211
211
|
3-dimensional array (n_trials x n_classes x n_predictions), where
|
|
212
212
|
the number of predictions depend on the chosen window size and the
|
|
213
|
-
receptive field of the network.
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
213
|
+
receptive field of the network. If trials have different lengths,
|
|
214
|
+
a list with one (n_classes x n_predictions) array per trial.
|
|
215
|
+
trial_targets : np.ndarray | list of np.ndarray
|
|
216
|
+
Ground-truth targets from the dataset. Only returned when
|
|
217
|
+
``return_targets=True``. An ``np.ndarray`` with a leading trial
|
|
218
|
+
dimension: ``(n_trials,)`` for scalar targets, with further
|
|
219
|
+
dimensions for multi-value or equal-length sequence targets. If
|
|
220
|
+
trial lengths differ, a list with one target array per trial.
|
|
219
221
|
"""
|
|
220
222
|
if not self.cropped:
|
|
221
223
|
warnings.warn(
|