Braindecode 1.8.1.dev174671102__tar.gz → 1.8.1.dev174738705__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.dev174671102/braindecode.egg-info → braindecode-1.8.1.dev174738705}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/base.py +119 -6
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/tuh.py +8 -4
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datautil/serialization.py +10 -6
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/attn_sleep.py +4 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/base.py +34 -15
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/brainomni.py +14 -4
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/csbrain.py +5 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/deep4.py +10 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/dgcnn.py +7 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegconformer.py +5 -2
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegnex.py +16 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/labram.py +23 -14
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/luna.py +4 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/medformer.py +4 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/msvtnet.py +5 -2
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/neurorvq.py +17 -3
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/neurorvq_tokenizer.py +47 -52
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/reve.py +13 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/signal_jepa.py +6 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/sleep_stager_blanco_2020.py +13 -6
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/tcn.py +5 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/tidnet.py +18 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/usleep.py +3 -2
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/zuna.py +6 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/filter.py +79 -33
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/quantization.py +10 -6
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/preprocessing/preprocess.py +11 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/preprocessing/windowers.py +3 -1
- braindecode-1.8.1.dev174738705/braindecode/version.py +1 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705/braindecode.egg-info}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/whats_new.rst +25 -0
- braindecode-1.8.1.dev174671102/braindecode/version.py +0 -1
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/LICENSE.txt +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/MANIFEST.in +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/NOTICE.txt +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/README.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/augmentation/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/augmentation/base.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/augmentation/functional.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/augmentation/transforms.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/classifier.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bids/format.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/chb_mit.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/collate.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/mne.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/siena.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/utils.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datautil/util.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/eegneuralnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/functional/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/functional/_real_dft.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/functional/functions.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/functional/initialization.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/atcnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/axon.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/barista.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/bendr.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/biot.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/brainbert.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/brainmodule.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/brant.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/cbramod.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/codebrain.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/config.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/contrawr.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/ctnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/dance.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/diver1.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eeg_clip.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegdino.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eeginception_erp.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eeginception_mi.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegitnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegminer.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegpt.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegsym.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/emg2qwerty.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/guetschel2026.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/ifnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/mapa.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/meta_neuromotor.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/mirepnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/mscformer.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/mvpformer.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/neuropose.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/patchedtransformer.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/popt.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/sensingdynamics.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/shallow_fbcsp.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/sinc_shallow.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/sleepfm.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/sparcnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/sstdpn.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/steegformer.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/summary.csv +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/syncnet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/tcformer.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/tfm_tokenizer.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/tmsanet.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/util.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/vemg2pose.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/activation.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/attention.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/blocks.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/channels.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/convolution.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/dance_modules.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/layers.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/linear.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/linear_attention.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/parametrization.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/popt_modules.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/stats.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/util.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/regressor.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/samplers/base.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/training/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/training/losses.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/training/scoring.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/util.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/visualization/activations.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/visualization/attribution.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/visualization/frequency.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/visualization/metrics.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/visualization/sanity.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/visualization/topology.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode.egg-info/SOURCES.txt +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode.egg-info/requires.txt +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/Makefile +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/agent_docs.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/api.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/cite.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/conf.py +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/help.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/index.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/install/install.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/install/install_pip.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/install/install_source.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/models.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/models_categorization.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/models_table.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/docs/user_guide/channel_strategies.rst +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/pyproject.toml +0 -0
- {braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/setup.cfg +0 -0
{braindecode-1.8.1.dev174671102/braindecode.egg-info → braindecode-1.8.1.dev174738705}/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.dev174738705
|
|
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.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/base.py
RENAMED
|
@@ -14,13 +14,16 @@ from __future__ import annotations
|
|
|
14
14
|
import bisect
|
|
15
15
|
import html as _html
|
|
16
16
|
import json
|
|
17
|
+
import mmap
|
|
17
18
|
import os
|
|
18
19
|
import shutil
|
|
19
20
|
import warnings
|
|
20
21
|
from abc import abstractmethod
|
|
21
22
|
from collections import Counter
|
|
22
|
-
from collections.abc import Callable, Hashable
|
|
23
|
+
from collections.abc import Callable, Hashable, Sequence
|
|
23
24
|
from glob import glob
|
|
25
|
+
from itertools import chain
|
|
26
|
+
from operator import attrgetter
|
|
24
27
|
from pathlib import Path
|
|
25
28
|
from typing import Any, Generic, Iterable, no_type_check
|
|
26
29
|
|
|
@@ -28,6 +31,7 @@ import mne
|
|
|
28
31
|
import mne.io
|
|
29
32
|
import numpy as np
|
|
30
33
|
import pandas as pd
|
|
34
|
+
from mne.io.constants import FIFF
|
|
31
35
|
from mne.utils import _soft_import
|
|
32
36
|
from mne.utils.docs import deprecated
|
|
33
37
|
from torch.utils.data import ConcatDataset, Dataset, IterableDataset
|
|
@@ -220,6 +224,109 @@ def _compute_ch_pos(info, targets_from):
|
|
|
220
224
|
return pos
|
|
221
225
|
|
|
222
226
|
|
|
227
|
+
_TAG_ROW = attrgetter("kind", "type", "size", "next", "pos")
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _tag_rows(tags):
|
|
231
|
+
"""(kind, type, size, next, pos) of FIF tags as an int64 array (n, 5)."""
|
|
232
|
+
flat = chain.from_iterable(map(_TAG_ROW, tags))
|
|
233
|
+
return np.fromiter(flat, np.int64, 5 * len(tags)).reshape(-1, 5)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class _FifTagTable(Sequence):
|
|
237
|
+
"""The data-buffer tags of a lazy FIF raw as one int64 array.
|
|
238
|
+
|
|
239
|
+
mne's FIF reader keeps one ``Tag`` object per data buffer in
|
|
240
|
+
``raw._raw_extras[i]["ent"]`` (one per second of signal with mne's default
|
|
241
|
+
buffers), each with its attribute dict and integers once unpickled. A lazy
|
|
242
|
+
dataset of many recordings holds millions of them in RAM, and every forked
|
|
243
|
+
DataLoader worker copies the memory pages of those it reads (reference
|
|
244
|
+
counts). This holds the same fields in 40 bytes per buffer and returns an
|
|
245
|
+
equal ``Tag`` on access, so mne's own reads are unchanged.
|
|
246
|
+
"""
|
|
247
|
+
|
|
248
|
+
def __init__(self, tags):
|
|
249
|
+
self.tag_class = type(tags[0])
|
|
250
|
+
self.table = _tag_rows(tags)
|
|
251
|
+
|
|
252
|
+
def __len__(self):
|
|
253
|
+
return len(self.table)
|
|
254
|
+
|
|
255
|
+
def __getitem__(self, i):
|
|
256
|
+
if isinstance(i, slice):
|
|
257
|
+
return [self.tag_class(*row) for row in self.table[i].tolist()]
|
|
258
|
+
return self.tag_class(*self.table[i].tolist())
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
_TAG_FIELDS = ("kind", "type", "size", "next", "pos", "data")
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _compact_fif_tags(inst):
|
|
265
|
+
"""Swap the ``Tag`` lists of a FIF raw for `_FifTagTable` (in place).
|
|
266
|
+
|
|
267
|
+
Only gap-free lists of directory tags (no ``None``, no ``data``) with mne's
|
|
268
|
+
``Tag`` fields are swapped; anything else is left as mne built it.
|
|
269
|
+
"""
|
|
270
|
+
for extra in getattr(inst, "_raw_extras", ()):
|
|
271
|
+
tags = extra.get("ent")
|
|
272
|
+
if not isinstance(tags, list) or not tags:
|
|
273
|
+
continue
|
|
274
|
+
cls = type(tags[0])
|
|
275
|
+
if tuple(getattr(cls, "__dataclass_fields__", ())) == _TAG_FIELDS and all(
|
|
276
|
+
type(t) is cls and t.data is None for t in tags
|
|
277
|
+
):
|
|
278
|
+
extra["ent"] = _FifTagTable(tags)
|
|
279
|
+
return inst
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def _read_fif_window(raw, start, stop):
|
|
283
|
+
"""Samples ``start:stop`` of a lazy FIF raw, copied from the file in one go.
|
|
284
|
+
|
|
285
|
+
mne reads, casts and calibrates the FIF data buffers of a range one at a
|
|
286
|
+
time (60 Python steps for a 60-s window saved with 1-s buffers, each through
|
|
287
|
+
a buffered file whose buffer is 4 MB on network file systems). Here one
|
|
288
|
+
slice of the memory-mapped file holds the bytes of every buffer in the
|
|
289
|
+
range and one multiply calibrates them, with mne's arithmetic (float64 data
|
|
290
|
+
times ``raw._cals``), so the values equal ``raw._getitem``'s. Returns None
|
|
291
|
+
(the caller uses mne) unless ``raw`` is a lazy, single-file, uncompressed
|
|
292
|
+
FIF raw of float32 buffers without projector, compensation or gaps.
|
|
293
|
+
"""
|
|
294
|
+
if (
|
|
295
|
+
not isinstance(raw, mne.io.Raw)
|
|
296
|
+
or raw.preload
|
|
297
|
+
or len(raw._raw_extras) != 1
|
|
298
|
+
or raw._projector is not None
|
|
299
|
+
or raw._comp is not None
|
|
300
|
+
):
|
|
301
|
+
return None
|
|
302
|
+
extra = raw._raw_extras[0]
|
|
303
|
+
fname, bounds = extra["filename"], extra["bounds"]
|
|
304
|
+
if not isinstance(fname, Path) or fname.suffix == ".gz":
|
|
305
|
+
return None
|
|
306
|
+
start, stop = start + raw._first_samps[0], stop + raw._first_samps[0]
|
|
307
|
+
first = np.searchsorted(bounds, start, side="right") - 1
|
|
308
|
+
tags = extra["ent"]
|
|
309
|
+
if isinstance(tags, _FifTagTable):
|
|
310
|
+
rows = tags.table[first : np.searchsorted(bounds, stop)]
|
|
311
|
+
else:
|
|
312
|
+
tags = tags[first : np.searchsorted(bounds, stop)]
|
|
313
|
+
if any(t is None for t in tags):
|
|
314
|
+
return None
|
|
315
|
+
rows = _tag_rows(tags)
|
|
316
|
+
if not len(rows) or (rows[:, 1] != FIFF.FIFFT_FLOAT).any():
|
|
317
|
+
return None
|
|
318
|
+
size, pos = rows[:, 2].tolist(), rows[:, 4].tolist()
|
|
319
|
+
# mmap: no copy through a 4 MB read buffer, and a cold file is read around
|
|
320
|
+
# the window by the kernel (as mne's 4 MB reads did), not window by window
|
|
321
|
+
with open(fname, "rb") as f, mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m:
|
|
322
|
+
buf = m[pos[0] : pos[-1] + 16 + size[-1]]
|
|
323
|
+
one = np.concatenate(
|
|
324
|
+
[np.frombuffer(buf, ">f4", s // 4, p + 16 - pos[0]) for s, p in zip(size, pos)]
|
|
325
|
+
).reshape(-1, extra["orig_nchan"])[start - bounds[first] : stop - bounds[first]]
|
|
326
|
+
picked = one[:, raw._read_picks[0]].T
|
|
327
|
+
return np.multiply(picked, raw._cals[:, np.newaxis], order="C")
|
|
328
|
+
|
|
329
|
+
|
|
223
330
|
def _window_info(crop_inds, sfreq):
|
|
224
331
|
"""Extract window size from crop indices.
|
|
225
332
|
|
|
@@ -823,9 +930,11 @@ class EEGWindowsDataset(_ZarrMixin, RecordDataset):
|
|
|
823
930
|
if self._zarr_data is not None:
|
|
824
931
|
X = self._zarr_data[:, i_start:i_stop]
|
|
825
932
|
else:
|
|
826
|
-
X = self.raw
|
|
827
|
-
|
|
828
|
-
|
|
933
|
+
X = _read_fif_window(self.raw, i_start, i_stop)
|
|
934
|
+
if X is None:
|
|
935
|
+
X = self.raw._getitem(
|
|
936
|
+
(slice(None), slice(i_start, i_stop)), return_times=False
|
|
937
|
+
)
|
|
829
938
|
X = np.array(X, dtype="float32")
|
|
830
939
|
if self.transform is not None:
|
|
831
940
|
X = self.transform(X)
|
|
@@ -1672,7 +1781,8 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1672
1781
|
kwargs_path = os.path.join(path, ".".join([kwarg_name, "json"]))
|
|
1673
1782
|
kwargs = getattr(self, kwarg_name)
|
|
1674
1783
|
if kwargs is not None:
|
|
1675
|
-
|
|
1784
|
+
with open(kwargs_path, "w") as f:
|
|
1785
|
+
json.dump(kwargs, f)
|
|
1676
1786
|
|
|
1677
1787
|
@property
|
|
1678
1788
|
def description(self) -> pd.DataFrame:
|
|
@@ -1742,7 +1852,10 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1742
1852
|
# Create path if it doesn't exist
|
|
1743
1853
|
os.makedirs(path, exist_ok=True)
|
|
1744
1854
|
|
|
1745
|
-
|
|
1855
|
+
# With an offset the caller fills one directory piece by piece (preprocess
|
|
1856
|
+
# saves each recording at its index), so the other entries are expected:
|
|
1857
|
+
# skip the scan that would stat them all on every call and list them in a warning.
|
|
1858
|
+
path_contents = os.listdir(path) if offset == 0 else []
|
|
1746
1859
|
n_sub_dirs = len(
|
|
1747
1860
|
[e for e in path_contents if os.path.isdir(os.path.join(path, e))]
|
|
1748
1861
|
)
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/datasets/tuh.py
RENAMED
|
@@ -241,7 +241,11 @@ class TUH(BaseConcatDataset):
|
|
|
241
241
|
# file paths, use this instead as before
|
|
242
242
|
if "year" in description:
|
|
243
243
|
meas_date = meas_date.replace(*description[["year", "month", "day"]])
|
|
244
|
-
|
|
244
|
+
# FIF (e.g. preprocess(..., save_dir=...)) stores dates from 1901-12-13 to
|
|
245
|
+
# 2038-01-19 only: undated recordings (year 1 above) and de-identified ones
|
|
246
|
+
# (TUAB has 1899-12-30) keep their date in the description only.
|
|
247
|
+
in_fif_range = -(2**31) <= meas_date.timestamp() < 2**31
|
|
248
|
+
raw.set_meas_date(meas_date if in_fif_range else None)
|
|
245
249
|
|
|
246
250
|
d = {
|
|
247
251
|
"age": int(age),
|
|
@@ -251,9 +255,9 @@ class TUH(BaseConcatDataset):
|
|
|
251
255
|
# if not, get it from meas_date in raw.info and add to description
|
|
252
256
|
# if meas_date is None, create fake one
|
|
253
257
|
if "year" not in description:
|
|
254
|
-
d["year"] =
|
|
255
|
-
d["month"] =
|
|
256
|
-
d["day"] =
|
|
258
|
+
d["year"] = meas_date.year
|
|
259
|
+
d["month"] = meas_date.month
|
|
260
|
+
d["day"] = meas_date.day
|
|
257
261
|
|
|
258
262
|
# read info relevant for preprocessing from raw without loading it
|
|
259
263
|
if add_physician_reports:
|
|
@@ -21,6 +21,7 @@ from ..datasets.base import (
|
|
|
21
21
|
EEGWindowsDataset,
|
|
22
22
|
RawDataset,
|
|
23
23
|
WindowsDataset,
|
|
24
|
+
_compact_fif_tags,
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
|
|
@@ -79,7 +80,8 @@ def _outdated_load_concat_dataset(path, preload, ids_to_load=None, target_name=N
|
|
|
79
80
|
for path in paths:
|
|
80
81
|
if is_raw and target_name is None:
|
|
81
82
|
target_file_name = path / "target_name.json"
|
|
82
|
-
|
|
83
|
+
with open(target_file_name) as f:
|
|
84
|
+
target_name = json.load(f)["target_name"]
|
|
83
85
|
|
|
84
86
|
all_signals, description = _load_signals_and_description(
|
|
85
87
|
path=path, preload=preload, is_raw=is_raw, ids_to_load=ids_to_load
|
|
@@ -141,7 +143,7 @@ def _load_signals(fif_file, preload, is_raw):
|
|
|
141
143
|
if all(Path(f).exists() for f in signals.filenames):
|
|
142
144
|
if preload:
|
|
143
145
|
signals.load_data()
|
|
144
|
-
return signals
|
|
146
|
+
return _compact_fif_tags(signals)
|
|
145
147
|
else: # This may happen if the file has been moved together with the pickle file.
|
|
146
148
|
warnings.warn(
|
|
147
149
|
f"Pickle file {pkl_file} exists, but the referenced fif "
|
|
@@ -171,7 +173,8 @@ def _load_signals(fif_file, preload, is_raw):
|
|
|
171
173
|
if preload:
|
|
172
174
|
signals._data, signals.preload = data, True
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
# after the pickle above, which keeps mne's own layout on disk
|
|
177
|
+
return _compact_fif_tags(signals)
|
|
175
178
|
|
|
176
179
|
|
|
177
180
|
def load_concat_dataset(path, preload, ids_to_load=None, target_name=None, n_jobs=1):
|
|
@@ -264,7 +267,8 @@ def _load_parallel(path, i, preload, is_raw, has_stored_windows):
|
|
|
264
267
|
target_file_path = sub_dir / "target_name.json"
|
|
265
268
|
target_name = None
|
|
266
269
|
if target_file_path.exists():
|
|
267
|
-
|
|
270
|
+
with open(target_file_path) as f:
|
|
271
|
+
target_name = json.load(f)["target_name"]
|
|
268
272
|
|
|
269
273
|
if is_raw and (not has_stored_windows):
|
|
270
274
|
dataset = RawDataset(signals, description, target_name)
|
|
@@ -304,8 +308,8 @@ def _load_kwargs_json(kwargs_name, sub_dir):
|
|
|
304
308
|
kwargs_file_name = ".".join([kwargs_name, "json"])
|
|
305
309
|
kwargs_file_path = os.path.join(sub_dir, kwargs_file_name)
|
|
306
310
|
if os.path.exists(kwargs_file_path):
|
|
307
|
-
|
|
308
|
-
|
|
311
|
+
with open(kwargs_file_path) as f:
|
|
312
|
+
return json.load(f)
|
|
309
313
|
|
|
310
314
|
|
|
311
315
|
def _is_outdated_saved(path):
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/attn_sleep.py
RENAMED
|
@@ -143,6 +143,10 @@ class AttnSleep(EEGModuleMixin, nn.Module):
|
|
|
143
143
|
sfreq=sfreq,
|
|
144
144
|
)
|
|
145
145
|
del n_outputs, n_chans, chs_info, n_times, input_window_seconds, sfreq
|
|
146
|
+
if self._n_chans_for_jit not in (None, 1):
|
|
147
|
+
raise ValueError(
|
|
148
|
+
f"AttnSleep takes single-channel input; got n_chans={self._n_chans_for_jit}."
|
|
149
|
+
)
|
|
146
150
|
|
|
147
151
|
self.mapping = {
|
|
148
152
|
"fc.weight": "final_layer.weight",
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/base.py
RENAMED
|
@@ -46,6 +46,24 @@ _GEOMETRY_KWARGS = (
|
|
|
46
46
|
)
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
def _too_short_input_error(exc: RuntimeError, input_shape) -> Optional[ValueError]:
|
|
50
|
+
"""ValueError for a layer that found the input too short, else None."""
|
|
51
|
+
if not str(exc).endswith(
|
|
52
|
+
(
|
|
53
|
+
"Output size is too small",
|
|
54
|
+
"Kernel size can't be greater than actual input size",
|
|
55
|
+
)
|
|
56
|
+
):
|
|
57
|
+
return None
|
|
58
|
+
return ValueError(
|
|
59
|
+
"During model prediction RuntimeError was thrown showing that at some "
|
|
60
|
+
f"layer `{str(exc).split('.')[-1]}` (see above in the stacktrace). This "
|
|
61
|
+
"could be caused by providing too small `n_times`/`input_window_seconds`. "
|
|
62
|
+
"Model may require longer chunks of signal in the input than "
|
|
63
|
+
f"{input_shape}."
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
49
67
|
_HF_INSTALL_HINT = (
|
|
50
68
|
"requires the `huggingface_hub` package. "
|
|
51
69
|
"Install with: pip install 'braindecode[hub]'"
|
|
@@ -483,6 +501,18 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
483
501
|
# Called by torch.jit.script before compiling the model.
|
|
484
502
|
return make_parametrizations_scriptable(self)
|
|
485
503
|
|
|
504
|
+
def __call__(self, *args, **kwargs):
|
|
505
|
+
# An input shorter than the layers need raises ValueError, not a torch
|
|
506
|
+
# RuntimeError from deep inside forward.
|
|
507
|
+
try:
|
|
508
|
+
return super().__call__(*args, **kwargs)
|
|
509
|
+
except RuntimeError as exc:
|
|
510
|
+
shape = tuple(args[0].shape) if args and hasattr(args[0], "shape") else None
|
|
511
|
+
error = _too_short_input_error(exc, shape)
|
|
512
|
+
if error is None:
|
|
513
|
+
raise
|
|
514
|
+
raise error from exc
|
|
515
|
+
|
|
486
516
|
def get_output_shape(self) -> tuple[int, ...]:
|
|
487
517
|
"""Returns shape of neural network output for batch size equal 1.
|
|
488
518
|
|
|
@@ -506,21 +536,10 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
506
536
|
.shape
|
|
507
537
|
)
|
|
508
538
|
except RuntimeError as exc:
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
)
|
|
514
|
-
):
|
|
515
|
-
msg = (
|
|
516
|
-
"During model prediction RuntimeError was thrown showing that at some "
|
|
517
|
-
f"layer `{str(exc).split('.')[-1]}` (see above in the stacktrace). This "
|
|
518
|
-
"could be caused by providing too small `n_times`/`input_window_seconds`. "
|
|
519
|
-
"Model may require longer chunks of signal in the input than "
|
|
520
|
-
f"{self.input_shape}."
|
|
521
|
-
)
|
|
522
|
-
raise ValueError(msg) from exc
|
|
523
|
-
raise exc
|
|
539
|
+
error = _too_short_input_error(exc, self.input_shape)
|
|
540
|
+
if error is None:
|
|
541
|
+
raise
|
|
542
|
+
raise error from exc
|
|
524
543
|
|
|
525
544
|
def get_config(self) -> dict:
|
|
526
545
|
"""Return a JSON-serializable dict of all ``__init__`` parameters.
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/brainomni.py
RENAMED
|
@@ -29,15 +29,21 @@ from braindecode.modules.quantization import ResidualVectorQuantizer
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
class _SELU(nn.SELU):
|
|
32
|
-
"""``nn.SELU``
|
|
33
|
-
trainable on Gaudi, whose ELU backward only
|
|
32
|
+
"""``nn.SELU`` as ``ELU(x, alpha * scale)`` times ``scale`` where ``x > 0``:
|
|
33
|
+
same values and gradients, and trainable on Gaudi, whose ELU backward only
|
|
34
|
+
supports ``scale == 1``."""
|
|
34
35
|
|
|
35
36
|
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
36
37
|
alpha, scale = (
|
|
37
38
|
1.6732632423543772848170429916717,
|
|
38
39
|
1.0507009873554804934193349852946,
|
|
39
40
|
)
|
|
40
|
-
|
|
41
|
+
# ELU is x on the positive side, so this equals the where(x > 0, x * scale,
|
|
42
|
+
# elu) form bit for bit, without its zero-filled where backward. The
|
|
43
|
+
# factor is at least float32, like the scalar multiply's compute type.
|
|
44
|
+
one = x.new_ones((), dtype=torch.promote_types(x.dtype, torch.float32))
|
|
45
|
+
factor = torch.where(x > 0, one * scale, one)
|
|
46
|
+
return (F.elu(x, alpha * scale) * factor).to(x.dtype)
|
|
41
47
|
|
|
42
48
|
|
|
43
49
|
class BrainTokenizer(EEGModuleMixin, nn.Module, license="mit"):
|
|
@@ -863,9 +869,13 @@ class _SEANetConv1d(nn.Module):
|
|
|
863
869
|
extra = (kernel_size - padding_total - x.shape[-1]) % stride
|
|
864
870
|
right = padding_total // 2
|
|
865
871
|
padding = (padding_total - right, right + extra)
|
|
872
|
+
if max(padding) == 0: # 1x1 convs: padding would only copy x
|
|
873
|
+
return self.conv(x)
|
|
866
874
|
# Zero-extend a signal too short to reflect, as EnCodec does.
|
|
867
875
|
short = max(max(padding) - x.shape[-1] + 1, 0)
|
|
868
|
-
|
|
876
|
+
if short > 0: # F.pad with nothing to pad still copies x
|
|
877
|
+
x = F.pad(x, (0, short))
|
|
878
|
+
x = F.pad(x, padding, mode="reflect")
|
|
869
879
|
return self.conv(x[..., : x.shape[-1] - short])
|
|
870
880
|
|
|
871
881
|
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/csbrain.py
RENAMED
|
@@ -314,6 +314,11 @@ class CSBrain(EEGModuleMixin, nn.Module):
|
|
|
314
314
|
sfreq=sfreq,
|
|
315
315
|
)
|
|
316
316
|
del n_chans, chs_info, n_times, input_window_seconds, sfreq, n_outputs
|
|
317
|
+
n_times = self._n_times_or_none()
|
|
318
|
+
if n_times is not None and n_times % patch_size:
|
|
319
|
+
raise ValueError(
|
|
320
|
+
f"n_times ({n_times}) must be a multiple of patch_size ({patch_size})."
|
|
321
|
+
)
|
|
317
322
|
|
|
318
323
|
self.rearrange = Rearrange(
|
|
319
324
|
"batch n_chans (n_patch patch_size) -> batch n_chans n_patch patch_size",
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/deep4.py
RENAMED
|
@@ -170,6 +170,10 @@ class Deep4Net(EEGModuleMixin, nn.Sequential):
|
|
|
170
170
|
):
|
|
171
171
|
resolved_n_times = round(self._input_window_seconds * self._sfreq)
|
|
172
172
|
|
|
173
|
+
if resolved_n_times is not None and resolved_n_times >= min_n_times:
|
|
174
|
+
# The bound above ignores stride_before_pool and an integer
|
|
175
|
+
# final_conv_length; inputs it admits are checked with the exact one.
|
|
176
|
+
min_n_times = self._get_min_n_times(exact=True)
|
|
173
177
|
if resolved_n_times is not None and resolved_n_times < min_n_times:
|
|
174
178
|
scaling_factor = resolved_n_times / min_n_times
|
|
175
179
|
warn(
|
|
@@ -363,13 +367,15 @@ class Deep4Net(EEGModuleMixin, nn.Sequential):
|
|
|
363
367
|
|
|
364
368
|
self.train()
|
|
365
369
|
|
|
366
|
-
def _get_min_n_times(self) -> int:
|
|
370
|
+
def _get_min_n_times(self, exact: bool = False) -> int:
|
|
367
371
|
"""
|
|
368
372
|
Calculate the minimum number of time samples required for the model
|
|
369
373
|
to work with the given temporal parameters.
|
|
370
374
|
"""
|
|
371
375
|
# Start with the minimum valid output length of the network (1)
|
|
372
376
|
min_len = 1
|
|
377
|
+
if exact and isinstance(self.final_conv_length, int):
|
|
378
|
+
min_len = self.final_conv_length
|
|
373
379
|
|
|
374
380
|
# List of conv kernel sizes and pool parameters for the 4 blocks, in reverse order
|
|
375
381
|
# Each tuple: (filter_length, pool_length, pool_stride)
|
|
@@ -382,6 +388,9 @@ class Deep4Net(EEGModuleMixin, nn.Sequential):
|
|
|
382
388
|
|
|
383
389
|
# Work backward from the last layer to the input
|
|
384
390
|
for filter_len, pool_len, pool_stride in block_params:
|
|
391
|
+
if exact and self.stride_before_pool: # strided conv, then pool stride 1
|
|
392
|
+
min_len = pool_stride * (min_len + pool_len - 2) + filter_len
|
|
393
|
+
continue
|
|
385
394
|
# Reverse the pooling operation
|
|
386
395
|
# L_in = stride * (L_out - 1) + kernel_size
|
|
387
396
|
min_len = pool_stride * (min_len - 1) + pool_len
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/dgcnn.py
RENAMED
|
@@ -142,6 +142,11 @@ def _build_initial_adjacency(chs_info, n_chans, n_neighbors=5):
|
|
|
142
142
|
electrode_positions = extract_channel_locations_from_chs_info(
|
|
143
143
|
chs_info, num_channels=n_chans
|
|
144
144
|
)
|
|
145
|
+
# MNE stores NaN for a channel without a position.
|
|
146
|
+
if electrode_positions is not None and not (
|
|
147
|
+
len(electrode_positions) == n_chans and np.isfinite(electrode_positions).all()
|
|
148
|
+
):
|
|
149
|
+
electrode_positions = None
|
|
145
150
|
|
|
146
151
|
if electrode_positions is None and chs_info is not None:
|
|
147
152
|
# Try to infer positions from channel names via a standard montage
|
|
@@ -162,6 +167,8 @@ def _build_initial_adjacency(chs_info, n_chans, n_neighbors=5):
|
|
|
162
167
|
"with 3-D positions or that channel names match a standard montage."
|
|
163
168
|
)
|
|
164
169
|
|
|
170
|
+
if n_chans < 2:
|
|
171
|
+
raise ValueError("DGCNN needs at least 2 channels to build its channel graph.")
|
|
165
172
|
n_neighbors_capped = min(n_neighbors, n_chans - 1)
|
|
166
173
|
|
|
167
174
|
# Pairwise Euclidean distances
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegconformer.py
RENAMED
|
@@ -7,7 +7,7 @@ import torch
|
|
|
7
7
|
from einops.layers.torch import Rearrange
|
|
8
8
|
from torch import Tensor, nn
|
|
9
9
|
|
|
10
|
-
from braindecode.models.base import EEGModuleMixin
|
|
10
|
+
from braindecode.models.base import EEGModuleMixin, _too_short_input_error
|
|
11
11
|
from braindecode.modules import FeedForwardBlock, MultiHeadAttention
|
|
12
12
|
|
|
13
13
|
|
|
@@ -276,7 +276,10 @@ class EEGConformer(EEGModuleMixin, nn.Module):
|
|
|
276
276
|
return x
|
|
277
277
|
|
|
278
278
|
def get_fc_size(self):
|
|
279
|
-
|
|
279
|
+
try:
|
|
280
|
+
out = self.patch_embedding(torch.ones((1, 1, self.n_chans, self.n_times)))
|
|
281
|
+
except RuntimeError as exc:
|
|
282
|
+
raise _too_short_input_error(exc, self.input_shape) or exc
|
|
280
283
|
size_embedding_1 = out.cpu().data.numpy().shape[1]
|
|
281
284
|
size_embedding_2 = out.cpu().data.numpy().shape[2]
|
|
282
285
|
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/eegnex.py
RENAMED
|
@@ -9,6 +9,7 @@ import torch
|
|
|
9
9
|
import torch.nn as nn
|
|
10
10
|
from einops.layers.torch import Rearrange
|
|
11
11
|
|
|
12
|
+
from braindecode.functional import fft_conv1d, prefer_fft_conv
|
|
12
13
|
from braindecode.models.base import EEGModuleMixin
|
|
13
14
|
from braindecode.modules import Conv2dWithConstraint, LinearWithConstraint
|
|
14
15
|
|
|
@@ -234,7 +235,7 @@ class EEGNeX(EEGModuleMixin, nn.Module):
|
|
|
234
235
|
)
|
|
235
236
|
|
|
236
237
|
self.block_2 = nn.Sequential(
|
|
237
|
-
|
|
238
|
+
_TemporalConv(
|
|
238
239
|
in_channels=self.filter_1,
|
|
239
240
|
out_channels=self.filter_2,
|
|
240
241
|
kernel_size=self.kernel_block_1_2,
|
|
@@ -352,3 +353,17 @@ class EEGNeX(EEGModuleMixin, nn.Module):
|
|
|
352
353
|
self.filter_1 * T5
|
|
353
354
|
) # filter_1 is the number of channels before flatten
|
|
354
355
|
return final_in_features
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
class _TemporalConv(nn.Conv2d):
|
|
359
|
+
"""``(1, k)`` Conv2d with "same" output length; on CPU, through
|
|
360
|
+
:func:`~braindecode.functional.fft_conv1d` where
|
|
361
|
+
:func:`~braindecode.functional.prefer_fft_conv` expects it to be faster."""
|
|
362
|
+
|
|
363
|
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
364
|
+
if not prefer_fft_conv(x, self.kernel_size[1]):
|
|
365
|
+
return self._conv_forward(x, self.weight, self.bias)
|
|
366
|
+
b, _, h, t = x.shape # the conv1d of each of the b * h rows
|
|
367
|
+
x = x.transpose(1, 2).reshape(b * h, -1, t)
|
|
368
|
+
x = fft_conv1d(x, self.weight.squeeze(2), self.bias)
|
|
369
|
+
return x.unflatten(0, [b, h]).transpose(1, 2)
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/labram.py
RENAMED
|
@@ -1416,9 +1416,7 @@ class _Attention(nn.Module):
|
|
|
1416
1416
|
if self.k_norm is not None:
|
|
1417
1417
|
k = self.k_norm(k).type_as(v)
|
|
1418
1418
|
|
|
1419
|
-
|
|
1420
|
-
attn = q @ k.transpose(-2, -1)
|
|
1421
|
-
|
|
1419
|
+
attn_mask: Optional[torch.Tensor] = None
|
|
1422
1420
|
if self.relative_position_bias_table is not None:
|
|
1423
1421
|
relative_position_bias = self.relative_position_bias_table[
|
|
1424
1422
|
self.relative_position_index.view(-1)
|
|
@@ -1427,18 +1425,29 @@ class _Attention(nn.Module):
|
|
|
1427
1425
|
self.window_size[0] * self.window_size[1] + 1,
|
|
1428
1426
|
-1,
|
|
1429
1427
|
) # Wh*Ww,Wh*Ww,nH
|
|
1430
|
-
|
|
1431
|
-
2, 0, 1
|
|
1432
|
-
)
|
|
1433
|
-
attn = attn + relative_position_bias.unsqueeze(0)
|
|
1434
|
-
|
|
1435
|
-
attn = attn.softmax(dim=-1)
|
|
1436
|
-
attn = self.attn_drop(attn)
|
|
1437
|
-
|
|
1438
|
-
if return_attention:
|
|
1439
|
-
return attn
|
|
1428
|
+
attn_mask = (
|
|
1429
|
+
relative_position_bias.permute(2, 0, 1).contiguous().unsqueeze(0)
|
|
1430
|
+
) # 1, nH, Wh*Ww, Wh*Ww
|
|
1440
1431
|
|
|
1441
|
-
|
|
1432
|
+
# Fused kernel, same math. Not on Gaudi (Labram trains ~12 % slower there)
|
|
1433
|
+
# nor with attention dropout in training (it would draw other masks).
|
|
1434
|
+
if (
|
|
1435
|
+
not return_attention
|
|
1436
|
+
and q.device.type != "hpu"
|
|
1437
|
+
and (self.attn_drop.p == 0.0 or not self.training)
|
|
1438
|
+
):
|
|
1439
|
+
x = nn.functional.scaled_dot_product_attention(
|
|
1440
|
+
q, k, v, attn_mask=attn_mask, scale=self.scale
|
|
1441
|
+
)
|
|
1442
|
+
else:
|
|
1443
|
+
attn = (q * self.scale) @ k.transpose(-2, -1)
|
|
1444
|
+
if attn_mask is not None:
|
|
1445
|
+
attn = attn + attn_mask
|
|
1446
|
+
attn = self.attn_drop(attn.softmax(dim=-1))
|
|
1447
|
+
if return_attention:
|
|
1448
|
+
return attn
|
|
1449
|
+
x = attn @ v
|
|
1450
|
+
x = x.transpose(1, 2).reshape(B, N, -1)
|
|
1442
1451
|
|
|
1443
1452
|
x = self.proj(x)
|
|
1444
1453
|
x = self.proj_drop(x)
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/luna.py
RENAMED
|
@@ -423,7 +423,10 @@ class LUNA(EEGModuleMixin, nn.Module, license="apache-2.0"):
|
|
|
423
423
|
channel_info, num_channels=num_channels
|
|
424
424
|
)
|
|
425
425
|
if locs is not None and len(locs) == num_channels:
|
|
426
|
-
|
|
426
|
+
locs = torch.from_numpy(locs).float()
|
|
427
|
+
# MNE stores NaN for a channel without a position.
|
|
428
|
+
if locs.isfinite().all():
|
|
429
|
+
return locs
|
|
427
430
|
|
|
428
431
|
# Fallback: generate default linear spacing along x-axis
|
|
429
432
|
positions = torch.linspace(-1.0, 1.0, steps=num_channels, dtype=torch.float32)
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/medformer.py
RENAMED
|
@@ -411,7 +411,10 @@ class _ListPatchEmbedding(nn.Module):
|
|
|
411
411
|
]
|
|
412
412
|
self.value_embeddings = nn.ModuleList(linear_layers)
|
|
413
413
|
self.position_embedding = _PositionalEmbedding(d_model=d_model)
|
|
414
|
-
|
|
414
|
+
# One row per time sample: windows longer than 5000 samples need more.
|
|
415
|
+
self.channel_embedding = _PositionalEmbedding(
|
|
416
|
+
d_model=seq_len, max_len=max(5000, enc_in)
|
|
417
|
+
)
|
|
415
418
|
self.dropout = nn.Dropout(dropout)
|
|
416
419
|
|
|
417
420
|
self.learnable_embeddings = nn.ParameterList(
|
{braindecode-1.8.1.dev174671102 → braindecode-1.8.1.dev174738705}/braindecode/models/msvtnet.py
RENAMED
|
@@ -7,7 +7,7 @@ import torch
|
|
|
7
7
|
import torch.nn as nn
|
|
8
8
|
from einops.layers.torch import Rearrange
|
|
9
9
|
|
|
10
|
-
from braindecode.models.base import EEGModuleMixin
|
|
10
|
+
from braindecode.models.base import EEGModuleMixin, _too_short_input_error
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class MSVTNet(EEGModuleMixin, nn.Module):
|
|
@@ -152,7 +152,10 @@ class MSVTNet(EEGModuleMixin, nn.Module):
|
|
|
152
152
|
self, cat: bool = True
|
|
153
153
|
) -> Union[torch.Tensor, list[torch.Tensor]]:
|
|
154
154
|
x = torch.randn(1, 1, self.n_chans, self.n_times)
|
|
155
|
-
|
|
155
|
+
try:
|
|
156
|
+
x = [tsconv(x) for tsconv in self.mstsconv]
|
|
157
|
+
except RuntimeError as exc:
|
|
158
|
+
raise _too_short_input_error(exc, self.input_shape) or exc
|
|
156
159
|
if cat:
|
|
157
160
|
x = torch.cat(x, dim=2)
|
|
158
161
|
return x
|