braindecode 1.8.1.dev177462534__tar.gz → 1.8.1.dev177618751__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.dev177462534 → braindecode-1.8.1.dev177618751}/NOTICE.txt +3 -0
- {braindecode-1.8.1.dev177462534/braindecode.egg-info → braindecode-1.8.1.dev177618751}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/augmentation/__init__.py +2 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/augmentation/base.py +7 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/augmentation/functional.py +85 -10
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/augmentation/transforms.py +63 -3
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/base.py +118 -7
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/mne.py +5 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/tuh.py +2 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datautil/serialization.py +11 -4
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/eegneuralnet.py +6 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/functional/_real_dft.py +55 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/functional/functions.py +32 -13
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/__init__.py +6 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/atcnet.py +11 -8
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/axon.py +42 -8
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/barista.py +25 -13
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/base.py +30 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/biot.py +4 -2
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/brainmodule.py +13 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/brant.py +18 -7
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/codebrain.py +108 -26
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/contrawr.py +23 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/csbrain.py +93 -48
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/ctnet.py +18 -4
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/diver1.py +51 -59
- braindecode-1.8.1.dev177618751/braindecode/models/duin.py +454 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eeg_clip.py +71 -9
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegconformer.py +14 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eeginception_mi.py +7 -3
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegnex.py +7 -3
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegpt.py +15 -9
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegsym.py +68 -16
- braindecode-1.8.1.dev177618751/braindecode/models/epint.py +315 -0
- braindecode-1.8.1.dev177618751/braindecode/models/gcnsnet.py +338 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/guetschel2026.py +8 -8
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/labram.py +19 -9
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/luna.py +7 -4
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/medformer.py +47 -20
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/meta_neuromotor.py +32 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/mirepnet.py +15 -4
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/mscformer.py +21 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/msvtnet.py +115 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/neurorvq.py +118 -31
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/neurorvq_tokenizer.py +40 -11
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/patchedtransformer.py +3 -7
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/reve.py +127 -43
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/signal_jepa.py +81 -3
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/sinc_shallow.py +2 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/sleepfm.py +62 -12
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/steegformer.py +16 -9
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/summary.csv +3 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/tfm_tokenizer.py +44 -3
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/util.py +8 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/zuna.py +11 -9
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/__init__.py +2 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/attention.py +149 -25
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/blocks.py +59 -7
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/channels.py +77 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/dance_modules.py +16 -3
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/layers.py +41 -2
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/quantization.py +5 -5
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/preprocessing/eegprep_preprocess.py +6 -3
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/preprocessing/preprocess.py +19 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/preprocessing/windowers.py +28 -17
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/regressor.py +6 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/samplers/base.py +73 -63
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/training/losses.py +5 -4
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/training/scoring.py +4 -1
- braindecode-1.8.1.dev177618751/braindecode/version.py +1 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751/braindecode.egg-info}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode.egg-info/SOURCES.txt +3 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/api.rst +11 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/whats_new.rst +154 -0
- braindecode-1.8.1.dev177462534/braindecode/version.py +0 -1
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/LICENSE.txt +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/MANIFEST.in +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/README.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/__init__.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/classifier.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bids/format.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/chb_mit.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/collate.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/siena.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/utils.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datautil/util.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/functional/__init__.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/functional/initialization.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/attn_sleep.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/bendr.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/brainbert.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/brainomni.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/cbramod.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/config.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/dance.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/deep4.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/dgcnn.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegdino.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eeginception_erp.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegitnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegminer.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/emg2qwerty.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/ifnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/mapa.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/mvpformer.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/neuropose.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/popt.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/sensingdynamics.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/shallow_fbcsp.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/sleep_stager_blanco_2020.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/sparcnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/sstdpn.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/syncnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/tcformer.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/tcn.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/tidnet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/tmsanet.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/usleep.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/models/vemg2pose.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/activation.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/convolution.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/filter.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/linear.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/linear_attention.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/parametrization.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/popt_modules.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/stats.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/util.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/training/__init__.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/util.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/visualization/activations.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/visualization/attribution.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/visualization/frequency.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/visualization/metrics.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/visualization/sanity.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/visualization/topology.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode.egg-info/requires.txt +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/Makefile +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/agent_docs.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/cite.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/conf.py +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/help.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/index.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/install/install.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/install/install_pip.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/install/install_source.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/models.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/models_categorization.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/models_table.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/docs/user_guide/channel_strategies.rst +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/pyproject.toml +0 -0
- {braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/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.dev177462534/braindecode.egg-info → braindecode-1.8.1.dev177618751}/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.dev177618751
|
|
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",
|
{braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/augmentation/base.py
RENAMED
|
@@ -171,7 +171,13 @@ class Compose(Transform):
|
|
|
171
171
|
self.transforms = transforms
|
|
172
172
|
super().__init__()
|
|
173
173
|
|
|
174
|
-
def forward(self, X, y):
|
|
174
|
+
def forward(self, X, y=None):
|
|
175
|
+
# like Transform.forward, return only X when no target is given (each
|
|
176
|
+
# transform then returns a single tensor, not an (X, y) pair)
|
|
177
|
+
if y is None:
|
|
178
|
+
for transform in self.transforms:
|
|
179
|
+
X = transform(X)
|
|
180
|
+
return X
|
|
175
181
|
for transform in self.transforms:
|
|
176
182
|
X, y = transform(X, y)
|
|
177
183
|
return X, y
|
|
@@ -22,6 +22,21 @@ from torch.fft import fft, ifft
|
|
|
22
22
|
from torch.nn.functional import pad
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
def _max_float_dtype(device: torch.device | str) -> torch.dtype:
|
|
26
|
+
"""float64, or float32 on Apple MPS, which has no float64."""
|
|
27
|
+
return torch.float32 if torch.device(device).type == "mps" else torch.float64
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _to_device(t: torch.Tensor, device: torch.device | str) -> torch.Tensor:
|
|
31
|
+
"""Move ``t`` to ``device``, in single precision on MPS (no float64 there)."""
|
|
32
|
+
if torch.device(device).type == "mps":
|
|
33
|
+
if t.dtype == torch.float64:
|
|
34
|
+
return t.float().to(device)
|
|
35
|
+
if t.dtype == torch.complex128:
|
|
36
|
+
return t.to(torch.complex64).to(device)
|
|
37
|
+
return t.to(device)
|
|
38
|
+
|
|
39
|
+
|
|
25
40
|
def identity(X: torch.Tensor, y: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:
|
|
26
41
|
"""Identity operation.
|
|
27
42
|
|
|
@@ -92,10 +107,11 @@ def _new_random_fft_phase_odd(
|
|
|
92
107
|
rng = check_random_state(random_state)
|
|
93
108
|
random_phase = torch.from_numpy(
|
|
94
109
|
2j * np.pi * rng.random((batch_size, c, (n - 1) // 2))
|
|
95
|
-
)
|
|
110
|
+
)
|
|
111
|
+
random_phase = _to_device(random_phase, device)
|
|
96
112
|
return torch.cat(
|
|
97
113
|
[
|
|
98
|
-
torch.zeros((batch_size, c, 1), device=device),
|
|
114
|
+
torch.zeros((batch_size, c, 1), device=device, dtype=random_phase.dtype),
|
|
99
115
|
random_phase,
|
|
100
116
|
-torch.flip(random_phase, [-1]),
|
|
101
117
|
],
|
|
@@ -113,12 +129,13 @@ def _new_random_fft_phase_even(
|
|
|
113
129
|
rng = check_random_state(random_state)
|
|
114
130
|
random_phase = torch.from_numpy(
|
|
115
131
|
2j * np.pi * rng.random((batch_size, c, n // 2 - 1))
|
|
116
|
-
)
|
|
132
|
+
)
|
|
133
|
+
random_phase = _to_device(random_phase, device)
|
|
117
134
|
return torch.cat(
|
|
118
135
|
[
|
|
119
|
-
torch.zeros((batch_size, c, 1), device=device),
|
|
136
|
+
torch.zeros((batch_size, c, 1), device=device, dtype=random_phase.dtype),
|
|
120
137
|
random_phase,
|
|
121
|
-
torch.zeros((batch_size, c, 1), device=device),
|
|
138
|
+
torch.zeros((batch_size, c, 1), device=device, dtype=random_phase.dtype),
|
|
122
139
|
-torch.flip(random_phase, [-1]),
|
|
123
140
|
],
|
|
124
141
|
dim=-1,
|
|
@@ -178,7 +195,7 @@ def ft_surrogate(
|
|
|
178
195
|
and 0 <= phase_noise_magnitude <= 1
|
|
179
196
|
), f"eps must be a float between 0 and 1. Got {phase_noise_magnitude}."
|
|
180
197
|
|
|
181
|
-
f = fft(X.
|
|
198
|
+
f = fft(X.to(_max_float_dtype(X.device)), dim=-1)
|
|
182
199
|
device = X.device
|
|
183
200
|
|
|
184
201
|
n = f.shape[-1]
|
|
@@ -580,6 +597,7 @@ def _frequency_shift(X: torch.Tensor, fs: float, f_shift: float) -> torch.Tensor
|
|
|
580
597
|
_f_shift = torch.as_tensor(f_shift).float()
|
|
581
598
|
else:
|
|
582
599
|
raise ValueError(f"Invalid f_shift type: {type(f_shift)}")
|
|
600
|
+
_f_shift = _f_shift.to(X.device)
|
|
583
601
|
f_shift_stack = _f_shift.repeat(N_padded, n_channels, 1)
|
|
584
602
|
reshaped_f_shift = f_shift_stack.permute(
|
|
585
603
|
*torch.arange(f_shift_stack.ndim - 1, -1, -1)
|
|
@@ -911,7 +929,15 @@ def _rotate_signals(
|
|
|
911
929
|
sensors_positions_matrix: torch.Tensor,
|
|
912
930
|
spherical: bool = True,
|
|
913
931
|
) -> torch.Tensor:
|
|
914
|
-
|
|
932
|
+
if X.device.type == "mps":
|
|
933
|
+
# MPS has no float64: compute the small (n_chans x n_chans) spherical
|
|
934
|
+
# spline matrices on CPU in double precision, only move the result
|
|
935
|
+
# (two separate steps: a combined device + dtype .to() from MPS
|
|
936
|
+
# returns zeros with some torch versions)
|
|
937
|
+
sensors_positions_matrix = sensors_positions_matrix.cpu().double()
|
|
938
|
+
rotations = [rotation.cpu().double() for rotation in rotations]
|
|
939
|
+
else:
|
|
940
|
+
sensors_positions_matrix = sensors_positions_matrix.to(X.device)
|
|
915
941
|
rot_sensors_matrices = [
|
|
916
942
|
rotation.matmul(sensors_positions_matrix) for rotation in rotations
|
|
917
943
|
]
|
|
@@ -921,9 +947,10 @@ def _rotate_signals(
|
|
|
921
947
|
torch.as_tensor(
|
|
922
948
|
_torch_make_interpolation_matrix(
|
|
923
949
|
sensors_positions_matrix.T, rot_sensors_matrix.T
|
|
924
|
-
)
|
|
925
|
-
|
|
926
|
-
|
|
950
|
+
)
|
|
951
|
+
)
|
|
952
|
+
.float()
|
|
953
|
+
.to(X.device)
|
|
927
954
|
for rot_sensors_matrix in rot_sensors_matrices
|
|
928
955
|
]
|
|
929
956
|
)
|
|
@@ -1075,6 +1102,54 @@ def mixup(
|
|
|
1075
1102
|
return X_mix, (y_a, y_b, lam)
|
|
1076
1103
|
|
|
1077
1104
|
|
|
1105
|
+
def cutmix(
|
|
1106
|
+
X: torch.Tensor,
|
|
1107
|
+
y: torch.Tensor,
|
|
1108
|
+
idx_perm: torch.Tensor,
|
|
1109
|
+
cut_t_start: torch.Tensor,
|
|
1110
|
+
cut_t_len: torch.Tensor,
|
|
1111
|
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
|
1112
|
+
"""Paste a time region of shuffled examples into the original examples.
|
|
1113
|
+
|
|
1114
|
+
See [1]_ for details.
|
|
1115
|
+
|
|
1116
|
+
Parameters
|
|
1117
|
+
----------
|
|
1118
|
+
X : torch.Tensor
|
|
1119
|
+
EEG data in form ``batch_size, n_channels, n_times``
|
|
1120
|
+
y : torch.Tensor
|
|
1121
|
+
Target of length ``batch_size``
|
|
1122
|
+
idx_perm : torch.Tensor
|
|
1123
|
+
Permuted indices of example that are mixed into original examples.
|
|
1124
|
+
cut_t_start : torch.Tensor
|
|
1125
|
+
Start index of the pasted time region for each example.
|
|
1126
|
+
cut_t_len : torch.Tensor
|
|
1127
|
+
Length of the pasted time region for each example.
|
|
1128
|
+
|
|
1129
|
+
Returns
|
|
1130
|
+
-------
|
|
1131
|
+
tuple
|
|
1132
|
+
``X``, ``y``. Where ``X`` is augmented and ``y`` is a tuple of length
|
|
1133
|
+
3 containing the labels of the two mixed examples and the fraction of
|
|
1134
|
+
each example kept from the original, ``1 - cut_t_len / n_times``.
|
|
1135
|
+
|
|
1136
|
+
References
|
|
1137
|
+
----------
|
|
1138
|
+
.. [1] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun,
|
|
1139
|
+
Junsuk Choe, Youngjoon Yoo (2019). CutMix: Regularization Strategy
|
|
1140
|
+
to Train Strong Classifiers with Localizable Features. In 2019
|
|
1141
|
+
IEEE/CVF International Conference on Computer Vision (ICCV)
|
|
1142
|
+
Online: https://arxiv.org/abs/1905.04899
|
|
1143
|
+
"""
|
|
1144
|
+
n_times = X.shape[-1]
|
|
1145
|
+
t = torch.arange(n_times, device=X.device)
|
|
1146
|
+
start = cut_t_start[:, None]
|
|
1147
|
+
in_cut = (t >= start) & (t < start + cut_t_len[:, None])
|
|
1148
|
+
X_mix = torch.where(in_cut[:, None], X[idx_perm], X)
|
|
1149
|
+
lam = (n_times - cut_t_len).to(X.dtype) / n_times
|
|
1150
|
+
return X_mix, (y.clone(), y[idx_perm].clone(), lam)
|
|
1151
|
+
|
|
1152
|
+
|
|
1078
1153
|
def segmentation_reconstruction(
|
|
1079
1154
|
X: torch.Tensor,
|
|
1080
1155
|
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
|
|
|
@@ -17,6 +18,7 @@ from braindecode.util import resolve_montage_name
|
|
|
17
18
|
|
|
18
19
|
from .base import Transform
|
|
19
20
|
from .functional import (
|
|
21
|
+
_max_float_dtype,
|
|
20
22
|
amplitude_scale,
|
|
21
23
|
band_rotation,
|
|
22
24
|
bandstop_filter,
|
|
@@ -24,6 +26,7 @@ from .functional import (
|
|
|
24
26
|
channels_permute,
|
|
25
27
|
channels_rereference,
|
|
26
28
|
channels_shuffle,
|
|
29
|
+
cutmix,
|
|
27
30
|
frequency_shift,
|
|
28
31
|
ft_surrogate,
|
|
29
32
|
gaussian_noise,
|
|
@@ -492,6 +495,7 @@ class SmoothTimeMask(Transform):
|
|
|
492
495
|
size=X.shape[0],
|
|
493
496
|
),
|
|
494
497
|
device=X.device,
|
|
498
|
+
dtype=_max_float_dtype(X.device),
|
|
495
499
|
) * (seq_length - mask_len_samples)
|
|
496
500
|
return {
|
|
497
501
|
"mask_start_per_sample": mask_start,
|
|
@@ -673,7 +677,11 @@ class FrequencyShift(Transform):
|
|
|
673
677
|
return super().get_augmentation_params(*batch)
|
|
674
678
|
X = batch[0]
|
|
675
679
|
|
|
676
|
-
u = torch.as_tensor(
|
|
680
|
+
u = torch.as_tensor(
|
|
681
|
+
self.rng.uniform(size=X.shape[0]),
|
|
682
|
+
device=X.device,
|
|
683
|
+
dtype=_max_float_dtype(X.device),
|
|
684
|
+
)
|
|
677
685
|
max_delta_freq = self.max_delta_freq
|
|
678
686
|
if isinstance(max_delta_freq, torch.Tensor):
|
|
679
687
|
max_delta_freq = max_delta_freq.to(X.device)
|
|
@@ -831,7 +839,10 @@ class SensorsRotation(Transform):
|
|
|
831
839
|
if isinstance(max_degrees, torch.Tensor):
|
|
832
840
|
max_degrees = max_degrees.to(X.device)
|
|
833
841
|
random_angles = (
|
|
834
|
-
torch.as_tensor(u, device=X.device)
|
|
842
|
+
torch.as_tensor(u, device=X.device, dtype=_max_float_dtype(X.device))
|
|
843
|
+
* 2
|
|
844
|
+
* max_degrees
|
|
845
|
+
- max_degrees
|
|
835
846
|
)
|
|
836
847
|
return {
|
|
837
848
|
"sensors_positions_matrix": self.sensors_positions_matrix,
|
|
@@ -1095,6 +1106,55 @@ class Mixup(Transform):
|
|
|
1095
1106
|
}
|
|
1096
1107
|
|
|
1097
1108
|
|
|
1109
|
+
class CutMix(Mixup):
|
|
1110
|
+
"""Implements CutMix for EEG data.
|
|
1111
|
+
|
|
1112
|
+
A random time region of each example is replaced by the same region of
|
|
1113
|
+
a shuffled example of the batch, see [1]_. As in the reference code [2]_,
|
|
1114
|
+
a coefficient ``lam`` is drawn from a Beta distribution, the region is
|
|
1115
|
+
``(1 - lam) * n_times`` long (the 1-D analogue of the cut area ratio
|
|
1116
|
+
``1 - lam``) around a uniformly drawn center, it is clipped at the trial
|
|
1117
|
+
boundaries, and ``lam`` is then recomputed from the pasted length.
|
|
1118
|
+
|
|
1119
|
+
Like :class:`Mixup`, it applies to whole batches and returns targets
|
|
1120
|
+
``(y_a, y_b, lam)`` for :func:`braindecode.training.mixup_criterion`.
|
|
1121
|
+
|
|
1122
|
+
Parameters
|
|
1123
|
+
----------
|
|
1124
|
+
alpha : float
|
|
1125
|
+
Parameter of the Beta distribution of ``lam``. ``alpha <= 0`` cuts
|
|
1126
|
+
nothing.
|
|
1127
|
+
beta_per_sample : bool (default=False)
|
|
1128
|
+
By default, one ``lam`` per batch is drawn. If True, one per sample.
|
|
1129
|
+
random_state : int | numpy.random.Generator, optional
|
|
1130
|
+
Seed to be used to instantiate numpy random number generator instance.
|
|
1131
|
+
Defaults to None.
|
|
1132
|
+
|
|
1133
|
+
References
|
|
1134
|
+
----------
|
|
1135
|
+
.. [1] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun,
|
|
1136
|
+
Junsuk Choe, Youngjoon Yoo (2019). CutMix: Regularization Strategy
|
|
1137
|
+
to Train Strong Classifiers with Localizable Features. In 2019
|
|
1138
|
+
IEEE/CVF International Conference on Computer Vision (ICCV)
|
|
1139
|
+
Online: https://arxiv.org/abs/1905.04899
|
|
1140
|
+
.. [2] https://github.com/clovaai/CutMix-PyTorch/blob/master/train.py
|
|
1141
|
+
"""
|
|
1142
|
+
|
|
1143
|
+
operation = staticmethod(cutmix) # type: ignore[assignment]
|
|
1144
|
+
|
|
1145
|
+
def get_augmentation_params(self, *batch):
|
|
1146
|
+
"""Return idx_perm and the cut_t_start, cut_t_len of each region."""
|
|
1147
|
+
params = super().get_augmentation_params(*batch)
|
|
1148
|
+
lam = params.pop("lam")
|
|
1149
|
+
n_times = batch[0].shape[-1]
|
|
1150
|
+
half = ((1 - lam) * n_times).long() // 2
|
|
1151
|
+
center = torch.as_tensor(self.rng.randint(n_times, size=len(lam)))
|
|
1152
|
+
center = center.to(lam.device)
|
|
1153
|
+
start = (center - half).clamp(min=0)
|
|
1154
|
+
end = (center + half).clamp(max=n_times)
|
|
1155
|
+
return dict(params, cut_t_start=start, cut_t_len=end - start)
|
|
1156
|
+
|
|
1157
|
+
|
|
1098
1158
|
class SegmentationReconstruction(Transform):
|
|
1099
1159
|
"""Segmentation Reconstruction from Lotte (2015) [Lotte2015]_.
|
|
1100
1160
|
|
|
@@ -1283,7 +1343,7 @@ class MaskEncoding(Transform):
|
|
|
1283
1343
|
)
|
|
1284
1344
|
|
|
1285
1345
|
time_start = self.rng.randint(
|
|
1286
|
-
0, n_times - segment_length, (batch_size, self.n_segments)
|
|
1346
|
+
0, n_times - segment_length + 1, (batch_size, self.n_segments)
|
|
1287
1347
|
)
|
|
1288
1348
|
time_start = torch.from_numpy(time_start)
|
|
1289
1349
|
|
{braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/base.py
RENAMED
|
@@ -279,7 +279,7 @@ def _compact_fif_tags(inst):
|
|
|
279
279
|
return inst
|
|
280
280
|
|
|
281
281
|
|
|
282
|
-
def _read_fif_window(raw, start, stop):
|
|
282
|
+
def _read_fif_window(raw, start, stop, willneed=False):
|
|
283
283
|
"""Samples ``start:stop`` of a lazy FIF raw, copied from the file in one go.
|
|
284
284
|
|
|
285
285
|
mne reads, casts and calibrates the FIF data buffers of a range one at a
|
|
@@ -290,6 +290,10 @@ def _read_fif_window(raw, start, stop):
|
|
|
290
290
|
times ``raw._cals``), so the values equal ``raw._getitem``'s. Returns None
|
|
291
291
|
(the caller uses mne) unless ``raw`` is a lazy, single-file, uncompressed
|
|
292
292
|
FIF raw of float32 buffers without projector, compensation or gaps.
|
|
293
|
+
|
|
294
|
+
With ``willneed=True`` nothing is read and None is returned: the OS is
|
|
295
|
+
only asked to start reading the window's bytes into the page cache in the
|
|
296
|
+
background (``posix_fadvise(POSIX_FADV_WILLNEED)``).
|
|
293
297
|
"""
|
|
294
298
|
if (
|
|
295
299
|
not isinstance(raw, mne.io.Raw)
|
|
@@ -316,6 +320,18 @@ def _read_fif_window(raw, start, stop):
|
|
|
316
320
|
if not len(rows) or (rows[:, 1] != FIFF.FIFFT_FLOAT).any():
|
|
317
321
|
return None
|
|
318
322
|
size, pos = rows[:, 2].tolist(), rows[:, 4].tolist()
|
|
323
|
+
if willneed: # only a hint: any error is left to the read itself
|
|
324
|
+
try:
|
|
325
|
+
with open(fname, "rb") as f:
|
|
326
|
+
os.posix_fadvise(
|
|
327
|
+
f.fileno(),
|
|
328
|
+
pos[0],
|
|
329
|
+
pos[-1] + 16 + size[-1] - pos[0],
|
|
330
|
+
os.POSIX_FADV_WILLNEED,
|
|
331
|
+
)
|
|
332
|
+
except OSError:
|
|
333
|
+
pass
|
|
334
|
+
return None
|
|
319
335
|
# mmap: no copy through a 4 MB read buffer, and a cold file is read around
|
|
320
336
|
# the window by the kernel (as mne's 4 MB reads did), not window by window
|
|
321
337
|
with open(fname, "rb") as f, mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m:
|
|
@@ -618,7 +634,9 @@ class RecordDataset(Dataset[tuple[np.ndarray, int | str, tuple[int, int, int]]])
|
|
|
618
634
|
f"'{key}' already in description. Please "
|
|
619
635
|
f"rename or set overwrite to True."
|
|
620
636
|
)
|
|
621
|
-
|
|
637
|
+
# drop on a copy: windows datasets share the description
|
|
638
|
+
# Series of the dataset they were created from
|
|
639
|
+
self._description = self._description.drop(key)
|
|
622
640
|
self._description = pd.concat([self.description, description])
|
|
623
641
|
|
|
624
642
|
@property
|
|
@@ -1265,6 +1283,49 @@ class WindowsDataset(_ZarrMixin, RecordDataset):
|
|
|
1265
1283
|
)
|
|
1266
1284
|
|
|
1267
1285
|
|
|
1286
|
+
def _lazy_source_files(ds) -> list:
|
|
1287
|
+
"""Return the files ``ds`` still reads its signal from (none once preloaded)."""
|
|
1288
|
+
signal = ds.raw if hasattr(ds, "raw") else getattr(ds, "windows", None)
|
|
1289
|
+
if signal is None or getattr(signal, "preload", True):
|
|
1290
|
+
return []
|
|
1291
|
+
files = list(
|
|
1292
|
+
getattr(signal, "filenames", None) or [getattr(signal, "filename", None)]
|
|
1293
|
+
)
|
|
1294
|
+
raw = getattr(signal, "_raw", None)
|
|
1295
|
+
if isinstance(raw, mne.io.BaseRaw) and not raw.preload:
|
|
1296
|
+
files += raw.filenames # mne.Epochs of a lazily read Raw read through it
|
|
1297
|
+
return [f for f in files if f is not None]
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
def _dir_key(directory):
|
|
1301
|
+
"""Identify a directory by device and inode, whatever its spelling."""
|
|
1302
|
+
stat = os.stat(directory)
|
|
1303
|
+
return stat.st_dev, stat.st_ino
|
|
1304
|
+
|
|
1305
|
+
|
|
1306
|
+
def _overwrite_conflicts(datasets, path, offset):
|
|
1307
|
+
"""Yield ``(i_ds, i_target, target_dir)`` for each dataset ``i_ds`` that
|
|
1308
|
+
lazily reads from inside ``target_dir = path/<i_target + offset>``, which
|
|
1309
|
+
``save(overwrite=True)`` deletes before writing dataset ``i_target``.
|
|
1310
|
+
"""
|
|
1311
|
+
targets = {}
|
|
1312
|
+
for i in range(len(datasets)):
|
|
1313
|
+
target_dir = os.path.join(path, str(i + offset))
|
|
1314
|
+
if os.path.isdir(target_dir):
|
|
1315
|
+
targets[_dir_key(target_dir)] = (i, target_dir)
|
|
1316
|
+
if not targets:
|
|
1317
|
+
return
|
|
1318
|
+
for i_ds, ds in enumerate(datasets):
|
|
1319
|
+
for file in _lazy_source_files(ds):
|
|
1320
|
+
# ancestors of the name and of the file it links to (DataLad)
|
|
1321
|
+
parents = {
|
|
1322
|
+
*Path(os.path.abspath(file)).parents,
|
|
1323
|
+
*Path(os.path.realpath(file)).parents,
|
|
1324
|
+
}
|
|
1325
|
+
for key in {_dir_key(p) for p in parents if p.is_dir()} & targets.keys():
|
|
1326
|
+
yield (i_ds, *targets[key])
|
|
1327
|
+
|
|
1328
|
+
|
|
1268
1329
|
@register_dataset
|
|
1269
1330
|
class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
1270
1331
|
"""A base class for concatenated datasets.
|
|
@@ -1362,7 +1423,8 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1362
1423
|
def __len__(self):
|
|
1363
1424
|
return self._ensure_cumulative_sizes()[-1]
|
|
1364
1425
|
|
|
1365
|
-
def
|
|
1426
|
+
def _locate(self, idx: int):
|
|
1427
|
+
"""The dataset that holds item ``idx`` and the item's index in it."""
|
|
1366
1428
|
if idx < 0:
|
|
1367
1429
|
if -idx > len(self):
|
|
1368
1430
|
raise ValueError(
|
|
@@ -1376,7 +1438,33 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1376
1438
|
sample_idx = idx
|
|
1377
1439
|
else:
|
|
1378
1440
|
sample_idx = idx - cumulative_sizes[dataset_idx - 1]
|
|
1379
|
-
return self.datasets[dataset_idx]
|
|
1441
|
+
return self.datasets[dataset_idx], sample_idx
|
|
1442
|
+
|
|
1443
|
+
def _get_single_item(self, idx: int):
|
|
1444
|
+
ds, i = self._locate(idx)
|
|
1445
|
+
return ds[i]
|
|
1446
|
+
|
|
1447
|
+
def __getitems__(self, indices):
|
|
1448
|
+
"""Items ``indices``, as ``[self[i] for i in indices]``.
|
|
1449
|
+
|
|
1450
|
+
A :class:`~torch.utils.data.DataLoader` fetches each batch through
|
|
1451
|
+
this. The lazy FIF windows of the batch are first requested from the
|
|
1452
|
+
OS all at once (``posix_fadvise(POSIX_FADV_WILLNEED)``, where it
|
|
1453
|
+
exists), so their reads from disk overlap instead of running one after
|
|
1454
|
+
another: on a network file system a batch read from cold files then
|
|
1455
|
+
costs about one round trip, not one per window.
|
|
1456
|
+
"""
|
|
1457
|
+
# ponytail: advises the whole batch at once; chunk it if a batch's
|
|
1458
|
+
# windows ever outgrow the page cache
|
|
1459
|
+
if hasattr(os, "posix_fadvise"):
|
|
1460
|
+
for idx in indices:
|
|
1461
|
+
if not isinstance(idx, (int, np.integer)):
|
|
1462
|
+
continue # e.g. a SequenceSampler tuple: read, not advised
|
|
1463
|
+
ds, i = self._locate(idx)
|
|
1464
|
+
if isinstance(ds, EEGWindowsDataset) and ds._zarr_data is None:
|
|
1465
|
+
_, start, stop = ds.crop_inds[i].tolist()
|
|
1466
|
+
_read_fif_window(ds.raw, start, stop, willneed=True)
|
|
1467
|
+
return [self[idx] for idx in indices]
|
|
1380
1468
|
|
|
1381
1469
|
def __getitem__(self, idx: int | list):
|
|
1382
1470
|
"""
|
|
@@ -1475,7 +1563,9 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1475
1563
|
metadata : pd.DataFrame
|
|
1476
1564
|
DataFrame containing as many rows as there are windows in the
|
|
1477
1565
|
BaseConcatDataset, with the metadata and description information
|
|
1478
|
-
for each window
|
|
1566
|
+
for each window, and an ``i_dataset`` column giving the position
|
|
1567
|
+
in ``datasets`` of the dataset (recording) each window comes from.
|
|
1568
|
+
Samplers use it to keep recordings apart.
|
|
1479
1569
|
"""
|
|
1480
1570
|
if not all(
|
|
1481
1571
|
[
|
|
@@ -1501,9 +1591,15 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1501
1591
|
"Dataset descriptions cannot contain the reserved window "
|
|
1502
1592
|
"metadata key 'i_trial_in_dataset'."
|
|
1503
1593
|
)
|
|
1594
|
+
if "i_dataset" in df.columns or "i_dataset" in ds.description:
|
|
1595
|
+
raise ValueError(
|
|
1596
|
+
"Window metadata and dataset descriptions cannot contain the "
|
|
1597
|
+
"key 'i_dataset', which get_metadata() reserves for the "
|
|
1598
|
+
"position of the dataset each window comes from. Rename it."
|
|
1599
|
+
)
|
|
1504
1600
|
|
|
1505
1601
|
all_dfs = list()
|
|
1506
|
-
for ds in self.datasets:
|
|
1602
|
+
for i_ds, ds in enumerate(self.datasets):
|
|
1507
1603
|
if hasattr(ds, "_windows") and ds._windows is not None:
|
|
1508
1604
|
df = ds._windows.metadata
|
|
1509
1605
|
else:
|
|
@@ -1513,6 +1609,7 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1513
1609
|
df = df.copy()
|
|
1514
1610
|
for k, v in ds.description.items():
|
|
1515
1611
|
df[k] = v
|
|
1612
|
+
df["i_dataset"] = i_ds
|
|
1516
1613
|
all_dfs.append(df)
|
|
1517
1614
|
|
|
1518
1615
|
return pd.concat(all_dfs)
|
|
@@ -1805,6 +1902,11 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1805
1902
|
dataset description.
|
|
1806
1903
|
"""
|
|
1807
1904
|
description = pd.DataFrame(description)
|
|
1905
|
+
if len(description.columns) and len(description) != len(self.datasets):
|
|
1906
|
+
raise ValueError(
|
|
1907
|
+
f"Length of values ({len(description)}) does not match "
|
|
1908
|
+
f"number of datasets ({len(self.datasets)})."
|
|
1909
|
+
)
|
|
1808
1910
|
for key, value in description.items():
|
|
1809
1911
|
for ds, value_ in zip(self.datasets, value):
|
|
1810
1912
|
ds.set_description({key: value_}, overwrite=overwrite)
|
|
@@ -1835,7 +1937,9 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1835
1937
|
-raw.fif | -epo.fif and .json files to.
|
|
1836
1938
|
overwrite : bool
|
|
1837
1939
|
Whether to delete old subdirectories that will be saved to in this
|
|
1838
|
-
call.
|
|
1940
|
+
call. If a dataset still reads its data lazily from one of them, a
|
|
1941
|
+
``ValueError`` is raised before anything is deleted: load the data
|
|
1942
|
+
into memory first (``preload=True``) or save to another directory.
|
|
1839
1943
|
offset : int
|
|
1840
1944
|
If provided, the integer is added to the id of the dataset in the
|
|
1841
1945
|
concat. This is useful in the setting of very large datasets, where
|
|
@@ -1848,6 +1952,13 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1848
1952
|
hasattr(self.datasets[0], "raw") or hasattr(self.datasets[0], "windows")
|
|
1849
1953
|
):
|
|
1850
1954
|
raise ValueError("dataset should have either raw or windows attribute")
|
|
1955
|
+
if overwrite:
|
|
1956
|
+
for _, _, target_dir in _overwrite_conflicts(self.datasets, path, offset):
|
|
1957
|
+
raise ValueError(
|
|
1958
|
+
f"Saving with overwrite=True would delete {target_dir} while "
|
|
1959
|
+
"a dataset still reads its data from it. Load the data into "
|
|
1960
|
+
"memory first (preload=True) or save to another directory."
|
|
1961
|
+
)
|
|
1851
1962
|
|
|
1852
1963
|
# Create path if it doesn't exist
|
|
1853
1964
|
os.makedirs(path, exist_ok=True)
|
{braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/mne.py
RENAMED
|
@@ -159,6 +159,11 @@ def create_from_mne_epochs(
|
|
|
159
159
|
|
|
160
160
|
list_of_windows_ds = []
|
|
161
161
|
for i, epochs in enumerate(list_of_epochs):
|
|
162
|
+
# drop rejected epochs first (on a copy) so that iterating over the
|
|
163
|
+
# epochs stays aligned with ``epochs.events``; preloaded epochs have
|
|
164
|
+
# already dropped them, so skip copying their data
|
|
165
|
+
if not epochs.preload:
|
|
166
|
+
epochs = epochs.copy().drop_bad()
|
|
162
167
|
event_descriptions = epochs.events[:, 2]
|
|
163
168
|
original_trial_starts = epochs.events[:, 0]
|
|
164
169
|
stop = len(epochs.times) - window_size_samples
|
{braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/braindecode/datasets/tuh.py
RENAMED
|
@@ -122,7 +122,8 @@ class TUH(BaseConcatDataset):
|
|
|
122
122
|
# Assume it is an integer specifying number
|
|
123
123
|
# of recordings to load
|
|
124
124
|
recording_ids = range(recording_ids)
|
|
125
|
-
|
|
125
|
+
# select by chronological position, not by (file listing) label
|
|
126
|
+
descriptions = descriptions.iloc[:, list(recording_ids)]
|
|
126
127
|
|
|
127
128
|
# workaround to ensure warnings are suppressed when running in parallel
|
|
128
129
|
def create_dataset(*args, **kwargs):
|
|
@@ -140,15 +140,19 @@ def _load_signals(fif_file, preload, is_raw):
|
|
|
140
140
|
with open(pkl_file, "rb") as f:
|
|
141
141
|
signals = pickle.load(f)
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
# The pickle stores absolute paths: check that they exist and point to
|
|
144
|
+
# this fif file, not to the folder the dataset was copied from.
|
|
145
|
+
if all(Path(f).exists() for f in signals.filenames) and (
|
|
146
|
+
Path(signals.filenames[0]).resolve() == fif_file.resolve()
|
|
147
|
+
):
|
|
144
148
|
if preload:
|
|
145
149
|
signals.load_data()
|
|
146
150
|
return _compact_fif_tags(signals)
|
|
147
151
|
else: # This may happen if the file has been moved together with the pickle file.
|
|
148
152
|
warnings.warn(
|
|
149
153
|
f"Pickle file {pkl_file} exists, but the referenced fif "
|
|
150
|
-
"file(s) do not exist. Will read the
|
|
151
|
-
"and re-create the pickle file.",
|
|
154
|
+
"file(s) do not exist or are not next to it. Will read the "
|
|
155
|
+
"fif file(s) directly and re-create the pickle file.",
|
|
152
156
|
UserWarning,
|
|
153
157
|
)
|
|
154
158
|
|
|
@@ -220,7 +224,10 @@ def load_concat_dataset(path, preload, ids_to_load=None, target_name=None, n_job
|
|
|
220
224
|
# target_name.json, raw_preproc_kwargs.json, window_kwargs.json,
|
|
221
225
|
# window_preproc_kwargs.json
|
|
222
226
|
if ids_to_load is None:
|
|
223
|
-
|
|
227
|
+
# skip stray entries such as .DS_Store or a README next to the datasets
|
|
228
|
+
ids_to_load = [
|
|
229
|
+
p.name for p in path.iterdir() if p.is_dir() and p.name.isdigit()
|
|
230
|
+
]
|
|
224
231
|
ids_to_load = sorted(ids_to_load, key=lambda i: int(i))
|
|
225
232
|
ids_to_load = [str(i) for i in ids_to_load]
|
|
226
233
|
first_raw_fif_path = path / ids_to_load[0] / f"{ids_to_load[0]}-raw.fif"
|
{braindecode-1.8.1.dev177462534 → braindecode-1.8.1.dev177618751}/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:
|