braindecode 2.1.0.dev183011375__tar.gz → 2.1.0.dev184329867__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.dev183011375 → braindecode-2.1.0.dev184329867}/NOTICE.txt +4 -0
- {braindecode-2.1.0.dev183011375/braindecode.egg-info → braindecode-2.1.0.dev184329867}/PKG-INFO +1 -1
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/functional/__init__.py +10 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/functional/attention.py +4 -14
- braindecode-2.1.0.dev184329867/braindecode/functional/channels.py +282 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/__init__.py +5 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/base.py +49 -12
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/biot.py +10 -8
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/brainmodule.py +1 -13
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/codebrain.py +5 -18
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/emg2qwerty.py +8 -2
- braindecode-2.1.0.dev184329867/braindecode/models/fnirs4d.py +761 -0
- braindecode-2.1.0.dev184329867/braindecode/models/fnirs_cnn1d.py +339 -0
- braindecode-2.1.0.dev184329867/braindecode/models/fnirs_t.py +785 -0
- braindecode-2.1.0.dev184329867/braindecode/models/fnirsnet.py +374 -0
- braindecode-2.1.0.dev184329867/braindecode/models/geonirs.py +1545 -0
- braindecode-2.1.0.dev184329867/braindecode/models/jung_mae.py +596 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/mapa.py +4 -5
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/msvtnet.py +1 -2
- braindecode-2.1.0.dev184329867/braindecode/models/mtrenirs.py +1053 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/reve.py +1 -4
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/signal_jepa.py +5 -6
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/summary.csv +6 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/util.py +32 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/zuna.py +10 -18
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/attention.py +9 -8
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/channels.py +170 -30
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/layers.py +2 -8
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/util.py +9 -2
- braindecode-2.1.0.dev184329867/braindecode/version.py +1 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867/braindecode.egg-info}/PKG-INFO +1 -1
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode.egg-info/SOURCES.txt +6 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/api.rst +10 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/install/gaudi.rst +15 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/user_guide/channel_strategies.rst +23 -3
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/whats_new.rst +142 -0
- braindecode-2.1.0.dev183011375/braindecode/models/fnirs4d.py +0 -419
- braindecode-2.1.0.dev183011375/braindecode/models/fnirsnet.py +0 -192
- braindecode-2.1.0.dev183011375/braindecode/version.py +0 -1
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/LICENSE.txt +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/MANIFEST.in +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/README.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/augmentation/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/augmentation/base.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/augmentation/functional.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/augmentation/transforms.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/classifier.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/base.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/bbci.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/chb_mit.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/collate.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/mne.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/moabb.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/nmt.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/registry.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/siena.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/tuh.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/utils.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datasets/xy.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datautil/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datautil/serialization.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/datautil/util.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/eegneuralnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/functional/_lfilter.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/functional/_real_dft.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/functional/channel_mask.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/functional/functions.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/functional/initialization.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/functional/patches.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/atcnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/attn_sleep.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/axon.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/barista.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/bbl.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/bendr.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/brainbert.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/brainomni.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/brant.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/cbramod.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/config.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/contrawr.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/corteg.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/csbrain.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/ctnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/dance.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/deep4.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/dgcnn.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/diver1.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/duin.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eeg_clip.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegconformer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegdino.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eeginception_erp.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eeginception_mi.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegitnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegminer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegnex.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegpt.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegsym.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/epint.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/fbcnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/gcnsnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/guetschel2026.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/hybrid.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/ifnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/labram.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/luna.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/medformer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/meggpt.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/megxl.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/meta_neuromotor.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/mirepnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/model.html.jinja +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/mscformer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/mvpformer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/neuropose.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/neurorvq.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/neurorvq_tokenizer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/nice.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/patchedtransformer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/popt.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/sccnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/sensingdynamics.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/shallow_fbcsp.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/sinc_shallow.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/sleepfm.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/sparcnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/sstdpn.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/steegformer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/syncnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/tccnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/tcformer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/tcn.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/tfm_tokenizer.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/tidnet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/tmsanet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/tsinception.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/usleep.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/vemg2pose.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/activation.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/blocks.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/convolution.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/dance_modules.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/filter.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/linear.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/linear_attention.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/parametrization.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/quantization.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/seanet.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/stats.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/util.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/modules/wrapper.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/preprocessing/preprocess.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/preprocessing/util.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/preprocessing/windowers.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/regressor.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/samplers/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/samplers/base.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/samplers/ssl.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/training/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/training/_trial_aggregation.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/training/callbacks.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/training/losses.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/training/scoring.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/visualization/__init__.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/visualization/activations.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/visualization/attribution.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/visualization/frequency.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/visualization/metrics.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/visualization/sanity.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/visualization/topology.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode.egg-info/requires.txt +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/Makefile +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/agent_docs.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/cite.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/conf.py +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/help.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/index.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/install/install.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/install/install_pip.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/install/install_source.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/categorization/attention.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/categorization/channel.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/categorization/spd.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/models.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/models_categorization.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/models_table.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/models/models_visualization.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/sg_execution_times.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/docs/user_guide/cropped_inference.rst +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/pyproject.toml +0 -0
- {braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/setup.cfg +0 -0
|
@@ -62,6 +62,9 @@ The following components are licensed under the MIT License:
|
|
|
62
62
|
- `braindecode/models/meggpt.py`
|
|
63
63
|
- `braindecode/models/megxl.py`
|
|
64
64
|
- `braindecode/models/nice.py`
|
|
65
|
+
- `braindecode/models/fnirs_t.py`
|
|
66
|
+
- `docs/_static/model/fnirst.png` (wzhlearning/fNIRS-Transformer `fig/model.png`)
|
|
67
|
+
- `braindecode/models/mtrenirs.py`
|
|
65
68
|
- `braindecode/models/tccnet.py`
|
|
66
69
|
- `docs/_static/model/tccnet.png`
|
|
67
70
|
|
|
@@ -99,6 +102,7 @@ Creative Commons Attribution 4.0 International License (each docstring
|
|
|
99
102
|
cites the paper):
|
|
100
103
|
|
|
101
104
|
- `docs/_static/model/fnirsnet.png` (Wang et al., IEEE TNSRE 2023, Fig. 2, cropped)
|
|
105
|
+
- `docs/_static/model/mtrenirs.png` (Chae et al., arXiv:2610.36159, Fig. 2, cropped)
|
|
102
106
|
|
|
103
107
|
### USC Academic License Files
|
|
104
108
|
|
{braindecode-2.1.0.dev183011375/braindecode.egg-info → braindecode-2.1.0.dev184329867}/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.dev184329867
|
|
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-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/functional/__init__.py
RENAMED
|
@@ -6,6 +6,12 @@ from .channel_mask import (
|
|
|
6
6
|
pack_channels,
|
|
7
7
|
unpack_channels,
|
|
8
8
|
)
|
|
9
|
+
from .channels import (
|
|
10
|
+
derivation_matrix,
|
|
11
|
+
exact_derivation,
|
|
12
|
+
linear_channel_map,
|
|
13
|
+
spherical_spline_kernel,
|
|
14
|
+
)
|
|
9
15
|
from .functions import (
|
|
10
16
|
_get_gaussian_kernel1d,
|
|
11
17
|
apply_rotary,
|
|
@@ -41,12 +47,15 @@ __all__ = [
|
|
|
41
47
|
"apply_rotary",
|
|
42
48
|
"check_ch_mask",
|
|
43
49
|
"daubechies_filters",
|
|
50
|
+
"derivation_matrix",
|
|
44
51
|
"drop_path",
|
|
45
52
|
"dwt_max_level",
|
|
53
|
+
"exact_derivation",
|
|
46
54
|
"fft_conv1d",
|
|
47
55
|
"hilbert_freq",
|
|
48
56
|
"identity",
|
|
49
57
|
"iou_1d",
|
|
58
|
+
"linear_channel_map",
|
|
50
59
|
"masked_group_norm",
|
|
51
60
|
"masked_mean",
|
|
52
61
|
"pack_channels",
|
|
@@ -62,6 +71,7 @@ __all__ = [
|
|
|
62
71
|
"safe_log",
|
|
63
72
|
"scaled_dot_product_attention",
|
|
64
73
|
"sinusoidal_positional_encoding",
|
|
74
|
+
"spherical_spline_kernel",
|
|
65
75
|
"spectral_input",
|
|
66
76
|
"square",
|
|
67
77
|
"unpack_channels",
|
|
@@ -12,13 +12,6 @@ import torch.nn.functional as F
|
|
|
12
12
|
from torch import Tensor
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
@torch.jit.unused
|
|
16
|
-
def _hpu_lazy() -> bool:
|
|
17
|
-
from habana_frameworks.torch.utils.internal import is_lazy
|
|
18
|
-
|
|
19
|
-
return is_lazy()
|
|
20
|
-
|
|
21
|
-
|
|
22
15
|
def _sdpa_math_dropout(
|
|
23
16
|
query: Tensor,
|
|
24
17
|
key: Tensor,
|
|
@@ -81,8 +74,8 @@ def scaled_dot_product_attention(
|
|
|
81
74
|
-----
|
|
82
75
|
On Intel Gaudi, torch's SDPA runs op by op unless Habana's attention
|
|
83
76
|
setting is on; then the bridge's fused kernel runs it, with or without a
|
|
84
|
-
mask (:ref:`install_gaudi`)
|
|
85
|
-
keeps torch's math path
|
|
77
|
+
mask (:ref:`install_gaudi`), dropout included. On CPU, dropout on float32
|
|
78
|
+
or float64 inputs without a mask keeps torch's math path.
|
|
86
79
|
"""
|
|
87
80
|
if exact:
|
|
88
81
|
scores = torch.matmul(query, key.transpose(-2, -1))
|
|
@@ -104,12 +97,9 @@ def scaled_dot_product_attention(
|
|
|
104
97
|
and dropout_p > 0.0
|
|
105
98
|
and attn_mask is None
|
|
106
99
|
and (query.dtype == torch.float32 or query.dtype == torch.float64)
|
|
107
|
-
and
|
|
108
|
-
query.device.type == "cpu"
|
|
109
|
-
or (query.device.type == "hpu" and not _hpu_lazy())
|
|
110
|
-
)
|
|
100
|
+
and query.device.type == "cpu"
|
|
111
101
|
):
|
|
112
|
-
# CPU
|
|
102
|
+
# The CPU runs SDPA with dropout through the math path.
|
|
113
103
|
return _sdpa_math_dropout(query, key, value, dropout_p, scale)
|
|
114
104
|
if scale is None: # torch 2.0's signature has no ``scale``
|
|
115
105
|
return F.scaled_dot_product_attention(
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
# Authors: Bruno Aristimunha <b.aristimunha@gmail.com>
|
|
2
|
+
#
|
|
3
|
+
# License: BSD (3-clause)
|
|
4
|
+
r"""Channels as linear measurements of the scalp potential.
|
|
5
|
+
|
|
6
|
+
Every channel is a linear combination of electrode potentials ``v``: ``A`` is
|
|
7
|
+
``V(A)`` against the recording reference, ``A-B`` is ``V(A) - V(B)``
|
|
8
|
+
(:func:`derivation_matrix`). The inputs are ``y = A v`` and the channels a
|
|
9
|
+
model wants are ``t = B v``, so re-montaging, re-referencing and interpolation
|
|
10
|
+
are all one linear estimate of ``B v`` from ``A v`` (:func:`linear_channel_map`).
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import numpy as np
|
|
16
|
+
import torch
|
|
17
|
+
from torch import Tensor
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def derivation_matrix(
|
|
21
|
+
ch_names: list[str],
|
|
22
|
+
electrodes: list[str] | None = None,
|
|
23
|
+
reference: str | None = None,
|
|
24
|
+
) -> tuple[Tensor, list[str]]:
|
|
25
|
+
"""Each channel as a row over electrode potentials.
|
|
26
|
+
|
|
27
|
+
Parameters
|
|
28
|
+
----------
|
|
29
|
+
ch_names : list of str
|
|
30
|
+
``"A"`` is ``V(A)``, ``"A-B"`` is ``V(A) - V(B)``. Names are compared
|
|
31
|
+
ignoring case; any other name is one electrode.
|
|
32
|
+
electrodes : list of str, optional
|
|
33
|
+
Columns (lower case). Defaults to the electrodes of ``ch_names`` in
|
|
34
|
+
order of appearance; electrodes missing from the list are added.
|
|
35
|
+
reference : str, optional
|
|
36
|
+
Reference of the single-electrode channels: ``None`` (the recording's,
|
|
37
|
+
left implicit), an electrode name (``"Cz"``: ``A`` is ``V(A) - V(Cz)``)
|
|
38
|
+
or ``"average"`` (``A`` minus the mean of the single-electrode channels).
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
matrix : torch.Tensor
|
|
43
|
+
``(n_channels, n_electrodes)``, float64.
|
|
44
|
+
electrodes : list of str
|
|
45
|
+
The columns.
|
|
46
|
+
"""
|
|
47
|
+
parts = [
|
|
48
|
+
ends if len(ends := n.lower().split("-")) == 2 and all(ends) else [n.lower()]
|
|
49
|
+
for n in ch_names
|
|
50
|
+
]
|
|
51
|
+
if reference is not None and reference != "average":
|
|
52
|
+
parts = [p if len(p) == 2 else [p[0], reference.lower()] for p in parts]
|
|
53
|
+
electrodes = list(
|
|
54
|
+
dict.fromkeys([*(e.lower() for e in (electrodes or [])), *sum(parts, [])])
|
|
55
|
+
)
|
|
56
|
+
matrix = torch.zeros(len(ch_names), len(electrodes), dtype=torch.float64)
|
|
57
|
+
for row, ends in enumerate(parts):
|
|
58
|
+
matrix[row, electrodes.index(ends[0])] += 1.0
|
|
59
|
+
if len(ends) == 2:
|
|
60
|
+
matrix[row, electrodes.index(ends[1])] -= 1.0
|
|
61
|
+
if reference == "average":
|
|
62
|
+
single = torch.tensor([len(p) == 1 for p in parts])
|
|
63
|
+
matrix[single] -= matrix[single].mean(0)
|
|
64
|
+
return matrix, electrodes
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def linear_channel_map(
|
|
68
|
+
A: Tensor,
|
|
69
|
+
B: Tensor,
|
|
70
|
+
cov: Tensor,
|
|
71
|
+
noise: float = 0.0,
|
|
72
|
+
flat: Tensor | None = None,
|
|
73
|
+
match_gain: bool = False,
|
|
74
|
+
atol: float = 1e-9,
|
|
75
|
+
) -> tuple[Tensor, Tensor]:
|
|
76
|
+
r"""Best linear estimate of the channels ``B v`` from the channels ``A v``.
|
|
77
|
+
|
|
78
|
+
The electrode potentials :math:`v` have prior covariance :math:`\Sigma`
|
|
79
|
+
(``cov``), plus an unknown offset along each column of :math:`F`
|
|
80
|
+
(``flat``: a flat prior, e.g. the unknown recording reference). The inputs
|
|
81
|
+
are :math:`y = A v + \varepsilon` with :math:`\varepsilon \sim
|
|
82
|
+
\mathcal{N}(0, \sigma^2 I)` (``noise``) and the targets are :math:`t = B v`.
|
|
83
|
+
The best linear unbiased estimate :math:`\hat t = W y` solves
|
|
84
|
+
|
|
85
|
+
.. math::
|
|
86
|
+
|
|
87
|
+
\begin{bmatrix} A \Sigma A^\top + \sigma^2 I & A F \\ (A F)^\top & 0
|
|
88
|
+
\end{bmatrix}
|
|
89
|
+
\begin{bmatrix} W^\top \\ M \end{bmatrix} =
|
|
90
|
+
\begin{bmatrix} A \Sigma B^\top \\ (B F)^\top \end{bmatrix},
|
|
91
|
+
\qquad
|
|
92
|
+
\operatorname{var}(t_k - \hat t_k) = \big[B \Sigma B^\top
|
|
93
|
+
- W A \Sigma B^\top - (B F) M\big]_{kk},
|
|
94
|
+
|
|
95
|
+
which is kriging [Matheron1963]_, universal kriging when :math:`F` is
|
|
96
|
+
given [Matheron1969]_, and the posterior mean and variance of a Gaussian
|
|
97
|
+
process [Rasmussen2006]_. Without ``flat`` it is
|
|
98
|
+
:math:`W = B \Sigma A^\top (A \Sigma A^\top + \sigma^2 I)^{-1}`. The choice
|
|
99
|
+
of :math:`\Sigma` gives the known methods:
|
|
100
|
+
|
|
101
|
+
- :math:`\Sigma = 0` and :math:`F = I` (every potential unknown): the
|
|
102
|
+
exact derivations of :func:`exact_derivation`, ``W = B A^+``, such as
|
|
103
|
+
bipolar or Laplacian (source) derivations [Hjorth1975]_; a target is
|
|
104
|
+
exact when :math:`B F` lies in the span of :math:`A F`.
|
|
105
|
+
- the spherical-spline kernel (:func:`spherical_spline_kernel`), ``noise``
|
|
106
|
+
the regularisation and :math:`F = \mathbf 1` (the unknown reference):
|
|
107
|
+
spherical-spline interpolation [Perrin1989]_, which is spline smoothing on
|
|
108
|
+
the sphere [Wahba1981]_ and the Gaussian-process estimate with that kernel
|
|
109
|
+
[Kimeldorf1970]_.
|
|
110
|
+
- :math:`\Sigma = L L^\top` for a lead field :math:`L`: the minimum-norm
|
|
111
|
+
estimate [Hamalainen1994]_; with the targets taken against a point at
|
|
112
|
+
infinity (zero potential) it is REST re-referencing [Yao2001]_.
|
|
113
|
+
- a covariance fitted on dense recordings: the Wiener (linear MMSE) filter.
|
|
114
|
+
|
|
115
|
+
Parameters
|
|
116
|
+
----------
|
|
117
|
+
A : torch.Tensor
|
|
118
|
+
``(n_inputs, n_electrodes)`` input channels (:func:`derivation_matrix`).
|
|
119
|
+
B : torch.Tensor
|
|
120
|
+
``(n_targets, n_electrodes)`` target channels.
|
|
121
|
+
cov : torch.Tensor
|
|
122
|
+
``(n_electrodes, n_electrodes)`` prior covariance :math:`\Sigma`.
|
|
123
|
+
noise : float
|
|
124
|
+
Input noise variance :math:`\sigma^2` (the regularisation).
|
|
125
|
+
flat : torch.Tensor, optional
|
|
126
|
+
``(n_electrodes, n_flat)`` directions :math:`F` with a flat prior.
|
|
127
|
+
match_gain : bool
|
|
128
|
+
Rescale the part of each row free of the flat constraint (so
|
|
129
|
+
:math:`W A F = B F` still holds) so that the estimate has, as closely as
|
|
130
|
+
that constraint allows, the prior variance of its
|
|
131
|
+
target, :math:`[W A \Sigma A^\top W^\top]_{kk} = [B \Sigma B^\top]_{kk}`:
|
|
132
|
+
the minimum-variance estimate shrinks the amplitude.
|
|
133
|
+
atol : float
|
|
134
|
+
Largest residual of :math:`B F` from the span of :math:`A F` for a
|
|
135
|
+
target to be estimable (the flat part alone, whatever :math:`\Sigma`).
|
|
136
|
+
|
|
137
|
+
Returns
|
|
138
|
+
-------
|
|
139
|
+
weight : torch.Tensor
|
|
140
|
+
``(n_targets, n_inputs)``, float64; rows of targets that cannot be
|
|
141
|
+
estimated (``W A F != B F``) are 0.
|
|
142
|
+
variance : torch.Tensor
|
|
143
|
+
``(n_targets,)`` posterior variance (of the estimate before
|
|
144
|
+
``match_gain``); ``inf`` where not estimable.
|
|
145
|
+
|
|
146
|
+
References
|
|
147
|
+
----------
|
|
148
|
+
.. [Matheron1963] Matheron, G. (1963). Principles of geostatistics.
|
|
149
|
+
Economic Geology, 58(8), 1246-1266. https://doi.org/10.2113/gsecongeo.58.8.1246
|
|
150
|
+
.. [Matheron1969] Matheron, G. (1969). Le krigeage universel. Cahiers du
|
|
151
|
+
Centre de Morphologie Mathématique, 1. École des Mines de Paris.
|
|
152
|
+
https://www.cg.minesparis.psl.eu/bibliotheque/public/MATHERON_Ouvrage_00131.pdf
|
|
153
|
+
.. [Kimeldorf1970] Kimeldorf, G. S., & Wahba, G. (1970). A correspondence
|
|
154
|
+
between Bayesian estimation on stochastic processes and smoothing by
|
|
155
|
+
splines. The Annals of Mathematical Statistics, 41(2), 495-502.
|
|
156
|
+
https://doi.org/10.1214/aoms/1177697089
|
|
157
|
+
.. [Hjorth1975] Hjorth, B. (1975). An on-line transformation of EEG scalp
|
|
158
|
+
potentials into orthogonal source derivations. Electroencephalography and
|
|
159
|
+
Clinical Neurophysiology, 39(5), 526-530.
|
|
160
|
+
https://doi.org/10.1016/0013-4694(75)90056-5
|
|
161
|
+
.. [Wahba1981] Wahba, G. (1981). Spline interpolation and smoothing on the
|
|
162
|
+
sphere. SIAM Journal on Scientific and Statistical Computing, 2(1), 5-16.
|
|
163
|
+
https://doi.org/10.1137/0902002
|
|
164
|
+
.. [Perrin1989] Perrin, F., Pernier, J., Bertrand, O., & Echallier, J. F.
|
|
165
|
+
(1989). Spherical splines for scalp potential and current density
|
|
166
|
+
mapping. Electroencephalography and Clinical Neurophysiology, 72(2),
|
|
167
|
+
184-187. https://doi.org/10.1016/0013-4694(89)90180-6
|
|
168
|
+
.. [Hamalainen1994] Hämäläinen, M. S., & Ilmoniemi, R. J. (1994).
|
|
169
|
+
Interpreting magnetic fields of the brain: minimum norm estimates.
|
|
170
|
+
Medical & Biological Engineering & Computing, 32(1), 35-42.
|
|
171
|
+
https://doi.org/10.1007/BF02512476
|
|
172
|
+
.. [Yao2001] Yao, D. (2001). A method to standardize a reference of scalp
|
|
173
|
+
EEG recordings to a point at infinity. Physiological Measurement, 22(4),
|
|
174
|
+
693-711. https://doi.org/10.1088/0967-3334/22/4/305
|
|
175
|
+
.. [Rasmussen2006] Rasmussen, C. E., & Williams, C. K. I. (2006). Gaussian
|
|
176
|
+
Processes for Machine Learning. MIT Press.
|
|
177
|
+
https://doi.org/10.7551/mitpress/3206.001.0001
|
|
178
|
+
"""
|
|
179
|
+
A, B, cov = (torch.as_tensor(t, dtype=torch.float64) for t in (A, B, cov))
|
|
180
|
+
F = A.new_zeros(len(cov), 0) if flat is None else torch.as_tensor(flat).to(A)
|
|
181
|
+
n, f = len(A), F.shape[1]
|
|
182
|
+
AF, BF, K, KyT = A @ F, B @ F, A @ cov @ A.T, A @ cov @ B.T
|
|
183
|
+
M = A.new_zeros(n + f, n + f)
|
|
184
|
+
M[:n, :n] = K + noise * torch.eye(n, dtype=A.dtype, device=A.device)
|
|
185
|
+
M[:n, n:], M[n:, :n] = AF, AF.T
|
|
186
|
+
sol = torch.linalg.pinv(M) @ torch.cat([KyT, BF.T]) # SVD cutoff, as scipy/MNE
|
|
187
|
+
W, mu = sol[:n].T, sol[n:]
|
|
188
|
+
prior = (B @ cov * B).sum(1)
|
|
189
|
+
var = prior - (W * KyT.T).sum(1) - (mu.T * BF).sum(1)
|
|
190
|
+
W0 = BF @ torch.linalg.pinv(AF) # the flat part: W0 A F = B F when estimable
|
|
191
|
+
ok = (
|
|
192
|
+
(W0 @ AF - BF).abs().amax(1) <= atol
|
|
193
|
+
if f
|
|
194
|
+
else torch.ones(len(B), dtype=torch.bool, device=A.device)
|
|
195
|
+
)
|
|
196
|
+
if match_gain: # (W0 + s D) K (W0 + s D)^T = prior, D = W - W0, per row
|
|
197
|
+
D = W - W0
|
|
198
|
+
a, b, c = ((D @ K) * D).sum(1), ((D @ K) * W0).sum(1), ((W0 @ K) * W0).sum(1)
|
|
199
|
+
root = (b**2 - a * (c - prior)).clamp_min(0).sqrt()
|
|
200
|
+
W = W0 + torch.where(a > 0, (root - b) / a, 1.0)[:, None] * D
|
|
201
|
+
return W * ok[:, None], torch.where(ok, var.clamp_min(0), torch.inf)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def spherical_spline_kernel(
|
|
205
|
+
pos_a: Tensor, pos_b: Tensor, stiffness: int = 4, n_terms: int = 50
|
|
206
|
+
) -> Tensor:
|
|
207
|
+
r"""Spherical-spline covariance :math:`g(\cos\gamma)` between two sets of positions.
|
|
208
|
+
|
|
209
|
+
:math:`g(x) = \frac{1}{4\pi}\sum_{n=1}^{N} \frac{2n + 1}{(n (n + 1))^m}
|
|
210
|
+
P_n(x)`, with :math:`P_n` the Legendre polynomials, :math:`\gamma` the
|
|
211
|
+
angle between the positions seen from the origin, :math:`m` the
|
|
212
|
+
``stiffness`` and :math:`N` the number of terms (MNE's defaults: 4 and 50), as
|
|
213
|
+
in [Perrin1989]_.
|
|
214
|
+
Positions are taken from the origin: subtract the head centre first. Pass
|
|
215
|
+
it, or any function with this signature, to
|
|
216
|
+
:class:`~braindecode.modules.ChannelLayer` as the strategy.
|
|
217
|
+
|
|
218
|
+
Parameters
|
|
219
|
+
----------
|
|
220
|
+
pos_a, pos_b : torch.Tensor
|
|
221
|
+
``(n_a, 3)`` and ``(n_b, 3)`` positions.
|
|
222
|
+
stiffness : int
|
|
223
|
+
:math:`m`.
|
|
224
|
+
n_terms : int
|
|
225
|
+
:math:`N`.
|
|
226
|
+
|
|
227
|
+
Returns
|
|
228
|
+
-------
|
|
229
|
+
torch.Tensor
|
|
230
|
+
``(n_a, n_b)``, float64.
|
|
231
|
+
|
|
232
|
+
References
|
|
233
|
+
----------
|
|
234
|
+
.. [Perrin1989] Perrin, F., Pernier, J., Bertrand, O., & Echallier, J. F.
|
|
235
|
+
(1989). Spherical splines for scalp potential and current density
|
|
236
|
+
mapping. Electroencephalography and Clinical Neurophysiology, 72(2),
|
|
237
|
+
184-187. https://doi.org/10.1016/0013-4694(89)90180-6
|
|
238
|
+
"""
|
|
239
|
+
a, b = (
|
|
240
|
+
torch.nn.functional.normalize(torch.as_tensor(p, dtype=torch.float64), dim=1)
|
|
241
|
+
for p in (pos_a, pos_b)
|
|
242
|
+
)
|
|
243
|
+
n = np.arange(1, n_terms + 1, dtype=float) # int64 overflows at stiffness >= 6
|
|
244
|
+
coef = np.r_[0.0, (2 * n + 1) / ((n * (n + 1)) ** stiffness * 4 * np.pi)]
|
|
245
|
+
return torch.as_tensor(
|
|
246
|
+
np.polynomial.legendre.legval((a @ b.T).clamp(-1, 1).numpy(), coef)
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def exact_derivation(
|
|
251
|
+
target: list[str], inputs: list[str], atol: float = 1e-9
|
|
252
|
+
) -> tuple[Tensor, Tensor]:
|
|
253
|
+
"""``W`` with ``W @ x`` the ``target`` channels, from the ``inputs`` ``x``.
|
|
254
|
+
|
|
255
|
+
A target is exact when its row of :func:`derivation_matrix` is a
|
|
256
|
+
combination of the input rows: ``F3-C3`` from ``C3-F3`` (weight ``-1``),
|
|
257
|
+
``F3-P3`` from ``F3-C3`` and ``C3-P3``, ``F3-C3`` from ``F3`` and ``C3``.
|
|
258
|
+
This is :func:`linear_channel_map` with every potential unknown, so ``W``
|
|
259
|
+
is the minimum-norm solution and duplicate measurements are averaged.
|
|
260
|
+
No reference is guessed: ``F3-C3`` is not exact from ``F3-R1`` and
|
|
261
|
+
``C3-R2``, and ``F3`` is not exact from bipolar channels alone.
|
|
262
|
+
|
|
263
|
+
Parameters
|
|
264
|
+
----------
|
|
265
|
+
target, inputs : list of str
|
|
266
|
+
Channel names, as in :func:`derivation_matrix`.
|
|
267
|
+
atol : float
|
|
268
|
+
Largest residual of an exact row.
|
|
269
|
+
|
|
270
|
+
Returns
|
|
271
|
+
-------
|
|
272
|
+
weight : torch.Tensor
|
|
273
|
+
``(len(target), len(inputs))``, float64; rows of non-exact targets are 0.
|
|
274
|
+
exact : torch.Tensor
|
|
275
|
+
``(len(target),)`` bool.
|
|
276
|
+
"""
|
|
277
|
+
R, electrodes = derivation_matrix(inputs)
|
|
278
|
+
T, electrodes = derivation_matrix(target, electrodes)
|
|
279
|
+
R = torch.nn.functional.pad(R, (0, T.shape[1] - R.shape[1]))
|
|
280
|
+
eye = torch.eye(T.shape[1], dtype=torch.float64)
|
|
281
|
+
weight, var = linear_channel_map(R, T, 0 * eye, flat=eye, atol=atol)
|
|
282
|
+
return weight.round(decimals=12) + 0.0, torch.isfinite(var) # -1.0, not -0.99..
|
{braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/__init__.py
RENAMED
|
@@ -55,11 +55,15 @@ if TYPE_CHECKING:
|
|
|
55
55
|
from .fblightconvnet import FBLightConvNet
|
|
56
56
|
from .fbmsnet import FBMSNet
|
|
57
57
|
from .fnirs4d import FNIRS4D
|
|
58
|
+
from .fnirs_cnn1d import FNIRSCNN1D
|
|
59
|
+
from .fnirs_t import FNIRST, FNIRSPreT
|
|
58
60
|
from .fnirsnet import FNIRSNet
|
|
59
61
|
from .gcnsnet import GCNsNet
|
|
62
|
+
from .geonirs import GeoNIRS
|
|
60
63
|
from .guetschel2026 import Guetschel2026
|
|
61
64
|
from .hybrid import HybridNet
|
|
62
65
|
from .ifnet import IFNet
|
|
66
|
+
from .jung_mae import JungMAE
|
|
63
67
|
from .labram import Labram
|
|
64
68
|
from .luna import LUNA
|
|
65
69
|
from .mapa import MAPA
|
|
@@ -70,6 +74,7 @@ if TYPE_CHECKING:
|
|
|
70
74
|
from .mirepnet import MIRepNet
|
|
71
75
|
from .mscformer import MSCFormer
|
|
72
76
|
from .msvtnet import MSVTNet
|
|
77
|
+
from .mtrenirs import MtReNIRS
|
|
73
78
|
from .mvpformer import MVPFormer
|
|
74
79
|
from .neuropose import NeuroPose
|
|
75
80
|
from .neurorvq import NeuroRVQ
|
{braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/base.py
RENAMED
|
@@ -466,7 +466,12 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
466
466
|
"Modifying chs_info argument using the _deserialize_chs_info() method"
|
|
467
467
|
)
|
|
468
468
|
|
|
469
|
-
if
|
|
469
|
+
if ( # under a channel_strategy the input montage changes per call
|
|
470
|
+
channel_strategy == "native"
|
|
471
|
+
and n_chans is not None
|
|
472
|
+
and chs_info is not None
|
|
473
|
+
and len(chs_info) != n_chans
|
|
474
|
+
):
|
|
470
475
|
raise ValueError(f"{n_chans=} different from {chs_info=} length")
|
|
471
476
|
if (
|
|
472
477
|
n_times is not None
|
|
@@ -531,23 +536,43 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
531
536
|
def _channel_forward(self, *args, chs_info=None, ch_names=None, **kwargs):
|
|
532
537
|
"""``forward`` under a channel strategy: map ``x`` (recorded with
|
|
533
538
|
``chs_info``, default the model's) onto the target, then run the backbone."""
|
|
539
|
+
# pad_channels_collate / set_return_ch_pos: pos and ch_mask describe the
|
|
540
|
+
# input montage of each sample; the backbone gets the full target one.
|
|
541
|
+
# pos describes the input channels, never the backbone's mapped ones
|
|
542
|
+
ch_mask, pos = kwargs.pop("ch_mask", None), kwargs.pop("pos", None)
|
|
534
543
|
bound = inspect.signature(type(self).forward).bind_partial(
|
|
535
544
|
self, *args, **kwargs
|
|
536
545
|
)
|
|
537
546
|
if bound.arguments.get("ch_mask") is not None:
|
|
538
|
-
# The channel layer mixes every input channel into each target one,
|
|
539
|
-
# so padding would leak into the real channels.
|
|
540
547
|
raise ValueError(
|
|
541
|
-
"ch_mask
|
|
542
|
-
"
|
|
548
|
+
"Pass ch_mask by keyword under a channel_strategy: the channel layer "
|
|
549
|
+
"uses it to map each sample, the backbone never sees it."
|
|
550
|
+
)
|
|
551
|
+
if chs_info is None and pos is not None and ch_mask is not None: # no names
|
|
552
|
+
mask = (
|
|
553
|
+
torch.ones(pos.shape[:2], dtype=torch.bool)
|
|
554
|
+
if ch_mask is None
|
|
555
|
+
else ch_mask
|
|
556
|
+
)
|
|
557
|
+
chs_info = [
|
|
558
|
+
[
|
|
559
|
+
{"ch_name": f"E{i}", "kind": "eeg", "loc": np.r_[p, np.zeros(9)]}
|
|
560
|
+
for i, p in enumerate(pb[mb.cpu().numpy()])
|
|
561
|
+
]
|
|
562
|
+
for pb, mb in zip(pos.detach().cpu().double().numpy(), mask)
|
|
563
|
+
]
|
|
564
|
+
elif ch_mask is not None and not (chs_info and isinstance(chs_info[0], list)):
|
|
565
|
+
raise ValueError(
|
|
566
|
+
"ch_mask under a channel_strategy needs the montage of each sample: "
|
|
567
|
+
"pos (set_return_ch_pos(True)) or chs_info as a list of montages."
|
|
543
568
|
)
|
|
544
569
|
if chs_info is None and ch_names is not None: # LaBraM: names of x's channels
|
|
545
570
|
chs_info = [{"ch_name": n} for n in ch_names]
|
|
546
571
|
if args:
|
|
547
|
-
args = (self.channel_layer(args[0], chs_info)[0], *args[1:])
|
|
572
|
+
args = (self.channel_layer(args[0], chs_info, ch_mask)[0], *args[1:])
|
|
548
573
|
else: # x by keyword: the backbone's first input (x, X, eeg...)
|
|
549
574
|
x = list(inspect.signature(type(self).forward).parameters)[1]
|
|
550
|
-
kwargs[x] = self.channel_layer(kwargs[x], chs_info)[0]
|
|
575
|
+
kwargs[x] = self.channel_layer(kwargs[x], chs_info, ch_mask)[0]
|
|
551
576
|
return type(self).forward(self, *args, **kwargs)
|
|
552
577
|
|
|
553
578
|
@property
|
|
@@ -891,14 +916,19 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
891
916
|
|
|
892
917
|
def load_state_dict(self, state_dict, *args, **kwargs):
|
|
893
918
|
mapping = self.mapping if self.mapping else {}
|
|
919
|
+
own = super().state_dict()
|
|
894
920
|
new_state_dict = OrderedDict()
|
|
895
921
|
for k, v in state_dict.items():
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
922
|
+
k = mapping.get(k, k)
|
|
923
|
+
# Checkpoints saved before a weight was parametrized (max-norm
|
|
924
|
+
# constraints) store it as ``weight``; the module now keeps it
|
|
925
|
+
# as ``parametrizations.weight.original``.
|
|
926
|
+
module, _, name = k.rpartition(".")
|
|
927
|
+
parametrized = f"{module}.parametrizations.weight.original".lstrip(".")
|
|
928
|
+
if name == "weight" and k not in own and parametrized in own:
|
|
929
|
+
k = parametrized
|
|
930
|
+
new_state_dict[k] = v
|
|
900
931
|
# A backbone checkpoint has no weights for a trainable channel layer.
|
|
901
|
-
own = super().state_dict()
|
|
902
932
|
# Load hooks may expand tensors with locally initialized values. Only
|
|
903
933
|
# attribute whole tensors whose checkpoint shape already matches.
|
|
904
934
|
from_checkpoint = {
|
|
@@ -1182,6 +1212,13 @@ class EEGModuleMixin(_BaseHubMixin, metaclass=_BraindecodeDocstringMeta):
|
|
|
1182
1212
|
|
|
1183
1213
|
config = build_model_config(self)
|
|
1184
1214
|
config["braindecode_version"] = __version__
|
|
1215
|
+
if callable(getattr(getattr(self, "channel_layer", None), "strategy", None)):
|
|
1216
|
+
warnings.warn(
|
|
1217
|
+
"The function channel_strategy is not saved: pass it again to "
|
|
1218
|
+
"from_pretrained(..., channel_strategy=...).",
|
|
1219
|
+
UserWarning,
|
|
1220
|
+
stacklevel=2,
|
|
1221
|
+
)
|
|
1185
1222
|
|
|
1186
1223
|
# Save to config.json
|
|
1187
1224
|
config_path = save_directory / "config.json"
|
{braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/biot.py
RENAMED
|
@@ -534,6 +534,12 @@ class _BIOTEncoder(nn.Module):
|
|
|
534
534
|
# channel's (batch, freq, ts) block is contiguous
|
|
535
535
|
spec = self.stft(x.transpose(0, 1).reshape(n_chans * batch_size, 1, n_times))
|
|
536
536
|
spec = spec.unflatten(0, [n_chans, batch_size])
|
|
537
|
+
# Every channel token in one lookup of a 1-D index, then one row per
|
|
538
|
+
# channel. A 0-d index per channel would also trip Intel Gaudi, whose
|
|
539
|
+
# embedding backward sends a 0-d index's gradient to row 0.
|
|
540
|
+
channel_tokens = self.channel_tokens(
|
|
541
|
+
self.index[n_channel_offset : n_channel_offset + n_chans]
|
|
542
|
+
)
|
|
537
543
|
emb_seq = []
|
|
538
544
|
token_masks = []
|
|
539
545
|
for i in range(n_chans):
|
|
@@ -545,10 +551,9 @@ class _BIOTEncoder(nn.Module):
|
|
|
545
551
|
batch_size, ts, _ = channel_spec_emb.shape
|
|
546
552
|
# (batch_size, ts, emb)
|
|
547
553
|
# Step by step the following lines do the following operations:
|
|
548
|
-
# -
|
|
549
|
-
#
|
|
550
|
-
#
|
|
551
|
-
# which channel's embedding is retrieved.
|
|
554
|
+
# - channel_tokens[i]:
|
|
555
|
+
# The token of channel i + n_channel_offset, where
|
|
556
|
+
# n_channel_offset adjusts which channel's embedding is used.
|
|
552
557
|
# - .unsqueeze(0).unsqueeze(0):
|
|
553
558
|
# Adds two singleton dimensions to the embedding tensor.
|
|
554
559
|
# [emb_size] to [1, 1, emb_size] .
|
|
@@ -556,10 +561,7 @@ class _BIOTEncoder(nn.Module):
|
|
|
556
561
|
# Replicates the embedding tensor to match the batch size and
|
|
557
562
|
# time steps (ts),
|
|
558
563
|
channel_token_emb = (
|
|
559
|
-
|
|
560
|
-
.unsqueeze(0)
|
|
561
|
-
.unsqueeze(0)
|
|
562
|
-
.repeat(batch_size, ts, 1)
|
|
564
|
+
channel_tokens[i].unsqueeze(0).unsqueeze(0).repeat(batch_size, ts, 1)
|
|
563
565
|
)
|
|
564
566
|
# (batch_size, ts, emb)
|
|
565
567
|
# The positional embedding is explaining with more
|
{braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/brainmodule.py
RENAMED
|
@@ -17,7 +17,6 @@ import torchaudio as ta
|
|
|
17
17
|
from torch import nn
|
|
18
18
|
from torch.nn import functional as F
|
|
19
19
|
|
|
20
|
-
from braindecode.functional.attention import _hpu_lazy
|
|
21
20
|
from braindecode.models.base import EEGModuleMixin
|
|
22
21
|
from braindecode.models.util import has_valid_locations, positions_from_chs_info
|
|
23
22
|
from braindecode.modules import ChannelMerger
|
|
@@ -713,7 +712,7 @@ class _ConvSequence(nn.Module):
|
|
|
713
712
|
nn.Conv1d(
|
|
714
713
|
chout, 2 * chout, 1 + 2 * glu_context, padding=glu_context
|
|
715
714
|
),
|
|
716
|
-
|
|
715
|
+
nn.GLU(dim=1),
|
|
717
716
|
)
|
|
718
717
|
)
|
|
719
718
|
else:
|
|
@@ -728,17 +727,6 @@ class _ConvSequence(nn.Module):
|
|
|
728
727
|
return x
|
|
729
728
|
|
|
730
729
|
|
|
731
|
-
class _GLU(nn.GLU):
|
|
732
|
-
"""``nn.GLU`` that Intel Gaudi's lazy mode can compile."""
|
|
733
|
-
|
|
734
|
-
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
|
735
|
-
if not torch.jit.is_scripting() and x.device.type == "hpu" and _hpu_lazy():
|
|
736
|
-
# Its graph compiler fails on ``aten.glu`` after a convolution.
|
|
737
|
-
a, b = x.chunk(2, dim=self.dim)
|
|
738
|
-
return a * torch.sigmoid(b)
|
|
739
|
-
return F.glu(x, self.dim)
|
|
740
|
-
|
|
741
|
-
|
|
742
730
|
def _pad_multiple(x: torch.Tensor, base: int) -> torch.Tensor:
|
|
743
731
|
"""Pad tensor to be a multiple of base."""
|
|
744
732
|
length = x.shape[-1]
|
{braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/codebrain.py
RENAMED
|
@@ -15,7 +15,6 @@ from torch import nn
|
|
|
15
15
|
from torch.nn.utils.parametrizations import weight_norm
|
|
16
16
|
|
|
17
17
|
from braindecode.functional import _real_dft, spectral_input
|
|
18
|
-
from braindecode.functional.attention import _hpu_lazy
|
|
19
18
|
from braindecode.functional.functions import _next_fast_len
|
|
20
19
|
from braindecode.models.base import EEGModuleMixin
|
|
21
20
|
|
|
@@ -904,20 +903,10 @@ class _ResidualGroup(nn.Module):
|
|
|
904
903
|
def forward(self, input_data: torch.Tensor) -> torch.Tensor:
|
|
905
904
|
noise = input_data
|
|
906
905
|
h = noise
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
skip_list = []
|
|
912
|
-
for block in self.residual_blocks:
|
|
913
|
-
h, skip_n = block((h, noise))
|
|
914
|
-
skip_list.append(skip_n)
|
|
915
|
-
skip = torch.stack(skip_list, dim=0).sum(dim=0)
|
|
916
|
-
else:
|
|
917
|
-
skip = torch.zeros((), dtype=h.dtype, device=h.device)
|
|
918
|
-
for block in self.residual_blocks:
|
|
919
|
-
h, skip_n = block((h, noise))
|
|
920
|
-
skip = skip_n + skip
|
|
906
|
+
skip = torch.zeros((), dtype=h.dtype, device=h.device)
|
|
907
|
+
for block in self.residual_blocks:
|
|
908
|
+
h, skip_n = block((h, noise))
|
|
909
|
+
skip = skip_n + skip
|
|
921
910
|
|
|
922
911
|
return skip * math.sqrt(1.0 / self.num_res_layers)
|
|
923
912
|
|
|
@@ -1003,9 +992,7 @@ class _PatchEmbedding(nn.Module):
|
|
|
1003
992
|
self.d_model = self.emb_dim
|
|
1004
993
|
|
|
1005
994
|
# ========== Learnable parameters ==========
|
|
1006
|
-
self.mask_encoding = nn.Parameter(
|
|
1007
|
-
torch.zeros(self.emb_dim), requires_grad=False
|
|
1008
|
-
)
|
|
995
|
+
self.mask_encoding = nn.Parameter(torch.zeros(patch_size), requires_grad=False)
|
|
1009
996
|
|
|
1010
997
|
# ========== Layers ==========
|
|
1011
998
|
# Temporal projection: 3-layer Conv2d stack
|
{braindecode-2.1.0.dev183011375 → braindecode-2.1.0.dev184329867}/braindecode/models/emg2qwerty.py
RENAMED
|
@@ -750,10 +750,16 @@ class _RotationInvariantMLP(nn.Module):
|
|
|
750
750
|
self.offsets = tuple(offsets) if len(offsets) > 0 else (0,)
|
|
751
751
|
|
|
752
752
|
def forward(self, inputs: torch.Tensor) -> torch.Tensor:
|
|
753
|
-
# Gaudi eager mode rolls a non-contiguous tensor wrongly.
|
|
753
|
+
# Gaudi eager mode rolls a non-contiguous tensor wrongly. Offset 0 is the
|
|
754
|
+
# input itself: no copy, and no roll by 0 in the backward (of a slice of
|
|
755
|
+
# the stack's gradient, which Gaudi also rolls wrongly).
|
|
754
756
|
inputs = inputs.contiguous()
|
|
755
757
|
rolled = torch.stack(
|
|
756
|
-
[
|
|
758
|
+
[
|
|
759
|
+
inputs.roll(offset, dims=2) if offset else inputs
|
|
760
|
+
for offset in self.offsets
|
|
761
|
+
],
|
|
762
|
+
dim=2,
|
|
757
763
|
)
|
|
758
764
|
per_roll_features = self.mlp(rolled.flatten(start_dim=3))
|
|
759
765
|
if self.pooling == "max":
|