braindecode 1.3.0.dev180329405__py3-none-any.whl → 1.3.0.dev182330353__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/augmentation/base.py +1 -1
- braindecode/datasets/__init__.py +12 -4
- braindecode/datasets/base.py +115 -151
- braindecode/datasets/bcicomp.py +4 -4
- braindecode/datasets/bids.py +3 -3
- braindecode/datasets/experimental.py +2 -2
- braindecode/datasets/mne.py +3 -5
- braindecode/datasets/moabb.py +17 -7
- braindecode/datasets/nmt.py +2 -2
- braindecode/datasets/sleep_physio_challe_18.py +2 -2
- braindecode/datasets/sleep_physionet.py +2 -2
- braindecode/datasets/tuh.py +2 -2
- braindecode/datasets/xy.py +2 -2
- braindecode/datautil/__init__.py +11 -1
- braindecode/datautil/channel_utils.py +114 -0
- braindecode/datautil/serialization.py +7 -7
- braindecode/functional/functions.py +6 -2
- braindecode/functional/initialization.py +2 -3
- braindecode/models/__init__.py +6 -0
- braindecode/models/atcnet.py +26 -27
- braindecode/models/attentionbasenet.py +37 -32
- braindecode/models/attn_sleep.py +2 -0
- braindecode/models/base.py +280 -2
- braindecode/models/bendr.py +469 -0
- braindecode/models/biot.py +2 -0
- braindecode/models/contrawr.py +2 -0
- braindecode/models/ctnet.py +8 -3
- braindecode/models/deepsleepnet.py +28 -19
- braindecode/models/eegconformer.py +2 -2
- braindecode/models/eeginception_erp.py +31 -25
- braindecode/models/eegitnet.py +2 -0
- braindecode/models/eegminer.py +2 -0
- braindecode/models/eegnet.py +1 -1
- braindecode/models/eegsym.py +917 -0
- braindecode/models/eegtcnet.py +2 -0
- braindecode/models/fbcnet.py +5 -1
- braindecode/models/fblightconvnet.py +2 -0
- braindecode/models/fbmsnet.py +20 -6
- braindecode/models/ifnet.py +2 -0
- braindecode/models/labram.py +33 -26
- braindecode/models/medformer.py +758 -0
- braindecode/models/msvtnet.py +2 -0
- braindecode/models/patchedtransformer.py +1 -1
- braindecode/models/signal_jepa.py +111 -27
- braindecode/models/sinc_shallow.py +12 -9
- braindecode/models/sstdpn.py +11 -11
- braindecode/models/summary.csv +3 -0
- braindecode/models/syncnet.py +2 -0
- braindecode/models/tcn.py +2 -0
- braindecode/models/usleep.py +26 -21
- braindecode/models/util.py +3 -0
- braindecode/modules/attention.py +10 -10
- braindecode/modules/blocks.py +3 -3
- braindecode/modules/filter.py +2 -9
- braindecode/modules/layers.py +18 -17
- braindecode/preprocessing/__init__.py +232 -3
- braindecode/preprocessing/eegprep_preprocess.py +1202 -0
- braindecode/preprocessing/mne_preprocess.py +142 -10
- braindecode/preprocessing/preprocess.py +28 -18
- braindecode/preprocessing/util.py +166 -0
- braindecode/preprocessing/windowers.py +26 -20
- braindecode/samplers/base.py +8 -8
- braindecode/version.py +1 -1
- {braindecode-1.3.0.dev180329405.dist-info → braindecode-1.3.0.dev182330353.dist-info}/METADATA +6 -2
- braindecode-1.3.0.dev182330353.dist-info/RECORD +109 -0
- braindecode-1.3.0.dev180329405.dist-info/RECORD +0 -103
- {braindecode-1.3.0.dev180329405.dist-info → braindecode-1.3.0.dev182330353.dist-info}/WHEEL +0 -0
- {braindecode-1.3.0.dev180329405.dist-info → braindecode-1.3.0.dev182330353.dist-info}/licenses/LICENSE.txt +0 -0
- {braindecode-1.3.0.dev180329405.dist-info → braindecode-1.3.0.dev182330353.dist-info}/licenses/NOTICE.txt +0 -0
- {braindecode-1.3.0.dev180329405.dist-info → braindecode-1.3.0.dev182330353.dist-info}/top_level.txt +0 -0
braindecode/modules/layers.py
CHANGED
|
@@ -70,26 +70,27 @@ class TimeDistributed(nn.Module):
|
|
|
70
70
|
class DropPath(nn.Module):
|
|
71
71
|
"""Drop paths, also known as Stochastic Depth, per sample.
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
When applied in main path of residual blocks.
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
drop_prob: float (default=None)
|
|
78
|
+
Drop path probability (should be in range 0-1).
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
Notes
|
|
81
|
+
-----
|
|
82
|
+
Code copied and modified from VISSL facebookresearch:
|
|
83
83
|
https://github.com/facebookresearch/vissl/blob/0b5d6a94437bc00baed112ca90c9d78c6ccfbafb/vissl/models/model_helpers.py#L676
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
|
|
85
|
+
All rights reserved.
|
|
86
|
+
|
|
87
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
88
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
89
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
90
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
91
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
92
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
93
|
+
SOFTWARE.
|
|
93
94
|
"""
|
|
94
95
|
|
|
95
96
|
def __init__(self, drop_prob=None):
|
|
@@ -1,10 +1,185 @@
|
|
|
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
|
+
)
|
|
1
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,
|
|
2
150
|
Crop,
|
|
151
|
+
CropByAnnotations,
|
|
152
|
+
DelProj,
|
|
3
153
|
DropChannels,
|
|
154
|
+
EqualizeBads,
|
|
155
|
+
EqualizeChannels,
|
|
4
156
|
Filter,
|
|
157
|
+
FilterData,
|
|
158
|
+
FindBadChannelsLof,
|
|
159
|
+
FixMagCoilTypes,
|
|
160
|
+
FixStimArtifact,
|
|
161
|
+
InterpolateBads,
|
|
162
|
+
InterpolateBridgedElectrodes,
|
|
163
|
+
InterpolateTo,
|
|
164
|
+
MaxwellFilter,
|
|
165
|
+
NotchFilter,
|
|
166
|
+
OversampledTemporalProjection,
|
|
5
167
|
Pick,
|
|
168
|
+
PickChannels,
|
|
169
|
+
PickTypes,
|
|
170
|
+
RealignRaw,
|
|
171
|
+
RegressArtifact,
|
|
172
|
+
RenameChannels,
|
|
173
|
+
ReorderChannels,
|
|
6
174
|
Resample,
|
|
175
|
+
Rescale,
|
|
176
|
+
SavgolFilter,
|
|
177
|
+
SetAnnotations,
|
|
178
|
+
SetBipolarReference,
|
|
179
|
+
SetChannelTypes,
|
|
7
180
|
SetEEGReference,
|
|
181
|
+
SetMeasDate,
|
|
182
|
+
SetMontage,
|
|
8
183
|
)
|
|
9
184
|
from .preprocess import (
|
|
10
185
|
Preprocessor,
|
|
@@ -25,12 +200,66 @@ __all__ = [
|
|
|
25
200
|
"filterbank",
|
|
26
201
|
"preprocess",
|
|
27
202
|
"Preprocessor",
|
|
28
|
-
"
|
|
203
|
+
"AddChannels",
|
|
204
|
+
"AddEvents",
|
|
205
|
+
"AddProj",
|
|
206
|
+
"AddReferenceChannels",
|
|
207
|
+
"Anonymize",
|
|
208
|
+
"AnnotateAmplitude",
|
|
209
|
+
"AnnotateBreak",
|
|
210
|
+
"AnnotateMovement",
|
|
211
|
+
"AnnotateMuscleZscore",
|
|
212
|
+
"AnnotateNan",
|
|
213
|
+
"ApplyGradientCompensation",
|
|
214
|
+
"ApplyHilbert",
|
|
215
|
+
"ApplyProj",
|
|
216
|
+
"CombineChannels",
|
|
217
|
+
"ComputeBridgedElectrodes",
|
|
218
|
+
"ComputeCurrentSourceDensity",
|
|
219
|
+
"Crop",
|
|
220
|
+
"CropByAnnotations",
|
|
221
|
+
"DelProj",
|
|
29
222
|
"DropChannels",
|
|
30
|
-
"
|
|
223
|
+
"EqualizeBads",
|
|
224
|
+
"EqualizeChannels",
|
|
31
225
|
"Filter",
|
|
226
|
+
"FilterData",
|
|
227
|
+
"FindBadChannelsLof",
|
|
228
|
+
"FixMagCoilTypes",
|
|
229
|
+
"FixStimArtifact",
|
|
230
|
+
"InterpolateBads",
|
|
231
|
+
"InterpolateBridgedElectrodes",
|
|
232
|
+
"InterpolateTo",
|
|
233
|
+
"MaxwellFilter",
|
|
234
|
+
"NotchFilter",
|
|
235
|
+
"OversampledTemporalProjection",
|
|
32
236
|
"Pick",
|
|
33
|
-
"
|
|
237
|
+
"PickChannels",
|
|
238
|
+
"PickTypes",
|
|
239
|
+
"RealignRaw",
|
|
240
|
+
"RegressArtifact",
|
|
241
|
+
"RenameChannels",
|
|
242
|
+
"ReorderChannels",
|
|
243
|
+
"Resample",
|
|
244
|
+
"Rescale",
|
|
245
|
+
"SavgolFilter",
|
|
246
|
+
"SetAnnotations",
|
|
247
|
+
"SetBipolarReference",
|
|
248
|
+
"SetChannelTypes",
|
|
249
|
+
"SetEEGReference",
|
|
250
|
+
"SetMeasDate",
|
|
251
|
+
"SetMontage",
|
|
252
|
+
"EEGPrep",
|
|
253
|
+
"RemoveDCOffset",
|
|
254
|
+
"Resampling",
|
|
255
|
+
"RemoveFlatChannels",
|
|
256
|
+
"RemoveDrifts",
|
|
257
|
+
"RemoveBadChannels",
|
|
258
|
+
"RemoveBadChannelsNoLocs",
|
|
259
|
+
"RemoveBursts",
|
|
260
|
+
"RemoveBadWindows",
|
|
261
|
+
"ReinterpolateRemovedChannels",
|
|
262
|
+
"RemoveCommonAverageReference",
|
|
34
263
|
"create_windows_from_events",
|
|
35
264
|
"create_fixed_length_windows",
|
|
36
265
|
"create_windows_from_target_channels",
|