braindecode 1.8.1.dev181333418__tar.gz → 1.8.1.dev181501004__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.dev181333418 → braindecode-1.8.1.dev181501004}/NOTICE.txt +3 -0
- {braindecode-1.8.1.dev181333418/braindecode.egg-info → braindecode-1.8.1.dev181501004}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/augmentation/__init__.py +2 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/augmentation/functional.py +48 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/augmentation/transforms.py +52 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/base.py +233 -11
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/tuh.py +17 -12
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datautil/serialization.py +10 -6
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/eegneuralnet.py +6 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/functional/_real_dft.py +55 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/functional/functions.py +32 -13
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/__init__.py +6 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/attn_sleep.py +4 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/axon.py +42 -8
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/barista.py +25 -13
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/base.py +52 -15
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/brainmodule.py +13 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/brainomni.py +14 -4
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/brant.py +18 -7
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/codebrain.py +114 -26
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/contrawr.py +23 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/csbrain.py +93 -43
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/ctnet.py +9 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/deep4.py +10 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/dgcnn.py +7 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/diver1.py +51 -59
- braindecode-1.8.1.dev181501004/braindecode/models/duin.py +454 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eeg_clip.py +71 -9
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegconformer.py +19 -3
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eeginception_mi.py +7 -3
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegnex.py +20 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegpt.py +15 -9
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegsym.py +68 -16
- braindecode-1.8.1.dev181501004/braindecode/models/epint.py +315 -0
- braindecode-1.8.1.dev181501004/braindecode/models/gcnsnet.py +338 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/labram.py +34 -15
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/luna.py +11 -5
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/medformer.py +51 -21
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/meta_neuromotor.py +35 -8
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/mirepnet.py +15 -4
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/mscformer.py +21 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/msvtnet.py +120 -2
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/neurorvq.py +135 -34
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/neurorvq_tokenizer.py +87 -63
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/patchedtransformer.py +3 -7
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/reve.py +135 -33
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/signal_jepa.py +87 -4
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/sinc_shallow.py +2 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/sleep_stager_blanco_2020.py +13 -6
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/sleepfm.py +62 -12
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/steegformer.py +16 -9
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/summary.csv +3 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/tcn.py +5 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/tfm_tokenizer.py +44 -3
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/tidnet.py +18 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/usleep.py +3 -2
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/util.py +8 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/zuna.py +17 -9
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/__init__.py +2 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/attention.py +124 -15
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/blocks.py +121 -5
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/channels.py +77 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/dance_modules.py +16 -3
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/filter.py +79 -33
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/layers.py +41 -2
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/quantization.py +10 -6
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/preprocessing/preprocess.py +28 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/preprocessing/windowers.py +3 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/samplers/base.py +60 -61
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/training/losses.py +5 -4
- braindecode-1.8.1.dev181501004/braindecode/version.py +1 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004/braindecode.egg-info}/PKG-INFO +1 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode.egg-info/SOURCES.txt +3 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/api.rst +11 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/whats_new.rst +148 -0
- braindecode-1.8.1.dev181333418/braindecode/version.py +0 -1
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/LICENSE.txt +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/MANIFEST.in +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/README.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/__init__.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/augmentation/base.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/classifier.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/__init__.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/_notebook_viewer.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bbci.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bcicomp.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bids/__init__.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bids/datasets.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bids/format.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bids/hub.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bids/hub_format.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bids/hub_io.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bids/hub_validation.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/bids/iterable.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/chb_mit.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/collate.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/mne.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/moabb.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/nmt.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/registry.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/siena.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/sleep_physio_challe_18.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/sleep_physionet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/utils.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/xy.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datautil/__init__.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datautil/channel_utils.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datautil/hub_formats.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datautil/util.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/functional/__init__.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/functional/initialization.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/atcnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/attentionbasenet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/bendr.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/biot.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/brainbert.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/cbramod.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/config.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/dance.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/deepsleepnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegdino.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eeginception_erp.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegitnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegminer.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegsimpleconv.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/eegtcnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/emg2qwerty.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/fbcnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/fblightconvnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/fbmsnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/guetschel2026.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/hybrid.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/ifnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/mapa.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/mvpformer.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/neuropose.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/popt.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/sccnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/seizure_transformer.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/sensingdynamics.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/shallow_fbcsp.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/sleep_stager_chambon_2018.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/sparcnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/sstdpn.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/syncnet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/tcformer.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/tmsanet.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/tsinception.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/models/vemg2pose.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/activation.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/convolution.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/linear.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/linear_attention.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/parametrization.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/popt_modules.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/stats.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/util.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/modules/wrapper.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/preprocessing/__init__.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/preprocessing/eegprep_preprocess.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/preprocessing/mne_preprocess.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/preprocessing/util.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/regressor.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/samplers/__init__.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/samplers/ssl.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/training/__init__.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/training/callbacks.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/training/scoring.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/util.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/visualization/__init__.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/visualization/activations.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/visualization/attribution.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/visualization/confusion_matrices.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/visualization/frequency.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/visualization/metrics.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/visualization/sanity.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/visualization/topology.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode.egg-info/dependency_links.txt +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode.egg-info/requires.txt +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode.egg-info/top_level.txt +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/Makefile +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/_templates/autosummary/class.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/_templates/autosummary/class_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/_templates/autosummary/function.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/_templates/autosummary/function_in_subdir.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/agent_docs.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/cite.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/conf.py +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/help.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/index.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/install/install.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/install/install_pip.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/install/install_source.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/categorization/attention.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/categorization/channel.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/categorization/convolution.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/categorization/filterbank.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/categorization/gnn.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/categorization/interpretable.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/categorization/lbm.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/categorization/recurrent.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/categorization/spd.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/models.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/models_categorization.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/models_table.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/models/models_visualization.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/sg_execution_times.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/docs/user_guide/channel_strategies.rst +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/pyproject.toml +0 -0
- {braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/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.dev181333418/braindecode.egg-info → braindecode-1.8.1.dev181501004}/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.dev181501004
|
|
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",
|
|
@@ -1075,6 +1075,54 @@ def mixup(
|
|
|
1075
1075
|
return X_mix, (y_a, y_b, lam)
|
|
1076
1076
|
|
|
1077
1077
|
|
|
1078
|
+
def cutmix(
|
|
1079
|
+
X: torch.Tensor,
|
|
1080
|
+
y: torch.Tensor,
|
|
1081
|
+
idx_perm: torch.Tensor,
|
|
1082
|
+
cut_t_start: torch.Tensor,
|
|
1083
|
+
cut_t_len: torch.Tensor,
|
|
1084
|
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
|
1085
|
+
"""Paste a time region of shuffled examples into the original examples.
|
|
1086
|
+
|
|
1087
|
+
See [1]_ for details.
|
|
1088
|
+
|
|
1089
|
+
Parameters
|
|
1090
|
+
----------
|
|
1091
|
+
X : torch.Tensor
|
|
1092
|
+
EEG data in form ``batch_size, n_channels, n_times``
|
|
1093
|
+
y : torch.Tensor
|
|
1094
|
+
Target of length ``batch_size``
|
|
1095
|
+
idx_perm : torch.Tensor
|
|
1096
|
+
Permuted indices of example that are mixed into original examples.
|
|
1097
|
+
cut_t_start : torch.Tensor
|
|
1098
|
+
Start index of the pasted time region for each example.
|
|
1099
|
+
cut_t_len : torch.Tensor
|
|
1100
|
+
Length of the pasted time region for each example.
|
|
1101
|
+
|
|
1102
|
+
Returns
|
|
1103
|
+
-------
|
|
1104
|
+
tuple
|
|
1105
|
+
``X``, ``y``. Where ``X`` is augmented and ``y`` is a tuple of length
|
|
1106
|
+
3 containing the labels of the two mixed examples and the fraction of
|
|
1107
|
+
each example kept from the original, ``1 - cut_t_len / n_times``.
|
|
1108
|
+
|
|
1109
|
+
References
|
|
1110
|
+
----------
|
|
1111
|
+
.. [1] Sangdoo Yun, Dongyoon Han, Seong Joon Oh, Sanghyuk Chun,
|
|
1112
|
+
Junsuk Choe, Youngjoon Yoo (2019). CutMix: Regularization Strategy
|
|
1113
|
+
to Train Strong Classifiers with Localizable Features. In 2019
|
|
1114
|
+
IEEE/CVF International Conference on Computer Vision (ICCV)
|
|
1115
|
+
Online: https://arxiv.org/abs/1905.04899
|
|
1116
|
+
"""
|
|
1117
|
+
n_times = X.shape[-1]
|
|
1118
|
+
t = torch.arange(n_times, device=X.device)
|
|
1119
|
+
start = cut_t_start[:, None]
|
|
1120
|
+
in_cut = (t >= start) & (t < start + cut_t_len[:, None])
|
|
1121
|
+
X_mix = torch.where(in_cut[:, None], X[idx_perm], X)
|
|
1122
|
+
lam = (n_times - cut_t_len).to(X.dtype) / n_times
|
|
1123
|
+
return X_mix, (y.clone(), y[idx_perm].clone(), lam)
|
|
1124
|
+
|
|
1125
|
+
|
|
1078
1126
|
def segmentation_reconstruction(
|
|
1079
1127
|
X: torch.Tensor,
|
|
1080
1128
|
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.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/base.py
RENAMED
|
@@ -14,13 +14,16 @@ from __future__ import annotations
|
|
|
14
14
|
import bisect
|
|
15
15
|
import html as _html
|
|
16
16
|
import json
|
|
17
|
+
import mmap
|
|
17
18
|
import os
|
|
18
19
|
import shutil
|
|
19
20
|
import warnings
|
|
20
21
|
from abc import abstractmethod
|
|
21
22
|
from collections import Counter
|
|
22
|
-
from collections.abc import Callable, Hashable
|
|
23
|
+
from collections.abc import Callable, Hashable, Sequence
|
|
23
24
|
from glob import glob
|
|
25
|
+
from itertools import chain
|
|
26
|
+
from operator import attrgetter
|
|
24
27
|
from pathlib import Path
|
|
25
28
|
from typing import Any, Generic, Iterable, no_type_check
|
|
26
29
|
|
|
@@ -28,6 +31,7 @@ import mne
|
|
|
28
31
|
import mne.io
|
|
29
32
|
import numpy as np
|
|
30
33
|
import pandas as pd
|
|
34
|
+
from mne.io.constants import FIFF
|
|
31
35
|
from mne.utils import _soft_import
|
|
32
36
|
from mne.utils.docs import deprecated
|
|
33
37
|
from torch.utils.data import ConcatDataset, Dataset, IterableDataset
|
|
@@ -220,6 +224,125 @@ def _compute_ch_pos(info, targets_from):
|
|
|
220
224
|
return pos
|
|
221
225
|
|
|
222
226
|
|
|
227
|
+
_TAG_ROW = attrgetter("kind", "type", "size", "next", "pos")
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _tag_rows(tags):
|
|
231
|
+
"""(kind, type, size, next, pos) of FIF tags as an int64 array (n, 5)."""
|
|
232
|
+
flat = chain.from_iterable(map(_TAG_ROW, tags))
|
|
233
|
+
return np.fromiter(flat, np.int64, 5 * len(tags)).reshape(-1, 5)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
class _FifTagTable(Sequence):
|
|
237
|
+
"""The data-buffer tags of a lazy FIF raw as one int64 array.
|
|
238
|
+
|
|
239
|
+
mne's FIF reader keeps one ``Tag`` object per data buffer in
|
|
240
|
+
``raw._raw_extras[i]["ent"]`` (one per second of signal with mne's default
|
|
241
|
+
buffers), each with its attribute dict and integers once unpickled. A lazy
|
|
242
|
+
dataset of many recordings holds millions of them in RAM, and every forked
|
|
243
|
+
DataLoader worker copies the memory pages of those it reads (reference
|
|
244
|
+
counts). This holds the same fields in 40 bytes per buffer and returns an
|
|
245
|
+
equal ``Tag`` on access, so mne's own reads are unchanged.
|
|
246
|
+
"""
|
|
247
|
+
|
|
248
|
+
def __init__(self, tags):
|
|
249
|
+
self.tag_class = type(tags[0])
|
|
250
|
+
self.table = _tag_rows(tags)
|
|
251
|
+
|
|
252
|
+
def __len__(self):
|
|
253
|
+
return len(self.table)
|
|
254
|
+
|
|
255
|
+
def __getitem__(self, i):
|
|
256
|
+
if isinstance(i, slice):
|
|
257
|
+
return [self.tag_class(*row) for row in self.table[i].tolist()]
|
|
258
|
+
return self.tag_class(*self.table[i].tolist())
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
_TAG_FIELDS = ("kind", "type", "size", "next", "pos", "data")
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def _compact_fif_tags(inst):
|
|
265
|
+
"""Swap the ``Tag`` lists of a FIF raw for `_FifTagTable` (in place).
|
|
266
|
+
|
|
267
|
+
Only gap-free lists of directory tags (no ``None``, no ``data``) with mne's
|
|
268
|
+
``Tag`` fields are swapped; anything else is left as mne built it.
|
|
269
|
+
"""
|
|
270
|
+
for extra in getattr(inst, "_raw_extras", ()):
|
|
271
|
+
tags = extra.get("ent")
|
|
272
|
+
if not isinstance(tags, list) or not tags:
|
|
273
|
+
continue
|
|
274
|
+
cls = type(tags[0])
|
|
275
|
+
if tuple(getattr(cls, "__dataclass_fields__", ())) == _TAG_FIELDS and all(
|
|
276
|
+
type(t) is cls and t.data is None for t in tags
|
|
277
|
+
):
|
|
278
|
+
extra["ent"] = _FifTagTable(tags)
|
|
279
|
+
return inst
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def _read_fif_window(raw, start, stop, willneed=False):
|
|
283
|
+
"""Samples ``start:stop`` of a lazy FIF raw, copied from the file in one go.
|
|
284
|
+
|
|
285
|
+
mne reads, casts and calibrates the FIF data buffers of a range one at a
|
|
286
|
+
time (60 Python steps for a 60-s window saved with 1-s buffers, each through
|
|
287
|
+
a buffered file whose buffer is 4 MB on network file systems). Here one
|
|
288
|
+
slice of the memory-mapped file holds the bytes of every buffer in the
|
|
289
|
+
range and one multiply calibrates them, with mne's arithmetic (float64 data
|
|
290
|
+
times ``raw._cals``), so the values equal ``raw._getitem``'s. Returns None
|
|
291
|
+
(the caller uses mne) unless ``raw`` is a lazy, single-file, uncompressed
|
|
292
|
+
FIF raw of float32 buffers without projector, compensation or gaps.
|
|
293
|
+
|
|
294
|
+
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)``).
|
|
297
|
+
"""
|
|
298
|
+
if (
|
|
299
|
+
not isinstance(raw, mne.io.Raw)
|
|
300
|
+
or raw.preload
|
|
301
|
+
or len(raw._raw_extras) != 1
|
|
302
|
+
or raw._projector is not None
|
|
303
|
+
or raw._comp is not None
|
|
304
|
+
):
|
|
305
|
+
return None
|
|
306
|
+
extra = raw._raw_extras[0]
|
|
307
|
+
fname, bounds = extra["filename"], extra["bounds"]
|
|
308
|
+
if not isinstance(fname, Path) or fname.suffix == ".gz":
|
|
309
|
+
return None
|
|
310
|
+
start, stop = start + raw._first_samps[0], stop + raw._first_samps[0]
|
|
311
|
+
first = np.searchsorted(bounds, start, side="right") - 1
|
|
312
|
+
tags = extra["ent"]
|
|
313
|
+
if isinstance(tags, _FifTagTable):
|
|
314
|
+
rows = tags.table[first : np.searchsorted(bounds, stop)]
|
|
315
|
+
else:
|
|
316
|
+
tags = tags[first : np.searchsorted(bounds, stop)]
|
|
317
|
+
if any(t is None for t in tags):
|
|
318
|
+
return None
|
|
319
|
+
rows = _tag_rows(tags)
|
|
320
|
+
if not len(rows) or (rows[:, 1] != FIFF.FIFFT_FLOAT).any():
|
|
321
|
+
return None
|
|
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
|
|
335
|
+
# mmap: no copy through a 4 MB read buffer, and a cold file is read around
|
|
336
|
+
# the window by the kernel (as mne's 4 MB reads did), not window by window
|
|
337
|
+
with open(fname, "rb") as f, mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m:
|
|
338
|
+
buf = m[pos[0] : pos[-1] + 16 + size[-1]]
|
|
339
|
+
one = np.concatenate(
|
|
340
|
+
[np.frombuffer(buf, ">f4", s // 4, p + 16 - pos[0]) for s, p in zip(size, pos)]
|
|
341
|
+
).reshape(-1, extra["orig_nchan"])[start - bounds[first] : stop - bounds[first]]
|
|
342
|
+
picked = one[:, raw._read_picks[0]].T
|
|
343
|
+
return np.multiply(picked, raw._cals[:, np.newaxis], order="C")
|
|
344
|
+
|
|
345
|
+
|
|
223
346
|
def _window_info(crop_inds, sfreq):
|
|
224
347
|
"""Extract window size from crop indices.
|
|
225
348
|
|
|
@@ -823,9 +946,11 @@ class EEGWindowsDataset(_ZarrMixin, RecordDataset):
|
|
|
823
946
|
if self._zarr_data is not None:
|
|
824
947
|
X = self._zarr_data[:, i_start:i_stop]
|
|
825
948
|
else:
|
|
826
|
-
X = self.raw
|
|
827
|
-
|
|
828
|
-
|
|
949
|
+
X = _read_fif_window(self.raw, i_start, i_stop)
|
|
950
|
+
if X is None:
|
|
951
|
+
X = self.raw._getitem(
|
|
952
|
+
(slice(None), slice(i_start, i_stop)), return_times=False
|
|
953
|
+
)
|
|
829
954
|
X = np.array(X, dtype="float32")
|
|
830
955
|
if self.transform is not None:
|
|
831
956
|
X = self.transform(X)
|
|
@@ -1156,6 +1281,49 @@ class WindowsDataset(_ZarrMixin, RecordDataset):
|
|
|
1156
1281
|
)
|
|
1157
1282
|
|
|
1158
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
|
+
|
|
1159
1327
|
@register_dataset
|
|
1160
1328
|
class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
1161
1329
|
"""A base class for concatenated datasets.
|
|
@@ -1253,7 +1421,8 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1253
1421
|
def __len__(self):
|
|
1254
1422
|
return self._ensure_cumulative_sizes()[-1]
|
|
1255
1423
|
|
|
1256
|
-
def
|
|
1424
|
+
def _locate(self, idx: int):
|
|
1425
|
+
"""The dataset that holds item ``idx`` and the item's index in it."""
|
|
1257
1426
|
if idx < 0:
|
|
1258
1427
|
if -idx > len(self):
|
|
1259
1428
|
raise ValueError(
|
|
@@ -1267,7 +1436,33 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1267
1436
|
sample_idx = idx
|
|
1268
1437
|
else:
|
|
1269
1438
|
sample_idx = idx - cumulative_sizes[dataset_idx - 1]
|
|
1270
|
-
return self.datasets[dataset_idx]
|
|
1439
|
+
return self.datasets[dataset_idx], sample_idx
|
|
1440
|
+
|
|
1441
|
+
def _get_single_item(self, idx: int):
|
|
1442
|
+
ds, i = self._locate(idx)
|
|
1443
|
+
return ds[i]
|
|
1444
|
+
|
|
1445
|
+
def __getitems__(self, indices):
|
|
1446
|
+
"""Items ``indices``, as ``[self[i] for i in indices]``.
|
|
1447
|
+
|
|
1448
|
+
A :class:`~torch.utils.data.DataLoader` fetches each batch through
|
|
1449
|
+
this. The lazy FIF windows of the batch are first requested from the
|
|
1450
|
+
OS all at once (``posix_fadvise(POSIX_FADV_WILLNEED)``, where it
|
|
1451
|
+
exists), so their reads from disk overlap instead of running one after
|
|
1452
|
+
another: on a network file system a batch read from cold files then
|
|
1453
|
+
costs about one round trip, not one per window.
|
|
1454
|
+
"""
|
|
1455
|
+
# ponytail: advises the whole batch at once; chunk it if a batch's
|
|
1456
|
+
# windows ever outgrow the page cache
|
|
1457
|
+
if hasattr(os, "posix_fadvise"):
|
|
1458
|
+
for idx in indices:
|
|
1459
|
+
if not isinstance(idx, (int, np.integer)):
|
|
1460
|
+
continue # e.g. a SequenceSampler tuple: read, not advised
|
|
1461
|
+
ds, i = self._locate(idx)
|
|
1462
|
+
if isinstance(ds, EEGWindowsDataset) and ds._zarr_data is None:
|
|
1463
|
+
_, start, stop = ds.crop_inds[i].tolist()
|
|
1464
|
+
_read_fif_window(ds.raw, start, stop, willneed=True)
|
|
1465
|
+
return [self[idx] for idx in indices]
|
|
1271
1466
|
|
|
1272
1467
|
def __getitem__(self, idx: int | list):
|
|
1273
1468
|
"""
|
|
@@ -1366,7 +1561,9 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1366
1561
|
metadata : pd.DataFrame
|
|
1367
1562
|
DataFrame containing as many rows as there are windows in the
|
|
1368
1563
|
BaseConcatDataset, with the metadata and description information
|
|
1369
|
-
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.
|
|
1370
1567
|
"""
|
|
1371
1568
|
if not all(
|
|
1372
1569
|
[
|
|
@@ -1392,9 +1589,15 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1392
1589
|
"Dataset descriptions cannot contain the reserved window "
|
|
1393
1590
|
"metadata key 'i_trial_in_dataset'."
|
|
1394
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
|
+
)
|
|
1395
1598
|
|
|
1396
1599
|
all_dfs = list()
|
|
1397
|
-
for ds in self.datasets:
|
|
1600
|
+
for i_ds, ds in enumerate(self.datasets):
|
|
1398
1601
|
if hasattr(ds, "_windows") and ds._windows is not None:
|
|
1399
1602
|
df = ds._windows.metadata
|
|
1400
1603
|
else:
|
|
@@ -1404,6 +1607,7 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1404
1607
|
df = df.copy()
|
|
1405
1608
|
for k, v in ds.description.items():
|
|
1406
1609
|
df[k] = v
|
|
1610
|
+
df["i_dataset"] = i_ds
|
|
1407
1611
|
all_dfs.append(df)
|
|
1408
1612
|
|
|
1409
1613
|
return pd.concat(all_dfs)
|
|
@@ -1672,7 +1876,8 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1672
1876
|
kwargs_path = os.path.join(path, ".".join([kwarg_name, "json"]))
|
|
1673
1877
|
kwargs = getattr(self, kwarg_name)
|
|
1674
1878
|
if kwargs is not None:
|
|
1675
|
-
|
|
1879
|
+
with open(kwargs_path, "w") as f:
|
|
1880
|
+
json.dump(kwargs, f)
|
|
1676
1881
|
|
|
1677
1882
|
@property
|
|
1678
1883
|
def description(self) -> pd.DataFrame:
|
|
@@ -1695,6 +1900,11 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1695
1900
|
dataset description.
|
|
1696
1901
|
"""
|
|
1697
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
|
+
)
|
|
1698
1908
|
for key, value in description.items():
|
|
1699
1909
|
for ds, value_ in zip(self.datasets, value):
|
|
1700
1910
|
ds.set_description({key: value_}, overwrite=overwrite)
|
|
@@ -1725,7 +1935,9 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1725
1935
|
-raw.fif | -epo.fif and .json files to.
|
|
1726
1936
|
overwrite : bool
|
|
1727
1937
|
Whether to delete old subdirectories that will be saved to in this
|
|
1728
|
-
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.
|
|
1729
1941
|
offset : int
|
|
1730
1942
|
If provided, the integer is added to the id of the dataset in the
|
|
1731
1943
|
concat. This is useful in the setting of very large datasets, where
|
|
@@ -1738,11 +1950,21 @@ class BaseConcatDataset(ConcatDataset, HubDatasetMixin, Generic[T]):
|
|
|
1738
1950
|
hasattr(self.datasets[0], "raw") or hasattr(self.datasets[0], "windows")
|
|
1739
1951
|
):
|
|
1740
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
|
+
)
|
|
1741
1960
|
|
|
1742
1961
|
# Create path if it doesn't exist
|
|
1743
1962
|
os.makedirs(path, exist_ok=True)
|
|
1744
1963
|
|
|
1745
|
-
|
|
1964
|
+
# With an offset the caller fills one directory piece by piece (preprocess
|
|
1965
|
+
# saves each recording at its index), so the other entries are expected:
|
|
1966
|
+
# skip the scan that would stat them all on every call and list them in a warning.
|
|
1967
|
+
path_contents = os.listdir(path) if offset == 0 else []
|
|
1746
1968
|
n_sub_dirs = len(
|
|
1747
1969
|
[e for e in path_contents if os.path.isdir(os.path.join(path, e))]
|
|
1748
1970
|
)
|
{braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/braindecode/datasets/tuh.py
RENAMED
|
@@ -16,6 +16,7 @@ import os
|
|
|
16
16
|
import re
|
|
17
17
|
import warnings
|
|
18
18
|
from datetime import datetime, timezone
|
|
19
|
+
from functools import cache
|
|
19
20
|
from pathlib import Path
|
|
20
21
|
from typing import Iterable, Literal
|
|
21
22
|
from unittest import mock
|
|
@@ -184,11 +185,8 @@ class TUH(BaseConcatDataset):
|
|
|
184
185
|
}
|
|
185
186
|
raw.rename_channels(mapping_strip)
|
|
186
187
|
|
|
187
|
-
montage1005 = mne.channels.make_standard_montage(
|
|
188
|
-
resolve_montage_name("standard_1005")
|
|
189
|
-
)
|
|
190
188
|
mapping_eeg_names = {
|
|
191
|
-
c.upper(): c for c in
|
|
189
|
+
c.upper(): c for c in _standard_1005().ch_names if c.upper() in raw.ch_names
|
|
192
190
|
}
|
|
193
191
|
|
|
194
192
|
# Set channels whose type could not be inferred (defaulted to "eeg") to "misc":
|
|
@@ -211,10 +209,7 @@ class TUH(BaseConcatDataset):
|
|
|
211
209
|
|
|
212
210
|
@staticmethod
|
|
213
211
|
def _set_montage(raw):
|
|
214
|
-
|
|
215
|
-
resolve_montage_name("standard_1005")
|
|
216
|
-
)
|
|
217
|
-
raw.set_montage(montage, on_missing="ignore")
|
|
212
|
+
raw.set_montage(_standard_1005(), on_missing="ignore")
|
|
218
213
|
|
|
219
214
|
@staticmethod
|
|
220
215
|
def _create_dataset(
|
|
@@ -246,7 +241,11 @@ class TUH(BaseConcatDataset):
|
|
|
246
241
|
# file paths, use this instead as before
|
|
247
242
|
if "year" in description:
|
|
248
243
|
meas_date = meas_date.replace(*description[["year", "month", "day"]])
|
|
249
|
-
|
|
244
|
+
# FIF (e.g. preprocess(..., save_dir=...)) stores dates from 1901-12-13 to
|
|
245
|
+
# 2038-01-19 only: undated recordings (year 1 above) and de-identified ones
|
|
246
|
+
# (TUAB has 1899-12-30) keep their date in the description only.
|
|
247
|
+
in_fif_range = -(2**31) <= meas_date.timestamp() < 2**31
|
|
248
|
+
raw.set_meas_date(meas_date if in_fif_range else None)
|
|
250
249
|
|
|
251
250
|
d = {
|
|
252
251
|
"age": int(age),
|
|
@@ -256,9 +255,9 @@ class TUH(BaseConcatDataset):
|
|
|
256
255
|
# if not, get it from meas_date in raw.info and add to description
|
|
257
256
|
# if meas_date is None, create fake one
|
|
258
257
|
if "year" not in description:
|
|
259
|
-
d["year"] =
|
|
260
|
-
d["month"] =
|
|
261
|
-
d["day"] =
|
|
258
|
+
d["year"] = meas_date.year
|
|
259
|
+
d["month"] = meas_date.month
|
|
260
|
+
d["day"] = meas_date.day
|
|
262
261
|
|
|
263
262
|
# read info relevant for preprocessing from raw without loading it
|
|
264
263
|
if add_physician_reports:
|
|
@@ -270,6 +269,12 @@ class TUH(BaseConcatDataset):
|
|
|
270
269
|
return base_dataset
|
|
271
270
|
|
|
272
271
|
|
|
272
|
+
@cache
|
|
273
|
+
def _standard_1005():
|
|
274
|
+
# Built once per process: set_montage copies the montage before using it.
|
|
275
|
+
return mne.channels.make_standard_montage(resolve_montage_name("standard_1005"))
|
|
276
|
+
|
|
277
|
+
|
|
273
278
|
def _create_description(file_paths, version, ds_name):
|
|
274
279
|
descriptions = [
|
|
275
280
|
_parse_description_from_file_path(f, version, ds_name) for f in file_paths
|
|
@@ -21,6 +21,7 @@ from ..datasets.base import (
|
|
|
21
21
|
EEGWindowsDataset,
|
|
22
22
|
RawDataset,
|
|
23
23
|
WindowsDataset,
|
|
24
|
+
_compact_fif_tags,
|
|
24
25
|
)
|
|
25
26
|
|
|
26
27
|
|
|
@@ -79,7 +80,8 @@ def _outdated_load_concat_dataset(path, preload, ids_to_load=None, target_name=N
|
|
|
79
80
|
for path in paths:
|
|
80
81
|
if is_raw and target_name is None:
|
|
81
82
|
target_file_name = path / "target_name.json"
|
|
82
|
-
|
|
83
|
+
with open(target_file_name) as f:
|
|
84
|
+
target_name = json.load(f)["target_name"]
|
|
83
85
|
|
|
84
86
|
all_signals, description = _load_signals_and_description(
|
|
85
87
|
path=path, preload=preload, is_raw=is_raw, ids_to_load=ids_to_load
|
|
@@ -141,7 +143,7 @@ def _load_signals(fif_file, preload, is_raw):
|
|
|
141
143
|
if all(Path(f).exists() for f in signals.filenames):
|
|
142
144
|
if preload:
|
|
143
145
|
signals.load_data()
|
|
144
|
-
return signals
|
|
146
|
+
return _compact_fif_tags(signals)
|
|
145
147
|
else: # This may happen if the file has been moved together with the pickle file.
|
|
146
148
|
warnings.warn(
|
|
147
149
|
f"Pickle file {pkl_file} exists, but the referenced fif "
|
|
@@ -171,7 +173,8 @@ def _load_signals(fif_file, preload, is_raw):
|
|
|
171
173
|
if preload:
|
|
172
174
|
signals._data, signals.preload = data, True
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
# after the pickle above, which keeps mne's own layout on disk
|
|
177
|
+
return _compact_fif_tags(signals)
|
|
175
178
|
|
|
176
179
|
|
|
177
180
|
def load_concat_dataset(path, preload, ids_to_load=None, target_name=None, n_jobs=1):
|
|
@@ -264,7 +267,8 @@ def _load_parallel(path, i, preload, is_raw, has_stored_windows):
|
|
|
264
267
|
target_file_path = sub_dir / "target_name.json"
|
|
265
268
|
target_name = None
|
|
266
269
|
if target_file_path.exists():
|
|
267
|
-
|
|
270
|
+
with open(target_file_path) as f:
|
|
271
|
+
target_name = json.load(f)["target_name"]
|
|
268
272
|
|
|
269
273
|
if is_raw and (not has_stored_windows):
|
|
270
274
|
dataset = RawDataset(signals, description, target_name)
|
|
@@ -304,8 +308,8 @@ def _load_kwargs_json(kwargs_name, sub_dir):
|
|
|
304
308
|
kwargs_file_name = ".".join([kwargs_name, "json"])
|
|
305
309
|
kwargs_file_path = os.path.join(sub_dir, kwargs_file_name)
|
|
306
310
|
if os.path.exists(kwargs_file_path):
|
|
307
|
-
|
|
308
|
-
|
|
311
|
+
with open(kwargs_file_path) as f:
|
|
312
|
+
return json.load(f)
|
|
309
313
|
|
|
310
314
|
|
|
311
315
|
def _is_outdated_saved(path):
|
{braindecode-1.8.1.dev181333418 → braindecode-1.8.1.dev181501004}/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:
|