braindecode 1.3.0.dev177069446__py3-none-any.whl
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/__init__.py +9 -0
- braindecode/augmentation/__init__.py +52 -0
- braindecode/augmentation/base.py +225 -0
- braindecode/augmentation/functional.py +1300 -0
- braindecode/augmentation/transforms.py +1356 -0
- braindecode/classifier.py +258 -0
- braindecode/datasets/__init__.py +44 -0
- braindecode/datasets/base.py +823 -0
- braindecode/datasets/bbci.py +693 -0
- braindecode/datasets/bcicomp.py +193 -0
- braindecode/datasets/bids/__init__.py +54 -0
- braindecode/datasets/bids/datasets.py +239 -0
- braindecode/datasets/bids/format.py +717 -0
- braindecode/datasets/bids/hub.py +987 -0
- braindecode/datasets/bids/hub_format.py +717 -0
- braindecode/datasets/bids/hub_io.py +197 -0
- braindecode/datasets/bids/hub_validation.py +114 -0
- braindecode/datasets/bids/iterable.py +220 -0
- braindecode/datasets/chb_mit.py +163 -0
- braindecode/datasets/mne.py +170 -0
- braindecode/datasets/moabb.py +219 -0
- braindecode/datasets/nmt.py +313 -0
- braindecode/datasets/registry.py +120 -0
- braindecode/datasets/siena.py +162 -0
- braindecode/datasets/sleep_physio_challe_18.py +411 -0
- braindecode/datasets/sleep_physionet.py +125 -0
- braindecode/datasets/tuh.py +591 -0
- braindecode/datasets/utils.py +67 -0
- braindecode/datasets/xy.py +96 -0
- braindecode/datautil/__init__.py +62 -0
- braindecode/datautil/channel_utils.py +114 -0
- braindecode/datautil/hub_formats.py +180 -0
- braindecode/datautil/serialization.py +359 -0
- braindecode/datautil/util.py +154 -0
- braindecode/eegneuralnet.py +372 -0
- braindecode/functional/__init__.py +22 -0
- braindecode/functional/functions.py +251 -0
- braindecode/functional/initialization.py +47 -0
- braindecode/models/__init__.py +117 -0
- braindecode/models/atcnet.py +830 -0
- braindecode/models/attentionbasenet.py +727 -0
- braindecode/models/attn_sleep.py +549 -0
- braindecode/models/base.py +574 -0
- braindecode/models/bendr.py +493 -0
- braindecode/models/biot.py +537 -0
- braindecode/models/brainmodule.py +845 -0
- braindecode/models/config.py +233 -0
- braindecode/models/contrawr.py +319 -0
- braindecode/models/ctnet.py +541 -0
- braindecode/models/deep4.py +376 -0
- braindecode/models/deepsleepnet.py +417 -0
- braindecode/models/eegconformer.py +475 -0
- braindecode/models/eeginception_erp.py +379 -0
- braindecode/models/eeginception_mi.py +379 -0
- braindecode/models/eegitnet.py +302 -0
- braindecode/models/eegminer.py +256 -0
- braindecode/models/eegnet.py +359 -0
- braindecode/models/eegnex.py +354 -0
- braindecode/models/eegsimpleconv.py +201 -0
- braindecode/models/eegsym.py +917 -0
- braindecode/models/eegtcnet.py +337 -0
- braindecode/models/fbcnet.py +225 -0
- braindecode/models/fblightconvnet.py +315 -0
- braindecode/models/fbmsnet.py +338 -0
- braindecode/models/hybrid.py +126 -0
- braindecode/models/ifnet.py +443 -0
- braindecode/models/labram.py +1316 -0
- braindecode/models/luna.py +891 -0
- braindecode/models/medformer.py +760 -0
- braindecode/models/msvtnet.py +377 -0
- braindecode/models/patchedtransformer.py +640 -0
- braindecode/models/reve.py +843 -0
- braindecode/models/sccnet.py +280 -0
- braindecode/models/shallow_fbcsp.py +212 -0
- braindecode/models/signal_jepa.py +1122 -0
- braindecode/models/sinc_shallow.py +339 -0
- braindecode/models/sleep_stager_blanco_2020.py +169 -0
- braindecode/models/sleep_stager_chambon_2018.py +159 -0
- braindecode/models/sparcnet.py +426 -0
- braindecode/models/sstdpn.py +869 -0
- braindecode/models/summary.csv +47 -0
- braindecode/models/syncnet.py +234 -0
- braindecode/models/tcn.py +275 -0
- braindecode/models/tidnet.py +397 -0
- braindecode/models/tsinception.py +295 -0
- braindecode/models/usleep.py +439 -0
- braindecode/models/util.py +369 -0
- braindecode/modules/__init__.py +92 -0
- braindecode/modules/activation.py +86 -0
- braindecode/modules/attention.py +883 -0
- braindecode/modules/blocks.py +160 -0
- braindecode/modules/convolution.py +330 -0
- braindecode/modules/filter.py +654 -0
- braindecode/modules/layers.py +216 -0
- braindecode/modules/linear.py +70 -0
- braindecode/modules/parametrization.py +38 -0
- braindecode/modules/stats.py +87 -0
- braindecode/modules/util.py +85 -0
- braindecode/modules/wrapper.py +90 -0
- braindecode/preprocessing/__init__.py +271 -0
- braindecode/preprocessing/eegprep_preprocess.py +1317 -0
- braindecode/preprocessing/mne_preprocess.py +240 -0
- braindecode/preprocessing/preprocess.py +579 -0
- braindecode/preprocessing/util.py +177 -0
- braindecode/preprocessing/windowers.py +1037 -0
- braindecode/regressor.py +234 -0
- braindecode/samplers/__init__.py +18 -0
- braindecode/samplers/base.py +399 -0
- braindecode/samplers/ssl.py +263 -0
- braindecode/training/__init__.py +23 -0
- braindecode/training/callbacks.py +23 -0
- braindecode/training/losses.py +105 -0
- braindecode/training/scoring.py +477 -0
- braindecode/util.py +419 -0
- braindecode/version.py +1 -0
- braindecode/visualization/__init__.py +8 -0
- braindecode/visualization/confusion_matrices.py +289 -0
- braindecode/visualization/gradients.py +62 -0
- braindecode-1.3.0.dev177069446.dist-info/METADATA +230 -0
- braindecode-1.3.0.dev177069446.dist-info/RECORD +124 -0
- braindecode-1.3.0.dev177069446.dist-info/WHEEL +5 -0
- braindecode-1.3.0.dev177069446.dist-info/licenses/LICENSE.txt +31 -0
- braindecode-1.3.0.dev177069446.dist-info/licenses/NOTICE.txt +20 -0
- braindecode-1.3.0.dev177069446.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"""Preprocessing module for EEG data.
|
|
2
|
+
|
|
3
|
+
This module provides preprocessing functionality for EEG data through:
|
|
4
|
+
|
|
5
|
+
1. **MNE-based preprocessing classes**: Automatically generated classes that wrap
|
|
6
|
+
MNE-Python functions for easy integration with Braindecode workflows.
|
|
7
|
+
2. **Custom preprocessing functions**: Specialized functions for EEG preprocessing.
|
|
8
|
+
3. **Windowing functions**: Tools for creating epochs/windows from continuous data.
|
|
9
|
+
|
|
10
|
+
MNE Preprocessing Classes
|
|
11
|
+
--------------------------
|
|
12
|
+
The following preprocessing classes are automatically generated from MNE functions.
|
|
13
|
+
Each class inherits from :class:`~braindecode.preprocessing.Preprocessor` and can be
|
|
14
|
+
used with :func:`~braindecode.preprocessing.preprocess`.
|
|
15
|
+
|
|
16
|
+
**Signal Processing**
|
|
17
|
+
|
|
18
|
+
- :class:`~braindecode.preprocessing.Resample` : Resample data to different sampling frequency
|
|
19
|
+
- :class:`~braindecode.preprocessing.Filter` : Apply bandpass, highpass, or lowpass filter
|
|
20
|
+
- :class:`~braindecode.preprocessing.FilterData` : Low-level filter function for data arrays
|
|
21
|
+
- :class:`~braindecode.preprocessing.NotchFilter` : Remove specific frequencies (e.g., 50/60 Hz power line noise)
|
|
22
|
+
- :class:`~braindecode.preprocessing.SavgolFilter` : Apply Savitzky-Golay polynomial filter
|
|
23
|
+
- :class:`~braindecode.preprocessing.ApplyHilbert` : Compute analytic signal or envelope
|
|
24
|
+
- :class:`~braindecode.preprocessing.Rescale` : Rescale channel amplitudes
|
|
25
|
+
- :class:`~braindecode.preprocessing.OversampledTemporalProjection` : Apply oversampled temporal projection
|
|
26
|
+
|
|
27
|
+
**Channel Management**
|
|
28
|
+
|
|
29
|
+
- :class:`~braindecode.preprocessing.Pick` : Select specific channels or channel types
|
|
30
|
+
- :class:`~braindecode.preprocessing.PickChannels` : Pick channels by name
|
|
31
|
+
- :class:`~braindecode.preprocessing.PickTypes` : Pick channels by type (EEG, MEG, etc.)
|
|
32
|
+
- :class:`~braindecode.preprocessing.DropChannels` : Remove specific channels
|
|
33
|
+
- :class:`~braindecode.preprocessing.AddChannels` : Append new channels from other MNE objects
|
|
34
|
+
- :class:`~braindecode.preprocessing.CombineChannels` : Combine data from multiple channels
|
|
35
|
+
- :class:`~braindecode.preprocessing.RenameChannels` : Rename channels
|
|
36
|
+
- :class:`~braindecode.preprocessing.ReorderChannels` : Reorder channels
|
|
37
|
+
- :class:`~braindecode.preprocessing.SetChannelTypes` : Specify sensor types of channels
|
|
38
|
+
- :class:`~braindecode.preprocessing.InterpolateBads` : Interpolate bad channels
|
|
39
|
+
- :class:`~braindecode.preprocessing.InterpolateTo` : Interpolate EEG data onto new montage
|
|
40
|
+
- :class:`~braindecode.preprocessing.InterpolateBridgedElectrodes` : Interpolate bridged electrodes
|
|
41
|
+
- :class:`~braindecode.preprocessing.ComputeBridgedElectrodes` : Identify bridged electrodes
|
|
42
|
+
- :class:`~braindecode.preprocessing.EqualizeChannels` : Make channel sets identical across datasets
|
|
43
|
+
- :class:`~braindecode.preprocessing.EqualizeBads` : Equalize bad channels across instances
|
|
44
|
+
- :class:`~braindecode.preprocessing.FindBadChannelsLof` : Find bad channels using LOF algorithm
|
|
45
|
+
|
|
46
|
+
**Reference & Montage**
|
|
47
|
+
|
|
48
|
+
- :class:`~braindecode.preprocessing.SetEEGReference` : Specify EEG reference (Raw method)
|
|
49
|
+
- :class:`~braindecode.preprocessing.SetBipolarReference` : Set bipolar reference
|
|
50
|
+
- :class:`~braindecode.preprocessing.AddReferenceChannels` : Add zero-filled reference channels
|
|
51
|
+
- :class:`~braindecode.preprocessing.SetMontage` : Set channel positions/montage
|
|
52
|
+
|
|
53
|
+
**SSP Projections**
|
|
54
|
+
|
|
55
|
+
- :class:`~braindecode.preprocessing.AddProj` : Add SSP projection vectors
|
|
56
|
+
- :class:`~braindecode.preprocessing.ApplyProj` : Apply SSP operators
|
|
57
|
+
- :class:`~braindecode.preprocessing.DelProj` : Remove SSP projection vector
|
|
58
|
+
|
|
59
|
+
**Data Transformation**
|
|
60
|
+
|
|
61
|
+
- :class:`~braindecode.preprocessing.Crop` : Crop data to specific time range
|
|
62
|
+
- :class:`~braindecode.preprocessing.CropByAnnotations` : Crop data by annotations
|
|
63
|
+
- :class:`~braindecode.preprocessing.ComputeCurrentSourceDensity` : Apply CSD transformation
|
|
64
|
+
- :class:`~braindecode.preprocessing.FixStimArtifact` : Remove stimulation artifacts
|
|
65
|
+
- :class:`~braindecode.preprocessing.MaxwellFilter` : Apply Maxwell filtering (for MEG data)
|
|
66
|
+
- :class:`~braindecode.preprocessing.RealignRaw` : Realign raw data
|
|
67
|
+
- :class:`~braindecode.preprocessing.RegressArtifact` : Regress out artifacts
|
|
68
|
+
|
|
69
|
+
**Artifact Detection & Annotation**
|
|
70
|
+
|
|
71
|
+
- :class:`~braindecode.preprocessing.AnnotateAmplitude` : Annotate periods based on amplitude
|
|
72
|
+
- :class:`~braindecode.preprocessing.AnnotateBreak` : Annotate breaks in the data
|
|
73
|
+
- :class:`~braindecode.preprocessing.AnnotateMovement` : Annotate movement artifacts
|
|
74
|
+
- :class:`~braindecode.preprocessing.AnnotateMuscleZscore` : Annotate muscle artifacts using z-score
|
|
75
|
+
- :class:`~braindecode.preprocessing.AnnotateNan` : Annotate NaN values in data
|
|
76
|
+
|
|
77
|
+
**Metadata & Configuration**
|
|
78
|
+
|
|
79
|
+
- :class:`~braindecode.preprocessing.Anonymize` : Anonymize measurement information
|
|
80
|
+
- :class:`~braindecode.preprocessing.SetAnnotations` : Set annotations
|
|
81
|
+
- :class:`~braindecode.preprocessing.SetMeasDate` : Set measurement start date
|
|
82
|
+
- :class:`~braindecode.preprocessing.AddEvents` : Add events to stim channel
|
|
83
|
+
- :class:`~braindecode.preprocessing.FixMagCoilTypes` : Fix Elekta magnetometer coil types
|
|
84
|
+
- :class:`~braindecode.preprocessing.ApplyGradientCompensation` : Apply CTF gradient compensation
|
|
85
|
+
|
|
86
|
+
Usage Examples
|
|
87
|
+
--------------
|
|
88
|
+
Using the new preprocessing classes::
|
|
89
|
+
|
|
90
|
+
from braindecode.preprocessing import (
|
|
91
|
+
Resample, Filter, NotchFilter, SetEEGReference, preprocess
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
preprocessors = [
|
|
95
|
+
Resample(sfreq=100),
|
|
96
|
+
NotchFilter(freqs=[50]), # Remove 50 Hz power line noise
|
|
97
|
+
Filter(l_freq=4, h_freq=30), # Bandpass filter
|
|
98
|
+
SetEEGReference(ref_channels='average'),
|
|
99
|
+
]
|
|
100
|
+
preprocess(dataset, preprocessors)
|
|
101
|
+
|
|
102
|
+
Using the generic Preprocessor class (legacy approach)::
|
|
103
|
+
|
|
104
|
+
from braindecode.preprocessing import Preprocessor, preprocess
|
|
105
|
+
|
|
106
|
+
preprocessors = [
|
|
107
|
+
Preprocessor('resample', sfreq=100),
|
|
108
|
+
Preprocessor('filter', l_freq=4, h_freq=30),
|
|
109
|
+
]
|
|
110
|
+
preprocess(dataset, preprocessors)
|
|
111
|
+
|
|
112
|
+
See Also
|
|
113
|
+
--------
|
|
114
|
+
:class:`braindecode.preprocessing.Preprocessor` : Base class for all preprocessors
|
|
115
|
+
:func:`braindecode.preprocessing.preprocess` : Apply preprocessors to datasets
|
|
116
|
+
:func:`braindecode.preprocessing.create_windows_from_events` : Create epochs from events
|
|
117
|
+
:func:`braindecode.preprocessing.create_fixed_length_windows` : Create fixed-length epochs
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
from .eegprep_preprocess import (
|
|
121
|
+
EEGPrep,
|
|
122
|
+
ReinterpolateRemovedChannels,
|
|
123
|
+
RemoveBadChannels,
|
|
124
|
+
RemoveBadChannelsNoLocs,
|
|
125
|
+
RemoveBadWindows,
|
|
126
|
+
RemoveBursts,
|
|
127
|
+
RemoveCommonAverageReference,
|
|
128
|
+
RemoveDCOffset,
|
|
129
|
+
RemoveDrifts,
|
|
130
|
+
RemoveFlatChannels,
|
|
131
|
+
Resampling,
|
|
132
|
+
)
|
|
133
|
+
from .mne_preprocess import ( # type: ignore[attr-defined]
|
|
134
|
+
AddChannels,
|
|
135
|
+
AddEvents,
|
|
136
|
+
AddProj,
|
|
137
|
+
AddReferenceChannels,
|
|
138
|
+
AnnotateAmplitude,
|
|
139
|
+
AnnotateBreak,
|
|
140
|
+
AnnotateMovement,
|
|
141
|
+
AnnotateMuscleZscore,
|
|
142
|
+
AnnotateNan,
|
|
143
|
+
Anonymize,
|
|
144
|
+
ApplyGradientCompensation,
|
|
145
|
+
ApplyHilbert,
|
|
146
|
+
ApplyProj,
|
|
147
|
+
CombineChannels,
|
|
148
|
+
ComputeBridgedElectrodes,
|
|
149
|
+
ComputeCurrentSourceDensity,
|
|
150
|
+
Crop,
|
|
151
|
+
CropByAnnotations,
|
|
152
|
+
DelProj,
|
|
153
|
+
DropChannels,
|
|
154
|
+
EqualizeBads,
|
|
155
|
+
EqualizeChannels,
|
|
156
|
+
Filter,
|
|
157
|
+
FilterData,
|
|
158
|
+
FindBadChannelsLof,
|
|
159
|
+
FixMagCoilTypes,
|
|
160
|
+
FixStimArtifact,
|
|
161
|
+
InterpolateBads,
|
|
162
|
+
InterpolateBridgedElectrodes,
|
|
163
|
+
InterpolateTo,
|
|
164
|
+
MaxwellFilter,
|
|
165
|
+
NotchFilter,
|
|
166
|
+
OversampledTemporalProjection,
|
|
167
|
+
Pick,
|
|
168
|
+
PickChannels,
|
|
169
|
+
PickTypes,
|
|
170
|
+
RealignRaw,
|
|
171
|
+
RegressArtifact,
|
|
172
|
+
RenameChannels,
|
|
173
|
+
ReorderChannels,
|
|
174
|
+
Resample,
|
|
175
|
+
Rescale,
|
|
176
|
+
SavgolFilter,
|
|
177
|
+
SetAnnotations,
|
|
178
|
+
SetBipolarReference,
|
|
179
|
+
SetChannelTypes,
|
|
180
|
+
SetEEGReference,
|
|
181
|
+
SetMeasDate,
|
|
182
|
+
SetMontage,
|
|
183
|
+
)
|
|
184
|
+
from .preprocess import (
|
|
185
|
+
Preprocessor,
|
|
186
|
+
exponential_moving_demean,
|
|
187
|
+
exponential_moving_standardize,
|
|
188
|
+
filterbank,
|
|
189
|
+
preprocess,
|
|
190
|
+
)
|
|
191
|
+
from .util import _init_preprocessor_dict
|
|
192
|
+
from .windowers import (
|
|
193
|
+
create_fixed_length_windows,
|
|
194
|
+
create_windows_from_events,
|
|
195
|
+
create_windows_from_target_channels,
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
# Call this last in order to make sure the list is populated with
|
|
199
|
+
# the preprocessors imported in this file.
|
|
200
|
+
_init_preprocessor_dict()
|
|
201
|
+
|
|
202
|
+
__all__ = [
|
|
203
|
+
"exponential_moving_demean",
|
|
204
|
+
"exponential_moving_standardize",
|
|
205
|
+
"filterbank",
|
|
206
|
+
"preprocess",
|
|
207
|
+
"Preprocessor",
|
|
208
|
+
"AddChannels",
|
|
209
|
+
"AddEvents",
|
|
210
|
+
"AddProj",
|
|
211
|
+
"AddReferenceChannels",
|
|
212
|
+
"Anonymize",
|
|
213
|
+
"AnnotateAmplitude",
|
|
214
|
+
"AnnotateBreak",
|
|
215
|
+
"AnnotateMovement",
|
|
216
|
+
"AnnotateMuscleZscore",
|
|
217
|
+
"AnnotateNan",
|
|
218
|
+
"ApplyGradientCompensation",
|
|
219
|
+
"ApplyHilbert",
|
|
220
|
+
"ApplyProj",
|
|
221
|
+
"CombineChannels",
|
|
222
|
+
"ComputeBridgedElectrodes",
|
|
223
|
+
"ComputeCurrentSourceDensity",
|
|
224
|
+
"Crop",
|
|
225
|
+
"CropByAnnotations",
|
|
226
|
+
"DelProj",
|
|
227
|
+
"DropChannels",
|
|
228
|
+
"EqualizeBads",
|
|
229
|
+
"EqualizeChannels",
|
|
230
|
+
"Filter",
|
|
231
|
+
"FilterData",
|
|
232
|
+
"FindBadChannelsLof",
|
|
233
|
+
"FixMagCoilTypes",
|
|
234
|
+
"FixStimArtifact",
|
|
235
|
+
"InterpolateBads",
|
|
236
|
+
"InterpolateBridgedElectrodes",
|
|
237
|
+
"InterpolateTo",
|
|
238
|
+
"MaxwellFilter",
|
|
239
|
+
"NotchFilter",
|
|
240
|
+
"OversampledTemporalProjection",
|
|
241
|
+
"Pick",
|
|
242
|
+
"PickChannels",
|
|
243
|
+
"PickTypes",
|
|
244
|
+
"RealignRaw",
|
|
245
|
+
"RegressArtifact",
|
|
246
|
+
"RenameChannels",
|
|
247
|
+
"ReorderChannels",
|
|
248
|
+
"Resample",
|
|
249
|
+
"Rescale",
|
|
250
|
+
"SavgolFilter",
|
|
251
|
+
"SetAnnotations",
|
|
252
|
+
"SetBipolarReference",
|
|
253
|
+
"SetChannelTypes",
|
|
254
|
+
"SetEEGReference",
|
|
255
|
+
"SetMeasDate",
|
|
256
|
+
"SetMontage",
|
|
257
|
+
"EEGPrep",
|
|
258
|
+
"RemoveDCOffset",
|
|
259
|
+
"Resampling",
|
|
260
|
+
"RemoveFlatChannels",
|
|
261
|
+
"RemoveDrifts",
|
|
262
|
+
"RemoveBadChannels",
|
|
263
|
+
"RemoveBadChannelsNoLocs",
|
|
264
|
+
"RemoveBursts",
|
|
265
|
+
"RemoveBadWindows",
|
|
266
|
+
"ReinterpolateRemovedChannels",
|
|
267
|
+
"RemoveCommonAverageReference",
|
|
268
|
+
"create_windows_from_events",
|
|
269
|
+
"create_fixed_length_windows",
|
|
270
|
+
"create_windows_from_target_channels",
|
|
271
|
+
]
|