braindecode 2.1.0.dev175175101__tar.gz → 2.1.0.dev181162869__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-2.1.0.dev175175101/braindecode.egg-info → braindecode-2.1.0.dev181162869}/PKG-INFO +2 -1
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/barista.py +8 -2
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/base.py +10 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/biot.py +30 -6
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/brainbert.py +12 -9
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/brant.py +32 -5
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/diver1.py +19 -3
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/epint.py +8 -6
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/labram.py +104 -25
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/luna.py +70 -12
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/mvpformer.py +10 -4
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/popt.py +8 -3
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/reve.py +68 -11
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/linear_attention.py +27 -10
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/util.py +33 -9
- braindecode-2.1.0.dev181162869/braindecode/version.py +1 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869/braindecode.egg-info}/PKG-INFO +2 -1
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode.egg-info/requires.txt +3 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/conf.py +7 -3
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/whats_new.rst +49 -4
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/pyproject.toml +6 -1
- braindecode-2.1.0.dev175175101/braindecode/version.py +0 -1
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/LICENSE.txt +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/MANIFEST.in +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/NOTICE.txt +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/README.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/augmentation/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/augmentation/base.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/augmentation/functional.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/augmentation/transforms.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/classifier.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/base.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/bbci.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/chb_mit.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/collate.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/mne.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/moabb.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/nmt.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/registry.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/siena.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/tuh.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/utils.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datasets/xy.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datautil/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datautil/serialization.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/datautil/util.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/eegneuralnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/functional/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/functional/_lfilter.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/functional/_real_dft.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/functional/attention.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/functional/channel_mask.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/functional/functions.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/functional/initialization.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/functional/patches.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/atcnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/attn_sleep.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/axon.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/bendr.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/brainmodule.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/brainomni.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/cbramod.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/codebrain.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/config.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/contrawr.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/csbrain.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/ctnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/dance.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/deep4.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/dgcnn.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/duin.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eeg_clip.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegconformer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegdino.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eeginception_erp.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eeginception_mi.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegitnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegminer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegnex.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegpt.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegsym.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/emg2qwerty.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/fbcnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/gcnsnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/guetschel2026.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/hybrid.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/ifnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/mapa.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/medformer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/meta_neuromotor.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/mirepnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/mscformer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/msvtnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/neuropose.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/neurorvq.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/neurorvq_tokenizer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/patchedtransformer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/sccnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/sensingdynamics.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/shallow_fbcsp.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/signal_jepa.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/sinc_shallow.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/sleepfm.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/sparcnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/sstdpn.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/steegformer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/summary.csv +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/syncnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/tcformer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/tcn.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/tfm_tokenizer.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/tidnet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/tmsanet.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/tsinception.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/usleep.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/util.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/vemg2pose.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/zuna.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/activation.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/attention.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/blocks.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/channels.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/convolution.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/dance_modules.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/filter.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/layers.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/linear.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/parametrization.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/quantization.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/stats.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/util.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/modules/wrapper.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/preprocessing/preprocess.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/preprocessing/util.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/preprocessing/windowers.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/regressor.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/samplers/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/samplers/base.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/samplers/ssl.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/training/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/training/_trial_aggregation.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/training/callbacks.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/training/losses.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/training/scoring.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/visualization/__init__.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/visualization/activations.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/visualization/attribution.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/visualization/frequency.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/visualization/metrics.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/visualization/sanity.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/visualization/topology.py +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode.egg-info/SOURCES.txt +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/Makefile +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/agent_docs.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/api.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/cite.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/help.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/index.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/install/install.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/install/install_pip.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/install/install_source.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/categorization/attention.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/categorization/channel.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/categorization/spd.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/models.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/models_categorization.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/models_table.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/models/models_visualization.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/sg_execution_times.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/user_guide/channel_strategies.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/docs/user_guide/cropped_inference.rst +0 -0
- {braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/setup.cfg +0 -0
{braindecode-2.1.0.dev175175101/braindecode.egg-info → braindecode-2.1.0.dev181162869}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: braindecode
|
|
3
|
-
Version: 2.1.0.
|
|
3
|
+
Version: 2.1.0.dev181162869
|
|
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>
|
|
@@ -39,6 +39,7 @@ Provides-Extra: moabb
|
|
|
39
39
|
Requires-Dist: moabb>=1.4.3; extra == "moabb"
|
|
40
40
|
Provides-Extra: eegprep
|
|
41
41
|
Requires-Dist: eegprep[eeglabio]>=0.2.23; extra == "eegprep"
|
|
42
|
+
Requires-Dist: torch>=2.7; python_version < "3.12" and extra == "eegprep"
|
|
42
43
|
Provides-Extra: hub
|
|
43
44
|
Requires-Dist: huggingface_hub[torch]>=0.20.0; extra == "hub"
|
|
44
45
|
Requires-Dist: zarr>=3.1; extra == "hub"
|
{braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/barista.py
RENAMED
|
@@ -449,7 +449,9 @@ class BaRISTA(EEGModuleMixin, nn.Module, license="other"):
|
|
|
449
449
|
-------
|
|
450
450
|
torch.Tensor or dict
|
|
451
451
|
Logits of shape ``(batch, n_outputs)``, or a dictionary containing
|
|
452
|
-
``features`` of shape ``(batch, d_model)
|
|
452
|
+
``features`` of shape ``(batch, d_model)``, ``cls_token=None`` and
|
|
453
|
+
``tokens``, the backbone output ``(batch, n_chans, n_patches,
|
|
454
|
+
d_model)``, zero for padded channels.
|
|
453
455
|
"""
|
|
454
456
|
if x.ndim != 3:
|
|
455
457
|
raise ValueError("Expected input of shape (batch, n_chans, n_times).")
|
|
@@ -506,7 +508,11 @@ class BaRISTA(EEGModuleMixin, nn.Module, license="other"):
|
|
|
506
508
|
else:
|
|
507
509
|
features = masked_mean(latents, token_mask, [1])
|
|
508
510
|
if not torch.jit.is_scripting() and return_features:
|
|
509
|
-
|
|
511
|
+
# Patch-major tokens -> (batch, n_chans, n_patches, d_model).
|
|
512
|
+
tokens = latents.unflatten(1, (n_patches, n_chans)).transpose(1, 2)
|
|
513
|
+
if mask is not None:
|
|
514
|
+
tokens = tokens.masked_fill(~mask[:, :, None, None], 0.0)
|
|
515
|
+
return {"features": features, "cls_token": None, "tokens": tokens}
|
|
510
516
|
return self.final_layer(features)
|
|
511
517
|
|
|
512
518
|
|
{braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/base.py
RENAMED
|
@@ -484,6 +484,16 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
484
484
|
def _channel_forward(self, *args, chs_info=None, ch_names=None, **kwargs):
|
|
485
485
|
"""``forward`` under a channel strategy: map ``x`` (recorded with
|
|
486
486
|
``chs_info``, default the model's) onto the target, then run the backbone."""
|
|
487
|
+
bound = inspect.signature(type(self).forward).bind_partial(
|
|
488
|
+
self, *args, **kwargs
|
|
489
|
+
)
|
|
490
|
+
if bound.arguments.get("ch_mask") is not None:
|
|
491
|
+
# The channel layer mixes every input channel into each target one,
|
|
492
|
+
# so padding would leak into the real channels.
|
|
493
|
+
raise ValueError(
|
|
494
|
+
"ch_mask needs channel_strategy='native': the channel layer maps "
|
|
495
|
+
"all input channels, padded ones included, onto the target montage."
|
|
496
|
+
)
|
|
487
497
|
if chs_info is None and ch_names is not None: # LaBraM: names of x's channels
|
|
488
498
|
chs_info = [{"ch_name": n} for n in ch_names]
|
|
489
499
|
if args:
|
{braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/biot.py
RENAMED
|
@@ -4,7 +4,7 @@ from warnings import warn
|
|
|
4
4
|
import torch
|
|
5
5
|
import torch.nn as nn
|
|
6
6
|
|
|
7
|
-
from braindecode.functional import spectral_input
|
|
7
|
+
from braindecode.functional import check_ch_mask, masked_mean, spectral_input
|
|
8
8
|
from braindecode.models.base import EEGModuleMixin
|
|
9
9
|
from braindecode.models.util import warn_if_sfreq_differs
|
|
10
10
|
from braindecode.modules import SinusoidalPositionalEncoding
|
|
@@ -239,7 +239,10 @@ class BIOT(EEGModuleMixin, nn.Module):
|
|
|
239
239
|
)
|
|
240
240
|
|
|
241
241
|
def forward(
|
|
242
|
-
self,
|
|
242
|
+
self,
|
|
243
|
+
x: torch.Tensor,
|
|
244
|
+
return_features: bool = False,
|
|
245
|
+
ch_mask: Optional[torch.Tensor] = None,
|
|
243
246
|
) -> Union[
|
|
244
247
|
torch.Tensor,
|
|
245
248
|
Tuple[torch.Tensor, torch.Tensor],
|
|
@@ -256,6 +259,10 @@ class BIOT(EEGModuleMixin, nn.Module):
|
|
|
256
259
|
return_features : bool
|
|
257
260
|
If True, return a dict with ``"features"`` and ``"cls_token"``
|
|
258
261
|
instead of the classification output.
|
|
262
|
+
ch_mask : torch.Tensor, optional
|
|
263
|
+
``(batch, n_chans)`` mask of real channels, see
|
|
264
|
+
:func:`~braindecode.functional.check_ch_mask`. Padded channels are
|
|
265
|
+
never attended to nor pooled; channel tokens follow the position.
|
|
259
266
|
|
|
260
267
|
Returns
|
|
261
268
|
-------
|
|
@@ -266,7 +273,7 @@ class BIOT(EEGModuleMixin, nn.Module):
|
|
|
266
273
|
If legacy ``return_feature=True`` (init param):
|
|
267
274
|
``(out, emb)`` tuple (ignored when ``return_features=True``).
|
|
268
275
|
"""
|
|
269
|
-
emb = self.encoder(x)
|
|
276
|
+
emb = self.encoder(x, ch_mask=check_ch_mask(ch_mask, x))
|
|
270
277
|
|
|
271
278
|
if return_features:
|
|
272
279
|
out: Dict[str, Optional[torch.Tensor]] = {
|
|
@@ -462,7 +469,13 @@ class _BIOTEncoder(nn.Module):
|
|
|
462
469
|
)
|
|
463
470
|
return torch.abs(spectral).to(sample)
|
|
464
471
|
|
|
465
|
-
def forward(
|
|
472
|
+
def forward(
|
|
473
|
+
self,
|
|
474
|
+
x,
|
|
475
|
+
n_channel_offset: int = 0,
|
|
476
|
+
perturb: bool = False,
|
|
477
|
+
ch_mask: Optional[torch.Tensor] = None,
|
|
478
|
+
):
|
|
466
479
|
"""
|
|
467
480
|
Forward pass of the BIOT encoder.
|
|
468
481
|
|
|
@@ -493,6 +506,9 @@ class _BIOTEncoder(nn.Module):
|
|
|
493
506
|
perturb: bool (default False)
|
|
494
507
|
Randomly select a number of time steps and reduce the
|
|
495
508
|
channel embedding to those time steps.
|
|
509
|
+
ch_mask: Tensor, optional
|
|
510
|
+
(batch_size, n_channels) boolean mask of real channels, already
|
|
511
|
+
checked.
|
|
496
512
|
|
|
497
513
|
Returns
|
|
498
514
|
-------
|
|
@@ -500,11 +516,15 @@ class _BIOTEncoder(nn.Module):
|
|
|
500
516
|
(batch_size, emb_size)
|
|
501
517
|
"""
|
|
502
518
|
batch_size, n_chans, n_times = x.shape
|
|
519
|
+
if ch_mask is not None:
|
|
520
|
+
# Padding may hold NaN, which the STFT would spread.
|
|
521
|
+
x = x.masked_fill(~ch_mask[:, :, None], 0.0)
|
|
503
522
|
# One spectrogram for all channels, channel-major so that each
|
|
504
523
|
# channel's (batch, freq, ts) block is contiguous
|
|
505
524
|
spec = self.stft(x.transpose(0, 1).reshape(n_chans * batch_size, 1, n_times))
|
|
506
525
|
spec = spec.unflatten(0, [n_chans, batch_size])
|
|
507
526
|
emb_seq = []
|
|
527
|
+
token_masks = []
|
|
508
528
|
for i in range(n_chans):
|
|
509
529
|
# Getting the spectrogram
|
|
510
530
|
channel_spec_emb = spec[i]
|
|
@@ -543,10 +563,14 @@ class _BIOTEncoder(nn.Module):
|
|
|
543
563
|
selected_ts = torch.randperm(ts)[:ts_new]
|
|
544
564
|
channel_emb = channel_emb[:, selected_ts]
|
|
545
565
|
emb_seq.append(channel_emb)
|
|
566
|
+
if ch_mask is not None:
|
|
567
|
+
token_masks.append(ch_mask[:, i, None].expand(-1, channel_emb.shape[1]))
|
|
546
568
|
|
|
547
569
|
# Concat and transformer
|
|
548
570
|
# (batch_size, 16 * ts, emb)
|
|
549
571
|
emb = torch.cat(emb_seq, dim=1)
|
|
572
|
+
token_mask: Optional[torch.Tensor] = None
|
|
573
|
+
if ch_mask is not None:
|
|
574
|
+
token_mask = torch.cat(token_masks, dim=1)
|
|
550
575
|
# (batch_size, emb)
|
|
551
|
-
|
|
552
|
-
return emb
|
|
576
|
+
return masked_mean(self.transformer(emb, token_mask), token_mask, [1])
|
{braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/brainbert.py
RENAMED
|
@@ -288,11 +288,13 @@ class BrainBERT(EEGModuleMixin, nn.Module, license="unknown"):
|
|
|
288
288
|
from the construction one.
|
|
289
289
|
return_features : bool
|
|
290
290
|
If ``True``, return the pooled encoder embedding instead of the
|
|
291
|
-
class logits, as ``{"features": pooled, "cls_token": None
|
|
292
|
-
(braindecode foundation-model convention).
|
|
293
|
-
centre frames and then the channels, and has no
|
|
294
|
-
``cls_token`` is ``None``.
|
|
295
|
-
|
|
291
|
+
class logits, as ``{"features": pooled, "cls_token": None,
|
|
292
|
+
"tokens": tokens}`` (braindecode foundation-model convention).
|
|
293
|
+
BrainBERT pools the centre frames and then the channels, and has no
|
|
294
|
+
class token, hence ``cls_token`` is ``None``. ``tokens`` is the
|
|
295
|
+
encoder output of every frame, ``(batch, n_chans, n_frames,
|
|
296
|
+
hidden_dim)``, zero for padded channels. A scripted model
|
|
297
|
+
(``torch.jit.script``) ignores this flag and always returns the logits.
|
|
296
298
|
ch_mask : torch.Tensor, optional
|
|
297
299
|
``(batch, n_chans)`` mask of real channels, see
|
|
298
300
|
:func:`~braindecode.functional.check_ch_mask`. Padded channels are dropped first.
|
|
@@ -301,7 +303,7 @@ class BrainBERT(EEGModuleMixin, nn.Module, license="unknown"):
|
|
|
301
303
|
-------
|
|
302
304
|
torch.Tensor or dict
|
|
303
305
|
Class logits of shape ``(batch, n_outputs)``, or the feature dict
|
|
304
|
-
``{"features", "cls_token"}`` when ``return_features`` is set.
|
|
306
|
+
``{"features", "cls_token", "tokens"}`` when ``return_features`` is set.
|
|
305
307
|
"""
|
|
306
308
|
mask = check_ch_mask(ch_mask, x)
|
|
307
309
|
n_chans = x.shape[1]
|
|
@@ -324,16 +326,17 @@ class BrainBERT(EEGModuleMixin, nn.Module, license="unknown"):
|
|
|
324
326
|
z = self.transformer(h) # (n_real, n_frames, hidden_dim)
|
|
325
327
|
|
|
326
328
|
# 3. pool the centre frames, then frames and real channels.
|
|
329
|
+
tokens = unpack_channels(z, mask, n_chans) # (batch, n_chans, frames, hidden)
|
|
330
|
+
z = tokens
|
|
327
331
|
if self.pool_n_frames is not None:
|
|
328
332
|
start = n_frames // 2 - self.pool_n_frames // 2
|
|
329
|
-
z = z[:, start : start + self.pool_n_frames]
|
|
330
|
-
z = unpack_channels(z, mask, n_chans) # (batch, n_chans, frames, hidden_dim)
|
|
333
|
+
z = z[:, :, start : start + self.pool_n_frames]
|
|
331
334
|
pooled = masked_mean(z, mask, [1, 2]) # (batch, hidden_dim)
|
|
332
335
|
logits = self.final_layer(pooled)
|
|
333
336
|
if return_features:
|
|
334
337
|
if torch.jit.is_scripting():
|
|
335
338
|
return logits
|
|
336
|
-
return {"features": pooled, "cls_token": None
|
|
339
|
+
return {"features": pooled, "cls_token": None, "tokens": tokens}
|
|
337
340
|
return logits
|
|
338
341
|
|
|
339
342
|
|
{braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/brant.py
RENAMED
|
@@ -133,6 +133,9 @@ class Brant(EEGModuleMixin, nn.Module, license="apache-2.0"):
|
|
|
133
133
|
"braindecode/brant-pretrained", n_outputs=2
|
|
134
134
|
)
|
|
135
135
|
|
|
136
|
+
A shorter ``n_times`` keeps the checkpoint's leading temporal
|
|
137
|
+
positions.
|
|
138
|
+
|
|
136
139
|
.. versionadded:: 2.0
|
|
137
140
|
|
|
138
141
|
Parameters
|
|
@@ -285,6 +288,25 @@ class Brant(EEGModuleMixin, nn.Module, license="apache-2.0"):
|
|
|
285
288
|
head = nn.Linear(self.final_layer.in_features, n_outputs)
|
|
286
289
|
self.final_layer = head.to(self.final_layer.weight)
|
|
287
290
|
|
|
291
|
+
def load_state_dict(self, state_dict, *args, **kwargs):
|
|
292
|
+
"""Also accept a checkpoint saved at a longer ``n_times``.
|
|
293
|
+
|
|
294
|
+
Its learned temporal positions are cropped to this model's
|
|
295
|
+
``seq_len`` leading ones.
|
|
296
|
+
"""
|
|
297
|
+
key = "temporal_encoder.input_embedding.positional_encoding"
|
|
298
|
+
positions = state_dict.get(key)
|
|
299
|
+
if positions is not None and len(positions) < self.seq_len:
|
|
300
|
+
raise ValueError(
|
|
301
|
+
f"The checkpoint holds {len(positions)} temporal positions, but "
|
|
302
|
+
f"n_times={self.n_times} spans {self.seq_len} patches of "
|
|
303
|
+
f"{self.patch_size} samples; use n_times <= "
|
|
304
|
+
f"{len(positions) * self.patch_size}."
|
|
305
|
+
)
|
|
306
|
+
if positions is not None:
|
|
307
|
+
state_dict = {**state_dict, key: positions[: self.seq_len]}
|
|
308
|
+
return super().load_state_dict(state_dict, *args, **kwargs)
|
|
309
|
+
|
|
288
310
|
def forward(
|
|
289
311
|
self,
|
|
290
312
|
x: torch.Tensor,
|
|
@@ -300,9 +322,11 @@ class Brant(EEGModuleMixin, nn.Module, license="apache-2.0"):
|
|
|
300
322
|
from the construction one.
|
|
301
323
|
return_features : bool
|
|
302
324
|
If ``True``, return the pooled encoder embedding instead of the
|
|
303
|
-
class logits, as ``{"features": pooled, "cls_token": None
|
|
304
|
-
(braindecode foundation-model convention). Brant
|
|
305
|
-
and patches and has no class token, hence
|
|
325
|
+
class logits, as ``{"features": pooled, "cls_token": None,
|
|
326
|
+
"tokens": tokens}`` (braindecode foundation-model convention). Brant
|
|
327
|
+
pools over channels and patches and has no class token, hence
|
|
328
|
+
``cls_token`` is ``None``. ``tokens`` is the spatial encoder output,
|
|
329
|
+
``(batch, n_chans, seq_len, embed_dim)``, zero for padded channels.
|
|
306
330
|
A TorchScript-compiled model returns the logits instead.
|
|
307
331
|
ch_mask : torch.Tensor, optional
|
|
308
332
|
``(batch, n_chans)`` mask of real channels, see
|
|
@@ -312,7 +336,8 @@ class Brant(EEGModuleMixin, nn.Module, license="apache-2.0"):
|
|
|
312
336
|
-------
|
|
313
337
|
torch.Tensor or dict
|
|
314
338
|
Class logits of shape ``(batch, n_outputs)``, or the feature
|
|
315
|
-
dict ``{"features", "cls_token"}`` when ``return_features``
|
|
339
|
+
dict ``{"features", "cls_token", "tokens"}`` when ``return_features``
|
|
340
|
+
is set.
|
|
316
341
|
"""
|
|
317
342
|
if x.shape[-1] != self.n_times:
|
|
318
343
|
raise ValueError(
|
|
@@ -345,7 +370,9 @@ class Brant(EEGModuleMixin, nn.Module, license="apache-2.0"):
|
|
|
345
370
|
if return_features:
|
|
346
371
|
if torch.jit.is_scripting():
|
|
347
372
|
return logits
|
|
348
|
-
|
|
373
|
+
if mask is not None:
|
|
374
|
+
emb = emb.masked_fill(~mask[:, :, None, None], 0.0)
|
|
375
|
+
return {"features": pooled, "cls_token": None, "tokens": emb}
|
|
349
376
|
return logits
|
|
350
377
|
|
|
351
378
|
|
{braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/diver1.py
RENAMED
|
@@ -365,7 +365,8 @@ class DIVER1(EEGModuleMixin, nn.Module, license="apache-2.0"):
|
|
|
365
365
|
x: torch.Tensor,
|
|
366
366
|
chan_metadata: torch.Tensor | None = None,
|
|
367
367
|
ch_mask: torch.Tensor | None = None,
|
|
368
|
-
|
|
368
|
+
return_features: bool = False,
|
|
369
|
+
) -> torch.Tensor | dict[str, torch.Tensor | None]:
|
|
369
370
|
"""Encode an iEEG batch into class logits.
|
|
370
371
|
|
|
371
372
|
Parameters
|
|
@@ -385,11 +386,17 @@ class DIVER1(EEGModuleMixin, nn.Module, license="apache-2.0"):
|
|
|
385
386
|
``(batch, n_chans)`` mask of real channels, see
|
|
386
387
|
:func:`~braindecode.functional.check_ch_mask`. Needs per-sample ``chan_metadata`` and
|
|
387
388
|
``pooling="mean"``.
|
|
389
|
+
return_features : bool
|
|
390
|
+
If ``True``, return ``{"features": pooled, "cls_token": None,
|
|
391
|
+
"tokens": tokens}`` instead of the class logits: the pooled embedding
|
|
392
|
+
and the encoder tokens without the registers, ``(batch, n_chans,
|
|
393
|
+
n_patches, d_model)``, zero for padded channels.
|
|
388
394
|
|
|
389
395
|
Returns
|
|
390
396
|
-------
|
|
391
|
-
torch.Tensor
|
|
392
|
-
Class logits of shape ``(batch, n_outputs)
|
|
397
|
+
torch.Tensor or dict
|
|
398
|
+
Class logits of shape ``(batch, n_outputs)``, or the feature dict
|
|
399
|
+
when ``return_features`` is set.
|
|
393
400
|
"""
|
|
394
401
|
mask = check_ch_mask(ch_mask, x)
|
|
395
402
|
if mask is not None and self.pooling != "mean":
|
|
@@ -493,6 +500,15 @@ class DIVER1(EEGModuleMixin, nn.Module, license="apache-2.0"):
|
|
|
493
500
|
pooled = tokens.flatten(start_dim=1)
|
|
494
501
|
else:
|
|
495
502
|
pooled = masked_mean(tokens, mask, [1, 2])
|
|
503
|
+
if return_features:
|
|
504
|
+
if mask is not None:
|
|
505
|
+
tokens = tokens.masked_fill(~mask[:, :, None, None], 0.0)
|
|
506
|
+
out: dict[str, torch.Tensor | None] = {
|
|
507
|
+
"features": pooled,
|
|
508
|
+
"cls_token": None,
|
|
509
|
+
"tokens": tokens,
|
|
510
|
+
}
|
|
511
|
+
return out
|
|
496
512
|
return self.final_layer(pooled)
|
|
497
513
|
|
|
498
514
|
@torch.jit.unused
|
{braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/epint.py
RENAMED
|
@@ -249,14 +249,15 @@ class EpiNT(EEGModuleMixin, nn.Module, license="mit"):
|
|
|
249
249
|
Input of shape ``(batch, n_chans, n_times)``; ``n_chans`` may differ
|
|
250
250
|
from the construction one.
|
|
251
251
|
return_features : bool
|
|
252
|
-
If ``True``, return ``{"features": pooled, "cls_token": cls
|
|
253
|
-
``cls`` holds the class token of every channel,
|
|
254
|
-
``(batch, n_chans, embed_dim)``,
|
|
255
|
-
channels
|
|
252
|
+
If ``True``, return ``{"features": pooled, "cls_token": cls,
|
|
253
|
+
"tokens": tokens}``: ``cls`` holds the class token of every channel,
|
|
254
|
+
shape ``(batch, n_chans, embed_dim)``, ``pooled`` is its mean over
|
|
255
|
+
channels and ``tokens`` the patch tokens, ``(batch, n_chans,
|
|
256
|
+
n_patches, embed_dim)``. A scripted model ignores this flag.
|
|
256
257
|
ch_mask : torch.Tensor, optional
|
|
257
258
|
``(batch, n_chans)`` mask of real channels, see
|
|
258
259
|
:func:`~braindecode.functional.check_ch_mask`. Padded channels are dropped first; their
|
|
259
|
-
rows of ``cls`` are zero.
|
|
260
|
+
rows of ``cls`` and ``tokens`` are zero.
|
|
260
261
|
|
|
261
262
|
Returns
|
|
262
263
|
-------
|
|
@@ -283,7 +284,8 @@ class EpiNT(EEGModuleMixin, nn.Module, license="mit"):
|
|
|
283
284
|
cls_token = unpack_channels(z[:, 0], mask, n_chans) # (batch, chans, dim)
|
|
284
285
|
pooled = masked_mean(cls_token, mask, [1]) # (batch, dim)
|
|
285
286
|
if not torch.jit.is_scripting() and return_features:
|
|
286
|
-
|
|
287
|
+
tokens = unpack_channels(z[:, 1:], mask, n_chans)
|
|
288
|
+
return {"features": pooled, "cls_token": cls_token, "tokens": tokens}
|
|
287
289
|
return self.final_layer(pooled)
|
|
288
290
|
|
|
289
291
|
|
{braindecode-2.1.0.dev175175101 → braindecode-2.1.0.dev181162869}/braindecode/models/labram.py
RENAMED
|
@@ -16,7 +16,13 @@ import torch.nn as nn
|
|
|
16
16
|
from einops.layers.torch import Rearrange
|
|
17
17
|
from torch.nn.init import trunc_normal_
|
|
18
18
|
|
|
19
|
-
from braindecode.functional import
|
|
19
|
+
from braindecode.functional import (
|
|
20
|
+
check_ch_mask,
|
|
21
|
+
init_weights_,
|
|
22
|
+
masked_group_norm,
|
|
23
|
+
masked_mean,
|
|
24
|
+
rescale_parameter,
|
|
25
|
+
)
|
|
20
26
|
from braindecode.functional.attention import _hpu_eager_fused_sdpa
|
|
21
27
|
from braindecode.models.base import EEGModuleMixin
|
|
22
28
|
from braindecode.modules import MLP, DropPath
|
|
@@ -636,6 +642,7 @@ class Labram(EEGModuleMixin, nn.Module):
|
|
|
636
642
|
input_chans,
|
|
637
643
|
return_patch_tokens: bool = False,
|
|
638
644
|
return_all_tokens: bool = False,
|
|
645
|
+
ch_mask: Optional[torch.Tensor] = None,
|
|
639
646
|
):
|
|
640
647
|
"""
|
|
641
648
|
Forward the features of the model.
|
|
@@ -650,6 +657,8 @@ class Labram(EEGModuleMixin, nn.Module):
|
|
|
650
657
|
Whether to return the patch tokens.
|
|
651
658
|
return_all_tokens : bool
|
|
652
659
|
Whether to return all the tokens.
|
|
660
|
+
ch_mask : torch.Tensor, optional
|
|
661
|
+
``(batch, n_chans)`` boolean mask of real channels, already checked.
|
|
653
662
|
|
|
654
663
|
Returns
|
|
655
664
|
-------
|
|
@@ -657,11 +666,23 @@ class Labram(EEGModuleMixin, nn.Module):
|
|
|
657
666
|
The output of the model.
|
|
658
667
|
"""
|
|
659
668
|
batch_size, n_input_chans, _ = x.shape
|
|
669
|
+
token_mask: Optional[torch.Tensor] = None
|
|
670
|
+
key_mask: Optional[torch.Tensor] = None
|
|
671
|
+
if ch_mask is not None:
|
|
672
|
+
# Padding may hold NaN, which the patch embedding would spread.
|
|
673
|
+
x = x.masked_fill(~ch_mask[:, :, None], 0.0)
|
|
674
|
+
# Tokens are (channel, patch), channel outermost; [CLS] is real.
|
|
675
|
+
token_mask = ch_mask.repeat_interleave(self.patch_embed[0].n_patchs, dim=1)
|
|
676
|
+
key_mask = torch.cat(
|
|
677
|
+
[token_mask.new_ones(batch_size, 1), token_mask], dim=1
|
|
678
|
+
)
|
|
660
679
|
|
|
661
680
|
if self.neural_tokenizer:
|
|
662
681
|
# For neural tokenizer: input is (batch, n_chans, n_times)
|
|
663
682
|
# patch_embed returns (batch, n_chans, emb_dim)
|
|
664
|
-
x = self.patch_embed(
|
|
683
|
+
x = self.patch_embed.temporal_conv(
|
|
684
|
+
self.patch_embed.segment_patch(x), ch_mask
|
|
685
|
+
)
|
|
665
686
|
# x shape: (batch, n_chans, emb_dim)
|
|
666
687
|
n_patch = n_input_chans # Use actual input channels, not self.n_chans
|
|
667
688
|
temporal = self.embed_dim
|
|
@@ -730,24 +751,20 @@ class Labram(EEGModuleMixin, nn.Module):
|
|
|
730
751
|
x = self.pos_drop(x)
|
|
731
752
|
|
|
732
753
|
for blk in self.blocks:
|
|
733
|
-
out = blk(x)
|
|
754
|
+
out = blk(x, key_mask=key_mask)
|
|
734
755
|
assert isinstance(out, torch.Tensor) # narrows the Union for TorchScript
|
|
735
756
|
x = out
|
|
736
757
|
|
|
737
758
|
x = self.norm(x)
|
|
738
759
|
if self.fc_norm is not None:
|
|
739
|
-
if return_all_tokens:
|
|
740
|
-
return self.fc_norm(x)
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
return self.fc_norm(tokens)
|
|
744
|
-
return self.fc_norm(tokens.mean(1))
|
|
745
|
-
else:
|
|
746
|
-
if return_all_tokens:
|
|
747
|
-
return x
|
|
748
|
-
elif return_patch_tokens:
|
|
749
|
-
return x[:, 1:]
|
|
760
|
+
if not (return_all_tokens or return_patch_tokens):
|
|
761
|
+
return self.fc_norm(masked_mean(x[:, 1:, :], token_mask, [1]))
|
|
762
|
+
x = self.fc_norm(x)
|
|
763
|
+
elif not (return_all_tokens or return_patch_tokens):
|
|
750
764
|
return x[:, 0]
|
|
765
|
+
if key_mask is not None:
|
|
766
|
+
x = x.masked_fill(~key_mask[:, :, None], 0.0)
|
|
767
|
+
return x if return_all_tokens else x[:, 1:]
|
|
751
768
|
|
|
752
769
|
def forward(
|
|
753
770
|
self,
|
|
@@ -756,6 +773,7 @@ class Labram(EEGModuleMixin, nn.Module):
|
|
|
756
773
|
return_all_tokens: bool = False,
|
|
757
774
|
return_features: bool = False,
|
|
758
775
|
ch_names: Optional[List[str]] = None,
|
|
776
|
+
ch_mask: Optional[torch.Tensor] = None,
|
|
759
777
|
) -> Union[torch.Tensor, Dict[str, torch.Tensor]]:
|
|
760
778
|
"""
|
|
761
779
|
Forward the input EEG data through the model.
|
|
@@ -770,8 +788,10 @@ class Labram(EEGModuleMixin, nn.Module):
|
|
|
770
788
|
return_all_tokens: bool
|
|
771
789
|
Return all the tokens
|
|
772
790
|
return_features : bool
|
|
773
|
-
If True, return a dict with ``"features"`` (patch tokens)
|
|
774
|
-
``"cls_token"``
|
|
791
|
+
If True, return a dict with ``"features"`` (patch tokens),
|
|
792
|
+
``"cls_token"`` and ``"tokens"``, the patch tokens as ``(batch,
|
|
793
|
+
n_chans, n_patches, embed_dim)`` (one row in decoder mode), instead of
|
|
794
|
+
the classification output. Token outputs are zero for padded channels.
|
|
775
795
|
ch_names : list of str, optional
|
|
776
796
|
Channel names matching the channel axis of ``x``.
|
|
777
797
|
Matched case-insensitively against :data:`LABRAM_CHANNEL_ORDER`
|
|
@@ -782,12 +802,22 @@ class Labram(EEGModuleMixin, nn.Module):
|
|
|
782
802
|
a :class:`ValueError` is raised. Only honored when
|
|
783
803
|
``neural_tokenizer=True``; in decoder mode the position
|
|
784
804
|
embedding is sequential and ``ch_names`` has no effect.
|
|
805
|
+
ch_mask : torch.Tensor, optional
|
|
806
|
+
``(batch, n_chans)`` mask of real channels, see
|
|
807
|
+
:func:`~braindecode.functional.check_ch_mask`. Padded channels affect no
|
|
808
|
+
pooled output. Needs ``neural_tokenizer=True``.
|
|
785
809
|
|
|
786
810
|
Returns
|
|
787
811
|
-------
|
|
788
812
|
torch.Tensor or dict
|
|
789
813
|
The output of the model with dimensions (batch, n_outputs)
|
|
790
814
|
"""
|
|
815
|
+
mask = check_ch_mask(ch_mask, x)
|
|
816
|
+
if mask is not None and not self.neural_tokenizer:
|
|
817
|
+
raise ValueError(
|
|
818
|
+
"ch_mask needs neural_tokenizer=True: the decoder averages the "
|
|
819
|
+
"channels into each token."
|
|
820
|
+
)
|
|
791
821
|
n_canonical = len(self._canonical_index) # len(LABRAM_CHANNEL_ORDER)
|
|
792
822
|
if ch_names is None:
|
|
793
823
|
if x.shape[1] != n_canonical:
|
|
@@ -820,12 +850,14 @@ class Labram(EEGModuleMixin, nn.Module):
|
|
|
820
850
|
input_chans = torch.tensor(matched, device=x.device, dtype=torch.long)
|
|
821
851
|
|
|
822
852
|
if return_features:
|
|
853
|
+
n_rows = x.shape[1] if self.neural_tokenizer else 1
|
|
823
854
|
x = self.forward_features(
|
|
824
|
-
x, input_chans=input_chans, return_all_tokens=True
|
|
855
|
+
x, input_chans=input_chans, return_all_tokens=True, ch_mask=mask
|
|
825
856
|
)
|
|
826
857
|
out: Dict[str, torch.Tensor] = {
|
|
827
858
|
"features": x[:, 1:, :],
|
|
828
859
|
"cls_token": x[:, 0, :],
|
|
860
|
+
"tokens": x[:, 1:, :].unflatten(1, [n_rows, -1]),
|
|
829
861
|
}
|
|
830
862
|
return out
|
|
831
863
|
|
|
@@ -834,6 +866,7 @@ class Labram(EEGModuleMixin, nn.Module):
|
|
|
834
866
|
input_chans=input_chans,
|
|
835
867
|
return_patch_tokens=return_patch_tokens,
|
|
836
868
|
return_all_tokens=return_all_tokens,
|
|
869
|
+
ch_mask=mask,
|
|
837
870
|
)
|
|
838
871
|
x = self.final_layer(x)
|
|
839
872
|
return x
|
|
@@ -1355,6 +1388,7 @@ class _Attention(nn.Module):
|
|
|
1355
1388
|
x: torch.Tensor,
|
|
1356
1389
|
return_attention: bool = False,
|
|
1357
1390
|
return_qkv: bool = False,
|
|
1391
|
+
key_mask: Optional[torch.Tensor] = None,
|
|
1358
1392
|
) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
|
|
1359
1393
|
"""
|
|
1360
1394
|
Apply the attention mechanism to the input tensor.
|
|
@@ -1368,6 +1402,8 @@ class _Attention(nn.Module):
|
|
|
1368
1402
|
return_qkv: bool (default=False)
|
|
1369
1403
|
If True, return the query, key, and value tensors together with
|
|
1370
1404
|
the output tensor.
|
|
1405
|
+
key_mask: torch.Tensor, optional
|
|
1406
|
+
(Batch, N) boolean mask of the keys that take part.
|
|
1371
1407
|
Returns:
|
|
1372
1408
|
--------
|
|
1373
1409
|
x: torch.Tensor
|
|
@@ -1410,6 +1446,11 @@ class _Attention(nn.Module):
|
|
|
1410
1446
|
attn_mask = (
|
|
1411
1447
|
relative_position_bias.permute(2, 0, 1).contiguous().unsqueeze(0)
|
|
1412
1448
|
) # 1, nH, Wh*Ww, Wh*Ww
|
|
1449
|
+
if key_mask is not None:
|
|
1450
|
+
key_bias = torch.zeros(
|
|
1451
|
+
key_mask.shape, dtype=q.dtype, device=q.device
|
|
1452
|
+
).masked_fill(~key_mask, float("-inf"))[:, None, None, :]
|
|
1453
|
+
attn_mask = key_bias if attn_mask is None else attn_mask + key_bias
|
|
1413
1454
|
|
|
1414
1455
|
# Fused kernel, same math. Not with attention dropout in training (it
|
|
1415
1456
|
# would draw other masks). On Gaudi, torch's SDPA trains ~12 % slower
|
|
@@ -1549,7 +1590,11 @@ class _WindowsAttentionBlock(nn.Module):
|
|
|
1549
1590
|
self.gamma_1, self.gamma_2 = None, None
|
|
1550
1591
|
|
|
1551
1592
|
def forward(
|
|
1552
|
-
self,
|
|
1593
|
+
self,
|
|
1594
|
+
x,
|
|
1595
|
+
return_attention: bool = False,
|
|
1596
|
+
return_qkv: bool = False,
|
|
1597
|
+
key_mask: Optional[torch.Tensor] = None,
|
|
1553
1598
|
) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
|
|
1554
1599
|
"""
|
|
1555
1600
|
Apply the attention mechanism to the input tensor.
|
|
@@ -1562,6 +1607,8 @@ class _WindowsAttentionBlock(nn.Module):
|
|
|
1562
1607
|
return_qkv: bool (default=False)
|
|
1563
1608
|
If True, return the query, key, and value tensors together with
|
|
1564
1609
|
the output tensor.
|
|
1610
|
+
key_mask: torch.Tensor, optional
|
|
1611
|
+
(Batch, N) boolean mask of the keys that take part.
|
|
1565
1612
|
|
|
1566
1613
|
Returns
|
|
1567
1614
|
-------
|
|
@@ -1570,16 +1617,16 @@ class _WindowsAttentionBlock(nn.Module):
|
|
|
1570
1617
|
"""
|
|
1571
1618
|
|
|
1572
1619
|
if return_attention:
|
|
1573
|
-
return self.attn(self.norm1(x), return_attention=True)
|
|
1620
|
+
return self.attn(self.norm1(x), return_attention=True, key_mask=key_mask)
|
|
1574
1621
|
if return_qkv:
|
|
1575
|
-
out = self.attn(self.norm1(x), return_qkv=return_qkv)
|
|
1622
|
+
out = self.attn(self.norm1(x), return_qkv=return_qkv, key_mask=key_mask)
|
|
1576
1623
|
assert isinstance(out, tuple) # narrows the Union for TorchScript
|
|
1577
1624
|
y, qkv = out
|
|
1578
1625
|
x = x + self.drop_path(self.gamma_1 * y)
|
|
1579
1626
|
x = x + self.drop_path(self.gamma_2 * self.mlp(self.norm2(x)))
|
|
1580
1627
|
return x, qkv
|
|
1581
1628
|
|
|
1582
|
-
y = self.attn(self.norm1(x))
|
|
1629
|
+
y = self.attn(self.norm1(x), key_mask=key_mask)
|
|
1583
1630
|
assert isinstance(y, torch.Tensor) # narrows the Union for TorchScript
|
|
1584
1631
|
if self.gamma_1 is None:
|
|
1585
1632
|
x = x + self.drop_path(y)
|
|
@@ -1678,7 +1725,7 @@ class _TemporalConv(nn.Module):
|
|
|
1678
1725
|
|
|
1679
1726
|
self.transpose_temporal_channel = Rearrange("Batch C NA T -> Batch NA (T C)")
|
|
1680
1727
|
|
|
1681
|
-
def forward(self, x):
|
|
1728
|
+
def forward(self, x, ch_mask: Optional[torch.Tensor] = None):
|
|
1682
1729
|
"""
|
|
1683
1730
|
Apply 3 steps of 2D convolution, GELU activation function,
|
|
1684
1731
|
and GroupNorm.
|
|
@@ -1687,15 +1734,47 @@ class _TemporalConv(nn.Module):
|
|
|
1687
1734
|
-----------
|
|
1688
1735
|
x: torch.Tensor
|
|
1689
1736
|
Input tensor of shape (Batch, Channels, n_patchs, size_patch).
|
|
1737
|
+
ch_mask: torch.Tensor, optional
|
|
1738
|
+
(Batch, Channels) boolean mask of real channels; padded channels
|
|
1739
|
+
then take no part in the GroupNorm statistics.
|
|
1690
1740
|
|
|
1691
1741
|
Returns:
|
|
1692
1742
|
--------
|
|
1693
1743
|
x: torch.Tensor
|
|
1694
1744
|
Output tensor of shape (Batch, NA, Temporal Channel).
|
|
1695
1745
|
"""
|
|
1746
|
+
row_mask: Optional[torch.Tensor] = None
|
|
1747
|
+
if ch_mask is not None:
|
|
1748
|
+
# Flattened rows are (chs npat), channel outermost.
|
|
1749
|
+
row_mask = ch_mask.repeat_interleave(x.shape[2], dim=1)
|
|
1696
1750
|
x = self.channel_patch_flatten(x)
|
|
1697
|
-
x = self.
|
|
1698
|
-
x =
|
|
1699
|
-
|
|
1751
|
+
x = self.conv1(x)
|
|
1752
|
+
x = masked_group_norm(
|
|
1753
|
+
x,
|
|
1754
|
+
self.norm1.num_groups,
|
|
1755
|
+
row_mask,
|
|
1756
|
+
self.norm1.weight,
|
|
1757
|
+
self.norm1.bias,
|
|
1758
|
+
self.norm1.eps,
|
|
1759
|
+
)
|
|
1760
|
+
x = self.conv2(self.act_layer_1(x))
|
|
1761
|
+
x = masked_group_norm(
|
|
1762
|
+
x,
|
|
1763
|
+
self.norm2.num_groups,
|
|
1764
|
+
row_mask,
|
|
1765
|
+
self.norm2.weight,
|
|
1766
|
+
self.norm2.bias,
|
|
1767
|
+
self.norm2.eps,
|
|
1768
|
+
)
|
|
1769
|
+
x = self.conv3(self.act_layer_2(x))
|
|
1770
|
+
x = masked_group_norm(
|
|
1771
|
+
x,
|
|
1772
|
+
self.norm3.num_groups,
|
|
1773
|
+
row_mask,
|
|
1774
|
+
self.norm3.weight,
|
|
1775
|
+
self.norm3.bias,
|
|
1776
|
+
self.norm3.eps,
|
|
1777
|
+
)
|
|
1778
|
+
x = self.act_layer_3(x)
|
|
1700
1779
|
x = self.transpose_temporal_channel(x)
|
|
1701
1780
|
return x
|