braindecode 1.8.1.dev178298903__tar.gz → 1.8.1.dev178305276__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/NOTICE.txt +3 -0
- {braindecode-1.8.1.dev178298903/braindecode.egg-info → braindecode-1.8.1.dev178305276}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/augmentation/__init__.py +2 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/augmentation/functional.py +49 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/augmentation/transforms.py +52 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/base.py +69 -3
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/eegneuralnet.py +6 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/functional/_real_dft.py +55 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/functional/functions.py +32 -13
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/__init__.py +6 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/axon.py +42 -8
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/barista.py +25 -13
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/base.py +22 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/brainmodule.py +13 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/brant.py +18 -7
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/codebrain.py +108 -26
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/csbrain.py +24 -12
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/ctnet.py +9 -1
- braindecode-1.8.1.dev178305276/braindecode/models/duin.py +454 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eeg_clip.py +71 -9
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegconformer.py +14 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eeginception_mi.py +7 -3
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegnex.py +7 -3
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegpt.py +15 -9
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegsym.py +68 -16
- braindecode-1.8.1.dev178305276/braindecode/models/epint.py +315 -0
- braindecode-1.8.1.dev178305276/braindecode/models/gcnsnet.py +338 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/labram.py +19 -9
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/luna.py +7 -4
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/medformer.py +47 -20
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/mirepnet.py +15 -4
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/mscformer.py +21 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/msvtnet.py +115 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/neurorvq.py +118 -31
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/neurorvq_tokenizer.py +30 -10
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/patchedtransformer.py +3 -7
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/reve.py +127 -43
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/signal_jepa.py +81 -3
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/sinc_shallow.py +2 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/sleepfm.py +62 -12
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/steegformer.py +16 -9
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/summary.csv +3 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/tfm_tokenizer.py +44 -3
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/util.py +8 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/zuna.py +9 -8
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/__init__.py +2 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/attention.py +85 -15
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/blocks.py +54 -5
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/channels.py +77 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/dance_modules.py +16 -3
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/layers.py +41 -2
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/quantization.py +5 -5
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/preprocessing/preprocess.py +19 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/samplers/base.py +60 -61
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/training/losses.py +5 -4
- braindecode-1.8.1.dev178305276/braindecode/version.py +1 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276/braindecode.egg-info}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode.egg-info/SOURCES.txt +3 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/api.rst +11 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/whats_new.rst +101 -0
- braindecode-1.8.1.dev178298903/braindecode/version.py +0 -1
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/LICENSE.txt +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/MANIFEST.in +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/README.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/__init__.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/augmentation/base.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/classifier.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bids/format.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/chb_mit.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/collate.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/mne.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/siena.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/tuh.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/utils.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datautil/serialization.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datautil/util.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/functional/__init__.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/functional/initialization.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/atcnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/attn_sleep.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/bendr.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/biot.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/brainbert.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/brainomni.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/cbramod.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/config.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/contrawr.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/dance.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/deep4.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/dgcnn.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/diver1.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegdino.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eeginception_erp.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegitnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegminer.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/emg2qwerty.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/guetschel2026.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/ifnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/mapa.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/meta_neuromotor.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/mvpformer.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/neuropose.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/popt.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/sensingdynamics.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/shallow_fbcsp.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/sparcnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/sstdpn.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/syncnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/tcformer.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/tcn.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/tidnet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/tmsanet.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/usleep.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/vemg2pose.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/activation.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/convolution.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/filter.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/linear.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/linear_attention.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/parametrization.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/popt_modules.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/stats.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/util.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/preprocessing/windowers.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/regressor.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/training/__init__.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/training/scoring.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/util.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/visualization/activations.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/visualization/attribution.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/visualization/frequency.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/visualization/metrics.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/visualization/sanity.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/visualization/topology.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode.egg-info/requires.txt +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/Makefile +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/agent_docs.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/cite.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/conf.py +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/help.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/index.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/install/install.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/install/install_pip.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/install/install_source.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/models.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/models_categorization.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/models_table.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/docs/user_guide/channel_strategies.rst +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/pyproject.toml +0 -0
- {braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/setup.cfg +0 -0
|
@@ -40,6 +40,7 @@ The following components are licensed under the MIT License:
|
|
|
40
40
|
|
|
41
41
|
- `braindecode/models/ctnet.py`
|
|
42
42
|
- `braindecode/models/dance.py`
|
|
43
|
+
- `braindecode/models/duin.py`
|
|
43
44
|
- `braindecode/models/medformer.py`
|
|
44
45
|
- `braindecode/models/tcformer.py`
|
|
45
46
|
- `braindecode/models/ifnet.py`
|
|
@@ -54,6 +55,8 @@ The following components are licensed under the MIT License:
|
|
|
54
55
|
- `docs/_static/model/seizure_transformer_arch.png`
|
|
55
56
|
- `braindecode/models/guetschel2026.py`
|
|
56
57
|
- `braindecode/models/tmsanet.py`
|
|
58
|
+
- `braindecode/models/epint.py`
|
|
59
|
+
- `braindecode/models/gcnsnet.py`
|
|
57
60
|
|
|
58
61
|
The `brainomni.py` file is a derivative of `OpenTSLab/BrainOmni` (MIT), whose
|
|
59
62
|
SEANet codec derives from Meta's `facebookresearch/encodec` (MIT). The
|
{braindecode-1.8.1.dev178298903/braindecode.egg-info → braindecode-1.8.1.dev178305276}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: braindecode
|
|
3
|
-
Version: 1.8.1.
|
|
3
|
+
Version: 1.8.1.dev178305276
|
|
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>
|
|
@@ -10,6 +10,7 @@ from .transforms import (
|
|
|
10
10
|
ChannelsReref,
|
|
11
11
|
ChannelsShuffle,
|
|
12
12
|
ChannelsSymmetry,
|
|
13
|
+
CutMix,
|
|
13
14
|
FrequencyShift,
|
|
14
15
|
FTSurrogate,
|
|
15
16
|
GaussianNoise,
|
|
@@ -36,6 +37,7 @@ __all__ = [
|
|
|
36
37
|
"SignFlip",
|
|
37
38
|
"FTSurrogate",
|
|
38
39
|
"ChannelsShuffle",
|
|
40
|
+
"CutMix",
|
|
39
41
|
"ChannelsDropout",
|
|
40
42
|
"GaussianNoise",
|
|
41
43
|
"ChannelsSymmetry",
|
|
@@ -580,6 +580,7 @@ def _frequency_shift(X: torch.Tensor, fs: float, f_shift: float) -> torch.Tensor
|
|
|
580
580
|
_f_shift = torch.as_tensor(f_shift).float()
|
|
581
581
|
else:
|
|
582
582
|
raise ValueError(f"Invalid f_shift type: {type(f_shift)}")
|
|
583
|
+
_f_shift = _f_shift.to(X.device)
|
|
583
584
|
f_shift_stack = _f_shift.repeat(N_padded, n_channels, 1)
|
|
584
585
|
reshaped_f_shift = f_shift_stack.permute(
|
|
585
586
|
*torch.arange(f_shift_stack.ndim - 1, -1, -1)
|
|
@@ -1075,6 +1076,54 @@ def mixup(
|
|
|
1075
1076
|
return X_mix, (y_a, y_b, lam)
|
|
1076
1077
|
|
|
1077
1078
|
|
|
1079
|
+
def cutmix(
|
|
1080
|
+
X: torch.Tensor,
|
|
1081
|
+
y: torch.Tensor,
|
|
1082
|
+
idx_perm: torch.Tensor,
|
|
1083
|
+
cut_t_start: torch.Tensor,
|
|
1084
|
+
cut_t_len: torch.Tensor,
|
|
1085
|
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
|
1086
|
+
"""Paste a time region of shuffled examples into the original examples.
|
|
1087
|
+
|
|
1088
|
+
See [1]_ for details.
|
|
1089
|
+
|
|
1090
|
+
Parameters
|
|
1091
|
+
----------
|
|
1092
|
+
X : torch.Tensor
|
|
1093
|
+
EEG data in form ``batch_size, n_channels, n_times``
|
|
1094
|
+
y : torch.Tensor
|
|
1095
|
+
Target of length ``batch_size``
|
|
1096
|
+
idx_perm : torch.Tensor
|
|
1097
|
+
Permuted indices of example that are mixed into original examples.
|
|
1098
|
+
cut_t_start : torch.Tensor
|
|
1099
|
+
Start index of the pasted time region for each example.
|
|
1100
|
+
cut_t_len : torch.Tensor
|
|
1101
|
+
Length of the pasted time region for each example.
|
|
1102
|
+
|
|
1103
|
+
Returns
|
|
1104
|
+
-------
|
|
1105
|
+
tuple
|
|
1106
|
+
``X``, ``y``. Where ``X`` is augmented and ``y`` is a tuple of length
|
|
1107
|
+
3 containing the labels of the two mixed examples and the fraction of
|
|
1108
|
+
each example kept from the original, ``1 - cut_t_len / n_times``.
|
|
1109
|
+
|
|
1110
|
+
References
|
|
1111
|
+
----------
|
|
1112
|
+
.. [1] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun,
|
|
1113
|
+
Junsuk Choe, Youngjoon Yoo (2019). CutMix: Regularization Strategy
|
|
1114
|
+
to Train Strong Classifiers with Localizable Features. In 2019
|
|
1115
|
+
IEEE/CVF International Conference on Computer Vision (ICCV)
|
|
1116
|
+
Online: https://arxiv.org/abs/1905.04899
|
|
1117
|
+
"""
|
|
1118
|
+
n_times = X.shape[-1]
|
|
1119
|
+
t = torch.arange(n_times, device=X.device)
|
|
1120
|
+
start = cut_t_start[:, None]
|
|
1121
|
+
in_cut = (t >= start) & (t < start + cut_t_len[:, None])
|
|
1122
|
+
X_mix = torch.where(in_cut[:, None], X[idx_perm], X)
|
|
1123
|
+
lam = (n_times - cut_t_len).to(X.dtype) / n_times
|
|
1124
|
+
return X_mix, (y.clone(), y[idx_perm].clone(), lam)
|
|
1125
|
+
|
|
1126
|
+
|
|
1078
1127
|
def segmentation_reconstruction(
|
|
1079
1128
|
X: torch.Tensor,
|
|
1080
1129
|
y: torch.Tensor,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# Gustavo Rodrigues <gustavenrique01@gmail.com>
|
|
4
4
|
# Bruna Lopes <brunajaflopes@gmail.com>
|
|
5
5
|
# Sarthak Tayal <sarthaktayal2@gmail.com>
|
|
6
|
+
# Anton Soloviev <anton@praviel.com>
|
|
6
7
|
#
|
|
7
8
|
# License: BSD (3-clause)
|
|
8
9
|
|
|
@@ -24,6 +25,7 @@ from .functional import (
|
|
|
24
25
|
channels_permute,
|
|
25
26
|
channels_rereference,
|
|
26
27
|
channels_shuffle,
|
|
28
|
+
cutmix,
|
|
27
29
|
frequency_shift,
|
|
28
30
|
ft_surrogate,
|
|
29
31
|
gaussian_noise,
|
|
@@ -1095,6 +1097,55 @@ class Mixup(Transform):
|
|
|
1095
1097
|
}
|
|
1096
1098
|
|
|
1097
1099
|
|
|
1100
|
+
class CutMix(Mixup):
|
|
1101
|
+
"""Implements CutMix for EEG data.
|
|
1102
|
+
|
|
1103
|
+
A random time region of each example is replaced by the same region of
|
|
1104
|
+
a shuffled example of the batch, see [1]_. As in the reference code [2]_,
|
|
1105
|
+
a coefficient ``lam`` is drawn from a Beta distribution, the region is
|
|
1106
|
+
``(1 - lam) * n_times`` long (the 1-D analogue of the cut area ratio
|
|
1107
|
+
``1 - lam``) around a uniformly drawn center, it is clipped at the trial
|
|
1108
|
+
boundaries, and ``lam`` is then recomputed from the pasted length.
|
|
1109
|
+
|
|
1110
|
+
Like :class:`Mixup`, it applies to whole batches and returns targets
|
|
1111
|
+
``(y_a, y_b, lam)`` for :func:`braindecode.training.mixup_criterion`.
|
|
1112
|
+
|
|
1113
|
+
Parameters
|
|
1114
|
+
----------
|
|
1115
|
+
alpha : float
|
|
1116
|
+
Parameter of the Beta distribution of ``lam``. ``alpha <= 0`` cuts
|
|
1117
|
+
nothing.
|
|
1118
|
+
beta_per_sample : bool (default=False)
|
|
1119
|
+
By default, one ``lam`` per batch is drawn. If True, one per sample.
|
|
1120
|
+
random_state : int | numpy.random.Generator, optional
|
|
1121
|
+
Seed to be used to instantiate numpy random number generator instance.
|
|
1122
|
+
Defaults to None.
|
|
1123
|
+
|
|
1124
|
+
References
|
|
1125
|
+
----------
|
|
1126
|
+
.. [1] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun,
|
|
1127
|
+
Junsuk Choe, Youngjoon Yoo (2019). CutMix: Regularization Strategy
|
|
1128
|
+
to Train Strong Classifiers with Localizable Features. In 2019
|
|
1129
|
+
IEEE/CVF International Conference on Computer Vision (ICCV)
|
|
1130
|
+
Online: https://arxiv.org/abs/1905.04899
|
|
1131
|
+
.. [2] https://github.com/clovaai/CutMix-PyTorch/blob/master/train.py
|
|
1132
|
+
"""
|
|
1133
|
+
|
|
1134
|
+
operation = staticmethod(cutmix) # type: ignore[assignment]
|
|
1135
|
+
|
|
1136
|
+
def get_augmentation_params(self, *batch):
|
|
1137
|
+
"""Return idx_perm and the cut_t_start, cut_t_len of each region."""
|
|
1138
|
+
params = super().get_augmentation_params(*batch)
|
|
1139
|
+
lam = params.pop("lam")
|
|
1140
|
+
n_times = batch[0].shape[-1]
|
|
1141
|
+
half = ((1 - lam) * n_times).long() // 2
|
|
1142
|
+
center = torch.as_tensor(self.rng.randint(n_times, size=len(lam)))
|
|
1143
|
+
center = center.to(lam.device)
|
|
1144
|
+
start = (center - half).clamp(min=0)
|
|
1145
|
+
end = (center + half).clamp(max=n_times)
|
|
1146
|
+
return dict(params, cut_t_start=start, cut_t_len=end - start)
|
|
1147
|
+
|
|
1148
|
+
|
|
1098
1149
|
class SegmentationReconstruction(Transform):
|
|
1099
1150
|
"""Segmentation Reconstruction from Lotte (2015) [Lotte2015]_.
|
|
1100
1151
|
|
|
@@ -1283,7 +1334,7 @@ class MaskEncoding(Transform):
|
|
|
1283
1334
|
)
|
|
1284
1335
|
|
|
1285
1336
|
time_start = self.rng.randint(
|
|
1286
|
-
0, n_times - segment_length, (batch_size, self.n_segments)
|
|
1337
|
+
0, n_times - segment_length + 1, (batch_size, self.n_segments)
|
|
1287
1338
|
)
|
|
1288
1339
|
time_start = torch.from_numpy(time_start)
|
|
1289
1340
|
|
{braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/datasets/base.py
RENAMED
|
@@ -1281,6 +1281,49 @@ class WindowsDataset(_ZarrMixin, RecordDataset):
|
|
|
1281
1281
|
)
|
|
1282
1282
|
|
|
1283
1283
|
|
|
1284
|
+
def _lazy_source_files(ds) -> list:
|
|
1285
|
+
"""Return the files ``ds`` still reads its signal from (none once preloaded)."""
|
|
1286
|
+
signal = ds.raw if hasattr(ds, "raw") else getattr(ds, "windows", None)
|
|
1287
|
+
if signal is None or getattr(signal, "preload", True):
|
|
1288
|
+
return []
|
|
1289
|
+
files = list(
|
|
1290
|
+
getattr(signal, "filenames", None) or [getattr(signal, "filename", None)]
|
|
1291
|
+
)
|
|
1292
|
+
raw = getattr(signal, "_raw", None)
|
|
1293
|
+
if isinstance(raw, mne.io.BaseRaw) and not raw.preload:
|
|
1294
|
+
files += raw.filenames # mne.Epochs of a lazily read Raw read through it
|
|
1295
|
+
return [f for f in files if f is not None]
|
|
1296
|
+
|
|
1297
|
+
|
|
1298
|
+
def _dir_key(directory):
|
|
1299
|
+
"""Identify a directory by device and inode, whatever its spelling."""
|
|
1300
|
+
stat = os.stat(directory)
|
|
1301
|
+
return stat.st_dev, stat.st_ino
|
|
1302
|
+
|
|
1303
|
+
|
|
1304
|
+
def _overwrite_conflicts(datasets, path, offset):
|
|
1305
|
+
"""Yield ``(i_ds, i_target, target_dir)`` for each dataset ``i_ds`` that
|
|
1306
|
+
lazily reads from inside ``target_dir = path/<i_target + offset>``, which
|
|
1307
|
+
``save(overwrite=True)`` deletes before writing dataset ``i_target``.
|
|
1308
|
+
"""
|
|
1309
|
+
targets = {}
|
|
1310
|
+
for i in range(len(datasets)):
|
|
1311
|
+
target_dir = os.path.join(path, str(i + offset))
|
|
1312
|
+
if os.path.isdir(target_dir):
|
|
1313
|
+
targets[_dir_key(target_dir)] = (i, target_dir)
|
|
1314
|
+
if not targets:
|
|
1315
|
+
return
|
|
1316
|
+
for i_ds, ds in enumerate(datasets):
|
|
1317
|
+
for file in _lazy_source_files(ds):
|
|
1318
|
+
# ancestors of the name and of the file it links to (DataLad)
|
|
1319
|
+
parents = {
|
|
1320
|
+
*Path(os.path.abspath(file)).parents,
|
|
1321
|
+
*Path(os.path.realpath(file)).parents,
|
|
1322
|
+
}
|
|
1323
|
+
for key in {_dir_key(p) for p in parents if p.is_dir()} & targets.keys():
|
|
1324
|
+
yield (i_ds, *targets[key])
|
|
1325
|
+
|
|
1326
|
+
|
|
1284
1327
|
@register_dataset
|
|
1285
1328
|
class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
1286
1329
|
"""A base class for concatenated datasets.
|
|
@@ -1518,7 +1561,9 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1518
1561
|
metadata : pd.DataFrame
|
|
1519
1562
|
DataFrame containing as many rows as there are windows in the
|
|
1520
1563
|
BaseConcatDataset, with the metadata and description information
|
|
1521
|
-
for each window
|
|
1564
|
+
for each window, and an ``i_dataset`` column giving the position
|
|
1565
|
+
in ``datasets`` of the dataset (recording) each window comes from.
|
|
1566
|
+
Samplers use it to keep recordings apart.
|
|
1522
1567
|
"""
|
|
1523
1568
|
if not all(
|
|
1524
1569
|
[
|
|
@@ -1544,9 +1589,15 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1544
1589
|
"Dataset descriptions cannot contain the reserved window "
|
|
1545
1590
|
"metadata key 'i_trial_in_dataset'."
|
|
1546
1591
|
)
|
|
1592
|
+
if "i_dataset" in df.columns or "i_dataset" in ds.description:
|
|
1593
|
+
raise ValueError(
|
|
1594
|
+
"Window metadata and dataset descriptions cannot contain the "
|
|
1595
|
+
"key 'i_dataset', which get_metadata() reserves for the "
|
|
1596
|
+
"position of the dataset each window comes from. Rename it."
|
|
1597
|
+
)
|
|
1547
1598
|
|
|
1548
1599
|
all_dfs = list()
|
|
1549
|
-
for ds in self.datasets:
|
|
1600
|
+
for i_ds, ds in enumerate(self.datasets):
|
|
1550
1601
|
if hasattr(ds, "_windows") and ds._windows is not None:
|
|
1551
1602
|
df = ds._windows.metadata
|
|
1552
1603
|
else:
|
|
@@ -1556,6 +1607,7 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1556
1607
|
df = df.copy()
|
|
1557
1608
|
for k, v in ds.description.items():
|
|
1558
1609
|
df[k] = v
|
|
1610
|
+
df["i_dataset"] = i_ds
|
|
1559
1611
|
all_dfs.append(df)
|
|
1560
1612
|
|
|
1561
1613
|
return pd.concat(all_dfs)
|
|
@@ -1848,6 +1900,11 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1848
1900
|
dataset description.
|
|
1849
1901
|
"""
|
|
1850
1902
|
description = pd.DataFrame(description)
|
|
1903
|
+
if len(description.columns) and len(description) != len(self.datasets):
|
|
1904
|
+
raise ValueError(
|
|
1905
|
+
f"Length of values ({len(description)}) does not match "
|
|
1906
|
+
f"number of datasets ({len(self.datasets)})."
|
|
1907
|
+
)
|
|
1851
1908
|
for key, value in description.items():
|
|
1852
1909
|
for ds, value_ in zip(self.datasets, value):
|
|
1853
1910
|
ds.set_description({key: value_}, overwrite=overwrite)
|
|
@@ -1878,7 +1935,9 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1878
1935
|
-raw.fif | -epo.fif and .json files to.
|
|
1879
1936
|
overwrite : bool
|
|
1880
1937
|
Whether to delete old subdirectories that will be saved to in this
|
|
1881
|
-
call.
|
|
1938
|
+
call. If a dataset still reads its data lazily from one of them, a
|
|
1939
|
+
``ValueError`` is raised before anything is deleted: load the data
|
|
1940
|
+
into memory first (``preload=True``) or save to another directory.
|
|
1882
1941
|
offset : int
|
|
1883
1942
|
If provided, the integer is added to the id of the dataset in the
|
|
1884
1943
|
concat. This is useful in the setting of very large datasets, where
|
|
@@ -1891,6 +1950,13 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1891
1950
|
hasattr(self.datasets[0], "raw") or hasattr(self.datasets[0], "windows")
|
|
1892
1951
|
):
|
|
1893
1952
|
raise ValueError("dataset should have either raw or windows attribute")
|
|
1953
|
+
if overwrite:
|
|
1954
|
+
for _, _, target_dir in _overwrite_conflicts(self.datasets, path, offset):
|
|
1955
|
+
raise ValueError(
|
|
1956
|
+
f"Saving with overwrite=True would delete {target_dir} while "
|
|
1957
|
+
"a dataset still reads its data from it. Load the data into "
|
|
1958
|
+
"memory first (preload=True) or save to another directory."
|
|
1959
|
+
)
|
|
1894
1960
|
|
|
1895
1961
|
# Create path if it doesn't exist
|
|
1896
1962
|
os.makedirs(path, exist_ok=True)
|
{braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/eegneuralnet.py
RENAMED
|
@@ -201,12 +201,17 @@ class _EEGNeuralNet(NeuralNet, abc.ABC):
|
|
|
201
201
|
if classes is None:
|
|
202
202
|
classes = getattr(self, "classes", None)
|
|
203
203
|
signal_kwargs = infer_signal_properties(X, y, mode=self.mode, classes=classes)
|
|
204
|
+
module = _get_model(self.module)
|
|
205
|
+
# Model-specific values computed from the data (e.g. GCNsNet's graph);
|
|
206
|
+
# the signal properties take precedence.
|
|
207
|
+
infer_model_kwargs = getattr(module, "_infer_model_kwargs", None)
|
|
208
|
+
if infer_model_kwargs is not None:
|
|
209
|
+
signal_kwargs = {**infer_model_kwargs(X, y), **signal_kwargs}
|
|
204
210
|
if not signal_kwargs:
|
|
205
211
|
return
|
|
206
212
|
|
|
207
213
|
# kick out missing kwargs:
|
|
208
214
|
module_kwargs = dict()
|
|
209
|
-
module = _get_model(self.module)
|
|
210
215
|
all_module_kwargs = inspect.signature(module.__init__).parameters.keys()
|
|
211
216
|
for k, v in signal_kwargs.items():
|
|
212
217
|
if v is None:
|
|
@@ -12,8 +12,10 @@ never downcast, so callers wrap the numerically sensitive parts with
|
|
|
12
12
|
#
|
|
13
13
|
# License: BSD (3-clause)
|
|
14
14
|
import functools
|
|
15
|
+
from typing import Optional
|
|
15
16
|
|
|
16
17
|
import torch
|
|
18
|
+
from torch import nn
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
def needs_real_dft(x: torch.Tensor) -> bool:
|
|
@@ -136,3 +138,56 @@ def hilbert_freq_real(x: torch.Tensor, forward_fourier: bool) -> torch.Tensor:
|
|
|
136
138
|
return torch.stack((out_real, out_imag), dim=-1)
|
|
137
139
|
|
|
138
140
|
return compute(x)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@torch.jit.unused
|
|
144
|
+
def fft_conv1d_real(
|
|
145
|
+
x: torch.Tensor, weight: torch.Tensor, bias: Optional[torch.Tensor]
|
|
146
|
+
) -> torch.Tensor:
|
|
147
|
+
"""Real-valued equivalent of :func:`braindecode.functional.fft_conv1d`.
|
|
148
|
+
|
|
149
|
+
Overlap-save: the input is cut into blocks of ``n`` samples (the power of
|
|
150
|
+
two ``>= 2 * kernel_size``) that advance by ``n - kernel_size + 1`` outputs,
|
|
151
|
+
each block's DFT is a matmul against the cosine/sine basis, and per
|
|
152
|
+
frequency the complex product with the kernels, summed over the input
|
|
153
|
+
channels, is one real matmul.
|
|
154
|
+
"""
|
|
155
|
+
|
|
156
|
+
@fp32_island
|
|
157
|
+
def compute(x, weight):
|
|
158
|
+
n_times, kernel_size = x.shape[-1], weight.shape[-1]
|
|
159
|
+
n = 1 << (2 * kernel_size - 1).bit_length()
|
|
160
|
+
hop = n - kernel_size + 1
|
|
161
|
+
n_blocks = -(-n_times // hop)
|
|
162
|
+
n_freqs = n // 2 + 1
|
|
163
|
+
# "same" alignment: torch pads the extra zero of an even kernel on the right
|
|
164
|
+
left = (kernel_size - 1) // 2
|
|
165
|
+
x = nn.functional.pad(x, (left, (n_blocks + 1) * hop - n_times - left))
|
|
166
|
+
hops = x.unflatten(-1, (n_blocks + 1, hop))
|
|
167
|
+
# block i = hop i + the first kernel_size - 1 samples of hop i + 1
|
|
168
|
+
blocks = torch.cat([hops[:, :, :-1], hops[:, :, 1:, : kernel_size - 1]], -1)
|
|
169
|
+
cosine, sine = real_dft_basis(n, device=x.device, dtype=x.dtype)
|
|
170
|
+
basis = torch.cat([cosine, -sine]).transpose(0, 1) # -> [Re | Im] of rfft
|
|
171
|
+
x_f = blocks @ basis # (batch, in, blocks, 2 * n_freqs)
|
|
172
|
+
w_f = nn.functional.pad(weight.to(x), (0, n - kernel_size)) @ basis
|
|
173
|
+
w_re, w_im = w_f[..., :n_freqs], w_f[..., n_freqs:]
|
|
174
|
+
# conv1d is a cross-correlation: x_f * conj(w_f), summed over the input
|
|
175
|
+
# channels. Per frequency [Re x, Im x] @ [[Re w, -Im w], [Im w, Re w]].
|
|
176
|
+
w_f = torch.cat([torch.cat([w_re, -w_im]), torch.cat([w_im, w_re])], 1)
|
|
177
|
+
x_f = x_f.unflatten(-1, (2, n_freqs)).permute(4, 0, 2, 3, 1).flatten(1, 2)
|
|
178
|
+
y_f = torch.bmm(x_f.flatten(2), w_f.permute(2, 1, 0)) # (freq, ., 2 * out)
|
|
179
|
+
y_f = y_f.unflatten(1, (x.shape[0], n_blocks)).unflatten(-1, (2, -1))
|
|
180
|
+
y_f = y_f.permute(1, 4, 2, 3, 0).flatten(
|
|
181
|
+
-2
|
|
182
|
+
) # (batch, out, blocks, 2 * n_freqs)
|
|
183
|
+
# inverse DFT of the first `hop` samples, the ones without wrap-around
|
|
184
|
+
scale = torch.full((n_freqs, 1), 2.0 / n, dtype=x.dtype, device=x.device)
|
|
185
|
+
scale[0] = 1.0 / n
|
|
186
|
+
scale[-1] = 1.0 / n # Nyquist (n is even)
|
|
187
|
+
inverse = torch.cat([scale * cosine[:, :hop], -scale * sine[:, :hop]])
|
|
188
|
+
return (y_f @ inverse).flatten(-2)[..., :n_times]
|
|
189
|
+
|
|
190
|
+
y = compute(x, weight)
|
|
191
|
+
if bias is not None:
|
|
192
|
+
y = y + bias.to(y).unsqueeze(-1)
|
|
193
|
+
return y.to(x)
|
|
@@ -62,9 +62,10 @@ def fft_conv1d(
|
|
|
62
62
|
|
|
63
63
|
Equal to the direct convolution up to float rounding: the FFT is long
|
|
64
64
|
enough for a linear (not circular) convolution. Its cost barely grows with
|
|
65
|
-
the kernel size, so it is faster than the direct one for long kernels
|
|
66
|
-
|
|
67
|
-
float32 (:func:`spectral_input`) and cast back.
|
|
65
|
+
the kernel size, so it is faster than the direct one for long kernels
|
|
66
|
+
(see :func:`prefer_fft_conv`). float16/bfloat16 inputs are computed in
|
|
67
|
+
float32 (:func:`spectral_input`) and cast back. On Intel Gaudi (HPU, no
|
|
68
|
+
complex dtype) the DFTs are real matmuls over overlapping blocks.
|
|
68
69
|
|
|
69
70
|
Parameters
|
|
70
71
|
----------
|
|
@@ -82,22 +83,35 @@ def fft_conv1d(
|
|
|
82
83
|
``x``. For an even ``kernel_size`` it is aligned like torch's
|
|
83
84
|
``padding="same"`` (the extra zero padded on the right).
|
|
84
85
|
"""
|
|
86
|
+
if _real_dft.needs_real_dft(x):
|
|
87
|
+
return _real_dft.fft_conv1d_real(x, weight, bias)
|
|
85
88
|
n_times, kernel_size = x.shape[-1], weight.shape[-1]
|
|
86
89
|
# >= n_times + kernel_size - 1 (no circular wrap-around), even and
|
|
87
90
|
# 5-smooth: the fast cases of a real FFT
|
|
88
91
|
n_fft = 2 * _next_fast_len((n_times + kernel_size) // 2)
|
|
89
92
|
xs = spectral_input(x)
|
|
90
93
|
# conv1d is a cross-correlation: a convolution with the flipped kernel
|
|
91
|
-
x_f = torch.fft.rfft(xs, n=n_fft)
|
|
94
|
+
x_f = torch.fft.rfft(xs, n=n_fft) # (batch, in, freq)
|
|
92
95
|
w_f = torch.fft.rfft(weight.to(xs).flip(-1), n=n_fft).permute(2, 1, 0)
|
|
93
96
|
# Per frequency (batch, in) @ (in, out) in complex numbers, as one real
|
|
94
|
-
# matmul (a complex one is slower on CPU)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
# matmul (a complex one is slower on CPU).
|
|
98
|
+
needs_grad = torch.is_grad_enabled() and (x.requires_grad or weight.requires_grad)
|
|
99
|
+
if needs_grad or x.shape[0] >= 2 * x.shape[1]:
|
|
100
|
+
# [Re x, Im x] @ [[Re w, Im w], [-Im w, Re w]] (rows of i * w): the
|
|
101
|
+
# output columns are the (Re, Im) pairs of the result, read as complex
|
|
102
|
+
# without a copy (and without a costly backward).
|
|
103
|
+
w_mat = torch.view_as_real(torch.stack([w_f, w_f * 1j], 1)).flatten(1, 2)
|
|
104
|
+
y_f = torch.view_as_real(x_f).permute(2, 0, 3, 1).flatten(2) @ w_mat.flatten(2)
|
|
105
|
+
y_f = torch.view_as_complex(y_f.unflatten(-1, [-1, 2]))
|
|
106
|
+
else:
|
|
107
|
+
# Forward only with fewer rows than twice the input channels: the
|
|
108
|
+
# doubled weight costs more than combining [Re x; Im x] @ [Re w, Im w].
|
|
109
|
+
x_f = x_f.permute(2, 0, 1)
|
|
110
|
+
p = torch.cat([x_f.real, x_f.imag], 1) @ torch.view_as_real(w_f).flatten(2)
|
|
111
|
+
p = p.unflatten(1, [2, x.shape[0]]).unflatten(3, [-1, 2])
|
|
112
|
+
y_f = torch.complex(
|
|
113
|
+
p[:, 0, :, :, 0] - p[:, 1, :, :, 1], p[:, 0, :, :, 1] + p[:, 1, :, :, 0]
|
|
114
|
+
)
|
|
101
115
|
y = torch.fft.irfft(y_f.permute(1, 2, 0), n=n_fft)
|
|
102
116
|
# "same" output t is sample t + kernel_size // 2 of the full convolution
|
|
103
117
|
y = y[..., kernel_size // 2 : kernel_size // 2 + n_times]
|
|
@@ -115,8 +129,11 @@ def prefer_fft_conv(x: torch.Tensor, kernel_size: int) -> bool:
|
|
|
115
129
|
and from ``batch_size * kernel_size >= 600`` if also
|
|
116
130
|
``in_channels * kernel_size >= 120``: with one or two input channels a
|
|
117
131
|
float32 direct convolution stays cheaper up to k = 85 / 31 (13 long
|
|
118
|
-
temporal convolutions of the model zoo, 22 channels x batch 32).
|
|
119
|
-
|
|
132
|
+
temporal convolutions of the model zoo, 22 channels x batch 32). On Intel
|
|
133
|
+
Gaudi (HPU) a direct convolution costs about ``batch_size * n_times *
|
|
134
|
+
kernel_size`` and the FFT about a fixed few milliseconds in eager mode: the
|
|
135
|
+
FFT wins from 8 input channels and ``batch_size * n_times * kernel_size >=
|
|
136
|
+
8e6``. GPUs keep the direct convolution.
|
|
120
137
|
|
|
121
138
|
Parameters
|
|
122
139
|
----------
|
|
@@ -125,6 +142,8 @@ def prefer_fft_conv(x: torch.Tensor, kernel_size: int) -> bool:
|
|
|
125
142
|
kernel_size : int
|
|
126
143
|
Kernel length in samples.
|
|
127
144
|
"""
|
|
145
|
+
if x.device.type == "hpu":
|
|
146
|
+
return x.shape[1] >= 8 and x.shape[0] * x.shape[-1] * kernel_size >= 8e6
|
|
128
147
|
return x.device.type == "cpu" and (
|
|
129
148
|
x.element_size() == 2
|
|
130
149
|
or (x.shape[0] * kernel_size >= 600 and x.shape[1] * kernel_size >= 120)
|
{braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/__init__.py
RENAMED
|
@@ -22,6 +22,7 @@ from .deep4 import Deep4Net
|
|
|
22
22
|
from .deepsleepnet import DeepSleepNet
|
|
23
23
|
from .dgcnn import DGCNN
|
|
24
24
|
from .diver1 import DIVER1
|
|
25
|
+
from .duin import DuIN
|
|
25
26
|
from .eeg_clip import EEGCLIP
|
|
26
27
|
from .eegconformer import EEGConformer
|
|
27
28
|
from .eegdino import EEGDINO
|
|
@@ -36,9 +37,11 @@ from .eegsimpleconv import EEGSimpleConv
|
|
|
36
37
|
from .eegsym import EEGSym
|
|
37
38
|
from .eegtcnet import EEGTCNet
|
|
38
39
|
from .emg2qwerty import EMG2QwertyNet
|
|
40
|
+
from .epint import EpiNT
|
|
39
41
|
from .fbcnet import FBCNet
|
|
40
42
|
from .fblightconvnet import FBLightConvNet
|
|
41
43
|
from .fbmsnet import FBMSNet
|
|
44
|
+
from .gcnsnet import GCNsNet
|
|
42
45
|
from .guetschel2026 import Guetschel2026
|
|
43
46
|
from .hybrid import HybridNet
|
|
44
47
|
from .ifnet import IFNet
|
|
@@ -117,6 +120,7 @@ __all__ = [
|
|
|
117
120
|
"Deep4Net",
|
|
118
121
|
"DeepSleepNet",
|
|
119
122
|
"DIVER1",
|
|
123
|
+
"DuIN",
|
|
120
124
|
"BrainModule",
|
|
121
125
|
"Brant",
|
|
122
126
|
"EEGCLIP",
|
|
@@ -134,12 +138,14 @@ __all__ = [
|
|
|
134
138
|
"EEGTCNet",
|
|
135
139
|
"DGCNN",
|
|
136
140
|
"EMG2QwertyNet",
|
|
141
|
+
"EpiNT",
|
|
137
142
|
"NeuroPose",
|
|
138
143
|
"SensingDynamics",
|
|
139
144
|
"VEMG2Pose",
|
|
140
145
|
"FBCNet",
|
|
141
146
|
"FBLightConvNet",
|
|
142
147
|
"FBMSNet",
|
|
148
|
+
"GCNsNet",
|
|
143
149
|
"Guetschel2026",
|
|
144
150
|
"MetaNeuromotorHand",
|
|
145
151
|
"HybridNet",
|
{braindecode-1.8.1.dev178298903 → braindecode-1.8.1.dev178305276}/braindecode/models/axon.py
RENAMED
|
@@ -14,6 +14,7 @@ from torch import nn
|
|
|
14
14
|
from braindecode.functional import sinusoidal_positional_encoding
|
|
15
15
|
from braindecode.models.base import EEGModuleMixin
|
|
16
16
|
from braindecode.models.util import warn_if_sfreq_differs
|
|
17
|
+
from braindecode.modules.attention import _scaled_dot_product_attention
|
|
17
18
|
from braindecode.modules.channels import _resolve
|
|
18
19
|
|
|
19
20
|
|
|
@@ -462,11 +463,33 @@ class _AxisAttention(nn.Module):
|
|
|
462
463
|
.unbind(0)
|
|
463
464
|
)
|
|
464
465
|
drop = self.att_drop_prob if self.training else 0.0
|
|
465
|
-
attended =
|
|
466
|
+
attended = _scaled_dot_product_attention(
|
|
466
467
|
query, key, value, attn_mask=mask, dropout_p=drop
|
|
467
468
|
)
|
|
468
469
|
return attended.transpose(1, 2).reshape(n_seq, length, -1)
|
|
469
470
|
|
|
471
|
+
def _attend_two_scales(
|
|
472
|
+
self, projected: torch.Tensor, band: torch.Tensor, weights: torch.Tensor
|
|
473
|
+
) -> torch.Tensor:
|
|
474
|
+
"""Banded and full attention from one score matrix, mixed per query.
|
|
475
|
+
|
|
476
|
+
``weights`` (N, L, 2) are the scale-gate weights. Both softmaxes share
|
|
477
|
+
the scores and one product with the values serves the mixture.
|
|
478
|
+
"""
|
|
479
|
+
n_seq, length, _ = projected.shape
|
|
480
|
+
query, key, value = (
|
|
481
|
+
projected.reshape(n_seq, length, 3, self.num_heads, self.head_dim)
|
|
482
|
+
.permute(2, 0, 3, 1, 4)
|
|
483
|
+
.unbind(0)
|
|
484
|
+
)
|
|
485
|
+
scores = torch.matmul(query, key.transpose(-2, -1)) * self.head_dim**-0.5
|
|
486
|
+
weights = weights.reshape(n_seq, 1, length, 2)
|
|
487
|
+
probs = weights[..., 0:1] * scores.masked_fill(~band, float("-inf")).softmax(
|
|
488
|
+
-1
|
|
489
|
+
) + weights[..., 1:2] * scores.softmax(-1)
|
|
490
|
+
attended = torch.matmul(probs, value)
|
|
491
|
+
return attended.transpose(1, 2).reshape(n_seq, length, -1)
|
|
492
|
+
|
|
470
493
|
def forward(self, x: torch.Tensor, band: Optional[torch.Tensor]) -> torch.Tensor:
|
|
471
494
|
batch, n_chans, n_patches, dim = x.shape
|
|
472
495
|
axis_weights = self.axis_gate(x) # (B, C, P, 2)
|
|
@@ -476,15 +499,26 @@ class _AxisAttention(nn.Module):
|
|
|
476
499
|
# the restricted branch is the full one; attend once unless the two
|
|
477
500
|
# branches draw their own attention dropout.
|
|
478
501
|
per_channel = self.temporal_qkv(x.reshape(batch * n_chans, n_patches, dim))
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
502
|
+
dropout = self.training and self.att_drop_prob > 0
|
|
503
|
+
if band is not None and not dropout:
|
|
504
|
+
# The scale-gate weights sum to one, so the two branches share the
|
|
505
|
+
# scores, the product with the values and temporal_out.
|
|
506
|
+
attended = self._attend_two_scales(per_channel, band, scale_weights)
|
|
507
|
+
temporal = self.temporal_out(attended).reshape(
|
|
485
508
|
batch, n_chans, n_patches, dim
|
|
486
509
|
)
|
|
487
|
-
|
|
510
|
+
else:
|
|
511
|
+
restricted = self.temporal_out(self._attend(per_channel, band)).reshape(
|
|
512
|
+
batch, n_chans, n_patches, dim
|
|
513
|
+
)
|
|
514
|
+
full = restricted
|
|
515
|
+
if dropout:
|
|
516
|
+
full = self.temporal_out(self._attend(per_channel, None)).reshape(
|
|
517
|
+
batch, n_chans, n_patches, dim
|
|
518
|
+
)
|
|
519
|
+
temporal = (
|
|
520
|
+
scale_weights[..., 0:1] * restricted + scale_weights[..., 1:2] * full
|
|
521
|
+
)
|
|
488
522
|
|
|
489
523
|
# Spatial path: one sequence of C tokens per time step.
|
|
490
524
|
per_step = self.spatial_qkv(
|