braindecode 1.8.1.dev176562021__tar.gz → 1.8.1.dev176771289__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.dev176562021/braindecode.egg-info → braindecode-1.8.1.dev176771289}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/augmentation/base.py +7 -1
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/augmentation/functional.py +37 -10
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/augmentation/transforms.py +11 -2
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/base.py +8 -1
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/mne.py +5 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/tuh.py +2 -1
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datautil/serialization.py +11 -4
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/atcnet.py +11 -8
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/base.py +13 -1
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/ctnet.py +9 -3
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/guetschel2026.py +8 -8
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/reve.py +5 -11
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/blocks.py +16 -83
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/quantization.py +5 -5
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/preprocessing/eegprep_preprocess.py +6 -3
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/preprocessing/preprocess.py +2 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/preprocessing/windowers.py +28 -17
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/samplers/base.py +13 -2
- braindecode-1.8.1.dev176771289/braindecode/version.py +1 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289/braindecode.egg-info}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/whats_new.rst +50 -22
- braindecode-1.8.1.dev176562021/braindecode/version.py +0 -1
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/LICENSE.txt +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/MANIFEST.in +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/NOTICE.txt +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/README.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/augmentation/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/classifier.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bids/format.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/chb_mit.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/collate.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/siena.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/utils.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datautil/util.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/eegneuralnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/functional/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/functional/_real_dft.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/functional/functions.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/functional/initialization.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/attn_sleep.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/axon.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/barista.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/bendr.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/biot.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/brainbert.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/brainmodule.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/brainomni.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/brant.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/cbramod.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/codebrain.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/config.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/contrawr.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/csbrain.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/dance.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/deep4.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/dgcnn.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/diver1.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/duin.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eeg_clip.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegconformer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegdino.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eeginception_erp.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eeginception_mi.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegitnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegminer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegnex.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegpt.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegsym.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/emg2qwerty.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/epint.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/gcnsnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/ifnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/labram.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/luna.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/mapa.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/medformer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/meta_neuromotor.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/mirepnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/mscformer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/msvtnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/mvpformer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/neuropose.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/neurorvq.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/neurorvq_tokenizer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/patchedtransformer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/popt.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/sensingdynamics.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/shallow_fbcsp.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/signal_jepa.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/sinc_shallow.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/sleepfm.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/sparcnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/sstdpn.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/steegformer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/summary.csv +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/syncnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/tcformer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/tcn.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/tfm_tokenizer.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/tidnet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/tmsanet.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/usleep.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/util.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/vemg2pose.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/zuna.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/activation.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/attention.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/channels.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/convolution.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/dance_modules.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/filter.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/layers.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/linear.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/linear_attention.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/parametrization.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/popt_modules.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/stats.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/util.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/regressor.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/training/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/training/losses.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/training/scoring.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/util.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/visualization/activations.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/visualization/attribution.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/visualization/frequency.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/visualization/metrics.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/visualization/sanity.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/visualization/topology.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode.egg-info/SOURCES.txt +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode.egg-info/requires.txt +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/Makefile +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/agent_docs.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/api.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/cite.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/conf.py +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/help.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/index.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/install/install.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/install/install_pip.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/install/install_source.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/models.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/models_categorization.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/models_table.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/docs/user_guide/channel_strategies.rst +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/pyproject.toml +0 -0
- {braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/setup.cfg +0 -0
{braindecode-1.8.1.dev176562021/braindecode.egg-info → braindecode-1.8.1.dev176771289}/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.dev176771289
|
|
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>
|
{braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/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
|
|
@@ -22,6 +22,21 @@ from torch.fft import fft, ifft
|
|
|
22
22
|
from torch.nn.functional import pad
|
|
23
23
|
|
|
24
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
|
+
|
|
25
40
|
def identity(X: torch.Tensor, y: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
|
|
26
41
|
"""Identity operation.
|
|
27
42
|
|
|
@@ -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
|
)
|
|
@@ -18,6 +18,7 @@ from braindecode.util import resolve_montage_name
|
|
|
18
18
|
|
|
19
19
|
from .base import Transform
|
|
20
20
|
from .functional import (
|
|
21
|
+
_max_float_dtype,
|
|
21
22
|
amplitude_scale,
|
|
22
23
|
band_rotation,
|
|
23
24
|
bandstop_filter,
|
|
@@ -494,6 +495,7 @@ class SmoothTimeMask(Transform):
|
|
|
494
495
|
size=X.shape[0],
|
|
495
496
|
),
|
|
496
497
|
device=X.device,
|
|
498
|
+
dtype=_max_float_dtype(X.device),
|
|
497
499
|
) * (seq_length - mask_len_samples)
|
|
498
500
|
return {
|
|
499
501
|
"mask_start_per_sample": mask_start,
|
|
@@ -675,7 +677,11 @@ class FrequencyShift(Transform):
|
|
|
675
677
|
return super().get_augmentation_params(*batch)
|
|
676
678
|
X = batch[0]
|
|
677
679
|
|
|
678
|
-
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
|
+
)
|
|
679
685
|
max_delta_freq = self.max_delta_freq
|
|
680
686
|
if isinstance(max_delta_freq, torch.Tensor):
|
|
681
687
|
max_delta_freq = max_delta_freq.to(X.device)
|
|
@@ -833,7 +839,10 @@ class SensorsRotation(Transform):
|
|
|
833
839
|
if isinstance(max_degrees, torch.Tensor):
|
|
834
840
|
max_degrees = max_degrees.to(X.device)
|
|
835
841
|
random_angles = (
|
|
836
|
-
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
|
|
837
846
|
)
|
|
838
847
|
return {
|
|
839
848
|
"sensors_positions_matrix": self.sensors_positions_matrix,
|
{braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/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
|
|
@@ -1900,6 +1902,11 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1900
1902
|
dataset description.
|
|
1901
1903
|
"""
|
|
1902
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
|
+
)
|
|
1903
1910
|
for key, value in description.items():
|
|
1904
1911
|
for ds, value_ in zip(self.datasets, value):
|
|
1905
1912
|
ds.set_description({key: value_}, overwrite=overwrite)
|
{braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/mne.py
RENAMED
|
@@ -159,6 +159,11 @@ def create_from_mne_epochs(
|
|
|
159
159
|
|
|
160
160
|
list_of_windows_ds = []
|
|
161
161
|
for i, epochs in enumerate(list_of_epochs):
|
|
162
|
+
# drop rejected epochs first (on a copy) so that iterating over the
|
|
163
|
+
# epochs stays aligned with ``epochs.events``; preloaded epochs have
|
|
164
|
+
# already dropped them, so skip copying their data
|
|
165
|
+
if not epochs.preload:
|
|
166
|
+
epochs = epochs.copy().drop_bad()
|
|
162
167
|
event_descriptions = epochs.events[:, 2]
|
|
163
168
|
original_trial_starts = epochs.events[:, 0]
|
|
164
169
|
stop = len(epochs.times) - window_size_samples
|
{braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/datasets/tuh.py
RENAMED
|
@@ -122,7 +122,8 @@ class TUH(BaseConcatDataset):
|
|
|
122
122
|
# Assume it is an integer specifying number
|
|
123
123
|
# of recordings to load
|
|
124
124
|
recording_ids = range(recording_ids)
|
|
125
|
-
|
|
125
|
+
# select by chronological position, not by (file listing) label
|
|
126
|
+
descriptions = descriptions.iloc[:, list(recording_ids)]
|
|
126
127
|
|
|
127
128
|
# workaround to ensure warnings are suppressed when running in parallel
|
|
128
129
|
def create_dataset(*args, **kwargs):
|
|
@@ -140,15 +140,19 @@ def _load_signals(fif_file, preload, is_raw):
|
|
|
140
140
|
with open(pkl_file, "rb") as f:
|
|
141
141
|
signals = pickle.load(f)
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
# The pickle stores absolute paths: check that they exist and point to
|
|
144
|
+
# this fif file, not to the folder the dataset was copied from.
|
|
145
|
+
if all(Path(f).exists() for f in signals.filenames) and (
|
|
146
|
+
Path(signals.filenames[0]).resolve() == fif_file.resolve()
|
|
147
|
+
):
|
|
144
148
|
if preload:
|
|
145
149
|
signals.load_data()
|
|
146
150
|
return _compact_fif_tags(signals)
|
|
147
151
|
else: # This may happen if the file has been moved together with the pickle file.
|
|
148
152
|
warnings.warn(
|
|
149
153
|
f"Pickle file {pkl_file} exists, but the referenced fif "
|
|
150
|
-
"file(s) do not exist. Will read the
|
|
151
|
-
"and re-create the pickle file.",
|
|
154
|
+
"file(s) do not exist or are not next to it. Will read the "
|
|
155
|
+
"fif file(s) directly and re-create the pickle file.",
|
|
152
156
|
UserWarning,
|
|
153
157
|
)
|
|
154
158
|
|
|
@@ -220,7 +224,10 @@ def load_concat_dataset(path, preload, ids_to_load=None, target_name=None, n_job
|
|
|
220
224
|
# target_name.json, raw_preproc_kwargs.json, window_kwargs.json,
|
|
221
225
|
# window_preproc_kwargs.json
|
|
222
226
|
if ids_to_load is None:
|
|
223
|
-
|
|
227
|
+
# skip stray entries such as .DS_Store or a README next to the datasets
|
|
228
|
+
ids_to_load = [
|
|
229
|
+
p.name for p in path.iterdir() if p.is_dir() and p.name.isdigit()
|
|
230
|
+
]
|
|
224
231
|
ids_to_load = sorted(ids_to_load, key=lambda i: int(i))
|
|
225
232
|
ids_to_load = [str(i) for i in ids_to_load]
|
|
226
233
|
first_raw_fif_path = path / ids_to_load[0] / f"{ids_to_load[0]}-raw.fif"
|
{braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/atcnet.py
RENAMED
|
@@ -444,8 +444,10 @@ class ATCNet(EEGModuleMixin, nn.Module):
|
|
|
444
444
|
# ----- Sliding window -----
|
|
445
445
|
sw_concat: list[torch.Tensor] = [] # to store sliding window outputs
|
|
446
446
|
# for w in range(self.n_windows):
|
|
447
|
-
|
|
448
|
-
|
|
447
|
+
# (final_layer is not zipped in: with concat=True it holds a single
|
|
448
|
+
# layer, which would stop the loop after the first window)
|
|
449
|
+
for idx, (attention, tcn_module) in enumerate(
|
|
450
|
+
zip(self.attention_blocks, self.temporal_conv_nets)
|
|
449
451
|
):
|
|
450
452
|
conv_feat_w = conv_feat[..., idx : idx + self.Tw]
|
|
451
453
|
# Dimension: (batch_size, F2, Tw)
|
|
@@ -458,14 +460,15 @@ class ATCNet(EEGModuleMixin, nn.Module):
|
|
|
458
460
|
tcn_feat = tcn_module(att_feat)[..., -1]
|
|
459
461
|
# Dimension: (batch_size, F2)
|
|
460
462
|
|
|
461
|
-
# Outputs of sliding window can be either averaged after being
|
|
462
|
-
# mapped by dense layer or concatenated then mapped by a dense
|
|
463
|
-
# layer
|
|
464
|
-
if not self.concat:
|
|
465
|
-
tcn_feat = final_layer(tcn_feat)
|
|
466
|
-
|
|
467
463
|
sw_concat.append(tcn_feat)
|
|
468
464
|
|
|
465
|
+
# Outputs of sliding window can be either averaged after being
|
|
466
|
+
# mapped by dense layer or concatenated then mapped by a dense
|
|
467
|
+
# layer
|
|
468
|
+
if not self.concat:
|
|
469
|
+
for idx, final_layer in enumerate(self.final_layer):
|
|
470
|
+
sw_concat[idx] = final_layer(sw_concat[idx])
|
|
471
|
+
|
|
469
472
|
# ----- Aggregation and prediction -----
|
|
470
473
|
if self.concat:
|
|
471
474
|
sw_concat_agg = torch.cat(sw_concat, dim=1)
|
{braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/base.py
RENAMED
|
@@ -521,6 +521,11 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
521
521
|
output_shape : tuple[int, ...]
|
|
522
522
|
shape of the network output for `batch_size==1` (1, ...)
|
|
523
523
|
"""
|
|
524
|
+
# Run in eval mode, so that the probe input does not update BatchNorm
|
|
525
|
+
# running stats or draw dropout masks; restore each module's own mode
|
|
526
|
+
# afterwards (some may have been put in eval mode on purpose).
|
|
527
|
+
modes = {module: module.training for module in self.modules()}
|
|
528
|
+
self.eval()
|
|
524
529
|
with torch.inference_mode():
|
|
525
530
|
try:
|
|
526
531
|
return tuple(
|
|
@@ -540,6 +545,9 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
540
545
|
if error is None:
|
|
541
546
|
raise
|
|
542
547
|
raise error from exc
|
|
548
|
+
finally:
|
|
549
|
+
for module, training in modes.items():
|
|
550
|
+
module.training = training
|
|
543
551
|
|
|
544
552
|
def get_config(self) -> dict:
|
|
545
553
|
"""Return a JSON-serializable dict of all ``__init__`` parameters.
|
|
@@ -623,7 +631,11 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
623
631
|
``"pad"``.
|
|
624
632
|
"""
|
|
625
633
|
legacy = getattr(cls, "_legacy_on_non_divisible", None)
|
|
626
|
-
if legacy is
|
|
634
|
+
if legacy is None or "on_non_divisible" in kwargs:
|
|
635
|
+
return
|
|
636
|
+
# A subclass with its own signature may not take the argument.
|
|
637
|
+
params = inspect.signature(cls.__init__).parameters.values()
|
|
638
|
+
if any(p.name == "on_non_divisible" or p.kind is p.VAR_KEYWORD for p in params):
|
|
627
639
|
kwargs["on_non_divisible"] = legacy
|
|
628
640
|
|
|
629
641
|
def _set_n_outputs(self, n_outputs: int) -> None:
|
{braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/ctnet.py
RENAMED
|
@@ -181,6 +181,7 @@ class CTNet(EEGModuleMixin, nn.Module, license="mit"):
|
|
|
181
181
|
drop_prob=self.att_positional_drop_prob,
|
|
182
182
|
n_times=self.n_times,
|
|
183
183
|
pool_size=self.pool_size_1,
|
|
184
|
+
sequence_length=self.sequence_length,
|
|
184
185
|
)
|
|
185
186
|
|
|
186
187
|
self.trans = _TransformerEncoder(
|
|
@@ -220,7 +221,7 @@ class CTNet(EEGModuleMixin, nn.Module, license="mit"):
|
|
|
220
221
|
cnn = self.position(cnn)
|
|
221
222
|
trans = self.trans(cnn)
|
|
222
223
|
features = cnn + trans
|
|
223
|
-
flatten_feature = self.
|
|
224
|
+
flatten_feature = self.flatten_drop_layer(features)
|
|
224
225
|
out = self.final_layer(flatten_feature)
|
|
225
226
|
return out
|
|
226
227
|
|
|
@@ -516,18 +517,23 @@ class _PositionalEncoding(nn.Module):
|
|
|
516
517
|
length: int = 100,
|
|
517
518
|
drop_prob: float = 0.1,
|
|
518
519
|
pool_size: int = 8,
|
|
520
|
+
sequence_length: int | None = None,
|
|
519
521
|
):
|
|
520
522
|
super().__init__()
|
|
521
523
|
self.pool_size = pool_size
|
|
522
524
|
self.n_times = n_times
|
|
523
525
|
|
|
524
|
-
|
|
526
|
+
# n_times / pool_size**2 is the sequence length only when both pooling
|
|
527
|
+
# sizes are equal; also cover the actual length (e.g. pool_size_2 <
|
|
528
|
+
# pool_size_1), so that the encoding is never shorter than the input
|
|
529
|
+
needed = max(int(n_times / (pool_size * pool_size)), sequence_length or 0)
|
|
530
|
+
if needed > length:
|
|
525
531
|
warn(
|
|
526
532
|
"the temporal dimensional is too long for this default length. "
|
|
527
533
|
"The length parameter will be automatically adjusted to "
|
|
528
534
|
"avoid inference issues."
|
|
529
535
|
)
|
|
530
|
-
length =
|
|
536
|
+
length = needed
|
|
531
537
|
|
|
532
538
|
self.dropout = nn.Dropout(drop_prob)
|
|
533
539
|
self.encoding = nn.Parameter(torch.randn(1, length, emb_size))
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Authors: Pierre Guetschel <pierre.guetschel@gmail.com>
|
|
2
|
+
# Anton Soloviev <anton@praviel.com>
|
|
2
3
|
#
|
|
3
4
|
# License: MIT (see NOTICE.txt)
|
|
4
5
|
#
|
|
@@ -72,6 +73,8 @@ class _GaussianRandomProjection(nn.Module):
|
|
|
72
73
|
def __init__(self, n_features: int, n_components: int, seed: int = 0):
|
|
73
74
|
super().__init__()
|
|
74
75
|
self.n_features, self.n_components = n_features, n_components
|
|
76
|
+
# A factory also sees temporary device contexts on older torch versions.
|
|
77
|
+
device = torch.empty(0).device
|
|
75
78
|
generator = torch.Generator(device="cpu").manual_seed(seed)
|
|
76
79
|
projection = torch.empty(
|
|
77
80
|
n_components, n_features, dtype=torch.float32, device="cpu"
|
|
@@ -81,9 +84,7 @@ class _GaussianRandomProjection(nn.Module):
|
|
|
81
84
|
# the draw stays on the CPU, only the result follows the default device
|
|
82
85
|
self.register_buffer(
|
|
83
86
|
"projection",
|
|
84
|
-
projection.to(
|
|
85
|
-
device=torch.get_default_device(), dtype=torch.get_default_dtype()
|
|
86
|
-
),
|
|
87
|
+
projection.to(device=device, dtype=torch.get_default_dtype()),
|
|
87
88
|
)
|
|
88
89
|
|
|
89
90
|
def extra_repr(self) -> str:
|
|
@@ -107,12 +108,13 @@ class _LinearPatchEmbedding(nn.Module):
|
|
|
107
108
|
class _PositionalEncoder(nn.Module):
|
|
108
109
|
def __init__(self, ch_pos, embed_dim, pos_half_range, max_n_times):
|
|
109
110
|
super().__init__()
|
|
111
|
+
device = torch.empty(0).device
|
|
110
112
|
self.coord_dim = self.time_dim = embed_dim // 4
|
|
111
113
|
self.pos_half_range, self.max_n_times = pos_half_range, max_n_times
|
|
112
114
|
self.register_buffer("ch_pos", ch_pos, persistent=False)
|
|
113
115
|
self.register_buffer(
|
|
114
116
|
"div_term",
|
|
115
|
-
_xyz_div_term(self.coord_dim).to(
|
|
117
|
+
_xyz_div_term(self.coord_dim).to(device),
|
|
116
118
|
persistent=False,
|
|
117
119
|
)
|
|
118
120
|
self.register_buffer(
|
|
@@ -121,9 +123,7 @@ class _PositionalEncoder(nn.Module):
|
|
|
121
123
|
# the same table, which overwrites them. Computed on the CPU, then moved
|
|
122
124
|
# to the default device.
|
|
123
125
|
# 33 = (6000 - 200) // 180 + 1 patches: the 30 s pre-training window
|
|
124
|
-
_pos_encode_time(33, self.time_dim, max_n_times).to(
|
|
125
|
-
torch.get_default_device()
|
|
126
|
-
),
|
|
126
|
+
_pos_encode_time(33, self.time_dim, max_n_times).to(device),
|
|
127
127
|
)
|
|
128
128
|
|
|
129
129
|
def forward(self, n_patches: int, batch_size: int):
|
|
@@ -559,7 +559,7 @@ class Guetschel2026(EEGModuleMixin, nn.Module, license="mit"):
|
|
|
559
559
|
)
|
|
560
560
|
# float32 BEFORE the encoding: float64 then cast gives a 4.2e-5 difference.
|
|
561
561
|
ch_pos_np = ch_pos_f64.astype(np.float32)
|
|
562
|
-
ch_pos = torch.from_numpy(ch_pos_np).to(torch.
|
|
562
|
+
ch_pos = torch.from_numpy(ch_pos_np).to(torch.empty(0).device)
|
|
563
563
|
self.normalization: str = normalization
|
|
564
564
|
self.input_scale: float = input_scale
|
|
565
565
|
self.clip_sigma: float = clip_sigma
|
{braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/models/reve.py
RENAMED
|
@@ -329,18 +329,12 @@ class REVE(EEGModuleMixin, nn.Module):
|
|
|
329
329
|
step = patch_size - patch_overlap
|
|
330
330
|
# Raises for "crop" below one patch and for "error" on an untiled window.
|
|
331
331
|
_patch_count(known_n_times, patch_size, on_non_divisible, step)
|
|
332
|
-
if on_non_divisible == "pad" and
|
|
332
|
+
if on_non_divisible == "pad" and (
|
|
333
|
+
known_n_times < patch_size or (known_n_times - patch_size) % step
|
|
334
|
+
):
|
|
333
335
|
warnings.warn(
|
|
334
|
-
f"
|
|
335
|
-
|
|
336
|
-
UserWarning,
|
|
337
|
-
stacklevel=2,
|
|
338
|
-
)
|
|
339
|
-
elif on_non_divisible == "pad" and (known_n_times - patch_size) % step:
|
|
340
|
-
warnings.warn(
|
|
341
|
-
f"Time dimension ({known_n_times}) minus patch_size "
|
|
342
|
-
f"({patch_size}) is not divisible by the patch step ({step}). "
|
|
343
|
-
"Input will be padded.",
|
|
336
|
+
f"REVE's patches do not tile {known_n_times} samples: the input "
|
|
337
|
+
"will be padded.",
|
|
344
338
|
UserWarning,
|
|
345
339
|
stacklevel=2,
|
|
346
340
|
)
|
{braindecode-1.8.1.dev176562021 → braindecode-1.8.1.dev176771289}/braindecode/modules/blocks.py
RENAMED
|
@@ -20,33 +20,8 @@ def _check_on_non_divisible(on_non_divisible: str) -> None:
|
|
|
20
20
|
def _patch_count(
|
|
21
21
|
n_times: int, patch_size: int, on_non_divisible: str = "pad", step: int = 0
|
|
22
22
|
) -> int:
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
The single source of the patch count of the patch-based models: their
|
|
26
|
-
positional tables, flatten heads and ``max_patches`` guards are sized
|
|
27
|
-
with it, so they agree with what the tokenizer produces at ``forward``.
|
|
28
|
-
|
|
29
|
-
Parameters
|
|
30
|
-
----------
|
|
31
|
-
n_times : int
|
|
32
|
-
Number of time samples.
|
|
33
|
-
patch_size : int
|
|
34
|
-
Number of samples per patch.
|
|
35
|
-
on_non_divisible : {"pad", "crop", "error"}, default="pad"
|
|
36
|
-
``"pad"`` counts the right zero-padded last patch
|
|
37
|
-
(``ceil``), ``"crop"`` only the complete patches (``floor``), and
|
|
38
|
-
``"error"`` raises when patches do not tile the axis exactly.
|
|
39
|
-
step : int, default=0
|
|
40
|
-
Hop between consecutive patch starts; ``0`` means ``patch_size``
|
|
41
|
-
(non-overlapping patches). Overlapping patches (``step <
|
|
42
|
-
patch_size``) tile the axis when ``(n_times - patch_size) % step ==
|
|
43
|
-
0``.
|
|
44
|
-
|
|
45
|
-
Returns
|
|
46
|
-
-------
|
|
47
|
-
int
|
|
48
|
-
The number of patches, at least 1.
|
|
49
|
-
"""
|
|
23
|
+
"""Patches cut from ``n_times`` samples every ``step`` (``0``: ``patch_size``):
|
|
24
|
+
the last one zero-padded (``"pad"``), dropped (``"crop"``) or an error."""
|
|
50
25
|
if step <= 0:
|
|
51
26
|
step = patch_size
|
|
52
27
|
if n_times < 1:
|
|
@@ -58,63 +33,26 @@ def _patch_count(
|
|
|
58
33
|
raise ValueError(
|
|
59
34
|
f"Need at least one full patch of {patch_size} samples, got {n_times}."
|
|
60
35
|
)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
n_complete = (n_times - patch_size) // step + 1
|
|
66
|
-
if (n_times - patch_size) % step == 0:
|
|
67
|
-
return n_complete
|
|
68
|
-
if on_non_divisible == "pad":
|
|
69
|
-
return n_complete + 1
|
|
70
|
-
if on_non_divisible == "crop":
|
|
71
|
-
return n_complete
|
|
72
|
-
if step == patch_size:
|
|
73
|
-
raise ValueError(
|
|
74
|
-
f"Time dimension ({n_times}) is not divisible by patch_size ({patch_size})."
|
|
75
|
-
)
|
|
36
|
+
elif (n_times - patch_size) % step == 0:
|
|
37
|
+
return (n_times - patch_size) // step + 1
|
|
38
|
+
elif on_non_divisible != "error":
|
|
39
|
+
return (n_times - patch_size) // step + 1 + (on_non_divisible == "pad")
|
|
76
40
|
raise ValueError(
|
|
77
|
-
f"Time dimension ({n_times})
|
|
78
|
-
f"
|
|
41
|
+
f"Time dimension ({n_times}) is not divisible by patch_size ({patch_size})"
|
|
42
|
+
+ ("." if step == patch_size else f" with patch step {step}.")
|
|
79
43
|
)
|
|
80
44
|
|
|
81
45
|
|
|
82
46
|
def _pad_or_crop_to_patches(
|
|
83
47
|
x: torch.Tensor, patch_size: int, on_non_divisible: str = "pad", step: int = 0
|
|
84
48
|
) -> torch.Tensor:
|
|
85
|
-
"""Right zero-pad or crop the last axis
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Parameters
|
|
93
|
-
----------
|
|
94
|
-
x : torch.Tensor
|
|
95
|
-
Input of shape ``(..., n_times)``.
|
|
96
|
-
patch_size : int
|
|
97
|
-
Number of samples per patch.
|
|
98
|
-
on_non_divisible : {"pad", "crop", "error"}, default="pad"
|
|
99
|
-
See :func:`_patch_count`.
|
|
100
|
-
step : int, default=0
|
|
101
|
-
Hop between patch starts; ``0`` means ``patch_size``.
|
|
102
|
-
|
|
103
|
-
Returns
|
|
104
|
-
-------
|
|
105
|
-
torch.Tensor
|
|
106
|
-
``x`` padded, cropped or unchanged.
|
|
107
|
-
"""
|
|
108
|
-
n_times = x.shape[-1]
|
|
109
|
-
n_patches = _patch_count(n_times, patch_size, on_non_divisible, step)
|
|
110
|
-
if step <= 0:
|
|
111
|
-
step = patch_size
|
|
112
|
-
target = patch_size + (n_patches - 1) * step
|
|
113
|
-
if target > n_times:
|
|
114
|
-
return nn.functional.pad(x, (0, target - n_times))
|
|
115
|
-
if target < n_times:
|
|
116
|
-
return x[..., :target]
|
|
117
|
-
return x
|
|
49
|
+
"""Right zero-pad or crop the last axis so the patches tile it; a tiled axis
|
|
50
|
+
is returned as is."""
|
|
51
|
+
n_patches = _patch_count(x.shape[-1], patch_size, on_non_divisible, step)
|
|
52
|
+
target = patch_size + (n_patches - 1) * (step if step > 0 else patch_size)
|
|
53
|
+
if target > x.shape[-1]:
|
|
54
|
+
return nn.functional.pad(x, (0, target - x.shape[-1]))
|
|
55
|
+
return x[..., :target]
|
|
118
56
|
|
|
119
57
|
|
|
120
58
|
class PatchTokenizer(nn.Module):
|
|
@@ -231,12 +169,7 @@ class PatchTokenizer(nn.Module):
|
|
|
231
169
|
self.proj = nn.Linear(patch_size, self.emb_dim)
|
|
232
170
|
|
|
233
171
|
def n_patches(self, n_times: int) -> int:
|
|
234
|
-
"""Number of patches ``forward`` returns for ``n_times`` samples.
|
|
235
|
-
|
|
236
|
-
``ceil(n_times / patch_size)`` for ``on_non_divisible="pad"``,
|
|
237
|
-
``n_times // patch_size`` for ``"crop"``; ``"error"`` raises for a
|
|
238
|
-
non-divisible ``n_times``.
|
|
239
|
-
"""
|
|
172
|
+
"""Number of patches ``forward`` returns for ``n_times`` samples."""
|
|
240
173
|
return _patch_count(n_times, self.patch_size, self.on_non_divisible)
|
|
241
174
|
|
|
242
175
|
def prepare_input(self, x):
|
|
@@ -217,11 +217,11 @@ class EMACodebook(nn.Module):
|
|
|
217
217
|
work = torch.promote_types(x.dtype, torch.float32)
|
|
218
218
|
x = x.to(work)
|
|
219
219
|
embed = self.embed.t().to(work)
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
)
|
|
220
|
+
# x2 - 2 x @ e + e2 written into the (N, codebook_size) product:
|
|
221
|
+
# same operations and rounding, no two more temporaries of that size.
|
|
222
|
+
dist = (2 * x @ embed).to(work)
|
|
223
|
+
dist = torch.sub(x.pow(2).sum(1, keepdim=True), dist, out=dist)
|
|
224
|
+
dist = dist.add_(embed.pow(2).sum(0, keepdim=True))
|
|
225
225
|
indices = dist.argmin(dim=-1)
|
|
226
226
|
return indices
|
|
227
227
|
|
|
@@ -163,7 +163,8 @@ class EEGPrepBasePreprocessor(Preprocessor):
|
|
|
163
163
|
eeg_idx = mne.pick_types(raw.info, eeg=True, exclude=[])
|
|
164
164
|
if len(eeg_idx) < len(chn_order):
|
|
165
165
|
eeg = raw.copy().pick(eeg_idx)
|
|
166
|
-
|
|
166
|
+
# on a copy, so that a failure below leaves the caller's raw intact
|
|
167
|
+
non_eeg = raw.copy().drop_channels(eeg.ch_names)
|
|
167
168
|
else:
|
|
168
169
|
eeg = raw
|
|
169
170
|
non_eeg = None
|
|
@@ -237,9 +238,11 @@ class EEGPrepBasePreprocessor(Preprocessor):
|
|
|
237
238
|
)
|
|
238
239
|
else:
|
|
239
240
|
# re-insert non-EEG channels, and restore original channel order
|
|
241
|
+
# of the channels that remain (the operation may remove some)
|
|
240
242
|
proc.add_channels([non_eeg], force_update_info=True)
|
|
241
|
-
if proc.ch_names
|
|
242
|
-
|
|
243
|
+
order = [ch for ch in chn_order if ch in proc.ch_names]
|
|
244
|
+
if proc.ch_names != order:
|
|
245
|
+
proc.reorder_channels(order)
|
|
243
246
|
|
|
244
247
|
# write result back into raw, discard proc (_apply_op() is in-place)
|
|
245
248
|
if not proc.preload:
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
# Bruno Aristimunha <b.aristimunha@gmail.com>
|
|
8
8
|
# Léo Burgund <leo.burgund@gmail.com>
|
|
9
9
|
# Sarthak Tayal <sarthaktayal2@gmail.com>
|
|
10
|
+
# Anton Soloviev <anton@praviel.com>
|
|
10
11
|
#
|
|
11
12
|
# License: BSD (3-clause)
|
|
12
13
|
|
|
@@ -170,6 +171,7 @@ class Preprocessor(object):
|
|
|
170
171
|
Preprocessor
|
|
171
172
|
The deserialized Preprocessor object.
|
|
172
173
|
"""
|
|
174
|
+
data = data.copy()
|
|
173
175
|
class_path = data.pop("__class_path__")
|
|
174
176
|
cls_name = class_path.split(".")[-1]
|
|
175
177
|
cls_module_name = ".".join(class_path.split(".")[:-1])
|