Skip to content

Commit 534c9a9

Browse files
1 parent bfbefc3 commit 534c9a9

File tree

52 files changed

+523
-477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+523
-477
lines changed
Binary file not shown.

master/_downloads/1224801107d6c3b138edf8ee33de0561/plot_bcic_iv_2a_moabb_cropped.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
},
4545
"outputs": [],
4646
"source": [
47-
"# .. note::\n#\n# For cropped decoding, the above training setup is mathematically\n# identical to sampling crops in your dataset, pushing them through the\n# network and training directly on the individual crops. At the same time,\n# the above training setup is much faster as it avoids redundant\n# computations by using dilated convolutions, see our paper\n# `Deep learning with convolutional neural networks for EEG decoding and visualization <https://arxiv.org/abs/1703.05051>`_. # noqa: E501\n# However, the two setups are only mathematically identical in case (1)\n# your network does not use any padding or only left padding and\n# (2) your loss function leads\n# to the same gradients when using the averaged output. The first is true\n# for our shallow and deep ConvNet models and the second is true for the\n# log-softmax outputs and negative log likelihood loss that is typically\n# used for classification in PyTorch.\n#\n\n# Loading and preprocessing the dataset\n# -------------------------------------\n#\n# Loading and preprocessing stays the same as in the `Trialwise decoding\n# tutorial <./plot_bcic_iv_2a_moabb_trial.html>`__.\n\nfrom braindecode.datasets import MOABBDataset\n\nsubject_id = 3\ndataset = MOABBDataset(dataset_name=\"BNCI2014001\", subject_ids=[subject_id])\n\nfrom braindecode.preprocessing import (\n exponential_moving_standardize, preprocess, Preprocessor, scale)\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
47+
"# .. note::\n#\n# For cropped decoding, the above training setup is mathematically\n# identical to sampling crops in your dataset, pushing them through the\n# network and training directly on the individual crops. At the same time,\n# the above training setup is much faster as it avoids redundant\n# computations by using dilated convolutions, see our paper\n# `Deep learning with convolutional neural networks for EEG decoding and visualization <https://arxiv.org/abs/1703.05051>`_. # noqa: E501\n# However, the two setups are only mathematically identical in case (1)\n# your network does not use any padding or only left padding and\n# (2) your loss function leads\n# to the same gradients when using the averaged output. The first is true\n# for our shallow and deep ConvNet models and the second is true for the\n# log-softmax outputs and negative log likelihood loss that is typically\n# used for classification in PyTorch.\n#\n\n# Loading and preprocessing the dataset\n# -------------------------------------\n#\n# Loading and preprocessing stays the same as in the `Trialwise decoding\n# tutorial <./plot_bcic_iv_2a_moabb_trial.html>`__.\n\nfrom braindecode.datasets import MOABBDataset\n\nsubject_id = 3\ndataset = MOABBDataset(dataset_name=\"BNCI2014001\", subject_ids=[subject_id])\n\nfrom braindecode.preprocessing import (\n exponential_moving_standardize, preprocess, Preprocessor)\nfrom numpy import multiply\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n# Factor to convert from V to uV\nfactor = 1e6\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
4848
]
4949
},
5050
{

master/_downloads/35f097f0d5a2df80f3fc3d21411435e1/plot_data_augmentation.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,20 @@
3939
#
4040

4141
from braindecode.preprocessing import (
42-
exponential_moving_standardize, preprocess, Preprocessor, scale)
42+
exponential_moving_standardize, preprocess, Preprocessor)
43+
from numpy import multiply
4344

4445
low_cut_hz = 4. # low cut frequency for filtering
4546
high_cut_hz = 38. # high cut frequency for filtering
4647
# Parameters for exponential moving standardization
4748
factor_new = 1e-3
4849
init_block_size = 1000
50+
# Factor to convert from V to uV
51+
factor = 1e6
4952

5053
preprocessors = [
5154
Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors
52-
Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV
55+
Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV
5356
Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter
5457
Preprocessor(exponential_moving_standardize, # Exponential moving standardization
5558
factor_new=factor_new, init_block_size=init_block_size)

master/_downloads/3e0455c88adcaa2571230abb981020db/plot_relative_positioning.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
"outputs": [],
6464
"source": [
65-
"from braindecode.preprocessing.preprocess import preprocess, Preprocessor, scale\n\nhigh_cut_hz = 30\n\npreprocessors = [\n Preprocessor(scale, factor=1e6, apply_on_array=True),\n Preprocessor('filter', l_freq=None, h_freq=high_cut_hz, n_jobs=n_jobs)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
65+
"from braindecode.preprocessing.preprocess import preprocess, Preprocessor\nfrom numpy import multiply\n\nhigh_cut_hz = 30\n# Factor to convert from V to uV\nfactor = 1e6\n\npreprocessors = [\n Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV\n Preprocessor('filter', l_freq=None, h_freq=high_cut_hz, n_jobs=n_jobs)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
6666
]
6767
},
6868
{

master/_downloads/475edf2d5ed60b15717de3100f3551a5/plot_bcic_iv_2a_moabb_trial.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,20 @@
6161
#
6262

6363
from braindecode.preprocessing import (
64-
exponential_moving_standardize, preprocess, Preprocessor, scale)
64+
exponential_moving_standardize, preprocess, Preprocessor)
65+
from numpy import multiply
6566

6667
low_cut_hz = 4. # low cut frequency for filtering
6768
high_cut_hz = 38. # high cut frequency for filtering
6869
# Parameters for exponential moving standardization
6970
factor_new = 1e-3
7071
init_block_size = 1000
72+
# Factor to convert from V to uV
73+
factor = 1e6
7174

7275
preprocessors = [
7376
Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors
74-
Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV
77+
Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV
7578
Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter
7679
Preprocessor(exponential_moving_standardize, # Exponential moving standardization
7780
factor_new=factor_new, init_block_size=init_block_size)
Binary file not shown.

master/_downloads/7132d1f42727a7844635064390fdd264/plot_sleep_staging_eldele2021.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
"outputs": [],
6464
"source": [
65-
"from braindecode.preprocessing import preprocess, Preprocessor, scale\n\nhigh_cut_hz = 30\n\npreprocessors = [\n Preprocessor(scale, factor=1e6, apply_on_array=True),\n Preprocessor('filter', l_freq=None, h_freq=high_cut_hz)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
65+
"from braindecode.preprocessing import preprocess, Preprocessor\nfrom numpy import multiply\n\nhigh_cut_hz = 30\n# Factor to convert from V to uV\nfactor = 1e6\n\npreprocessors = [\n Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV\n Preprocessor('filter', l_freq=None, h_freq=high_cut_hz)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
6666
]
6767
},
6868
{

master/_downloads/748680401b0360239d00624375dd9587/plot_bcic_iv_2a_moabb_trial.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
},
7373
"outputs": [],
7474
"source": [
75-
"from braindecode.preprocessing import (\n exponential_moving_standardize, preprocess, Preprocessor, scale)\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
75+
"from braindecode.preprocessing import (\n exponential_moving_standardize, preprocess, Preprocessor)\nfrom numpy import multiply\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n# Factor to convert from V to uV\nfactor = 1e6\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
7676
]
7777
},
7878
{

master/_downloads/763a361b3d3c09298e3afb84a82726b5/plot_sleep_staging_eldele2021.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,15 @@
6565
# Next, we preprocess the raw data. We convert the data to microvolts and apply
6666
# a lowpass filter.
6767

68-
from braindecode.preprocessing import preprocess, Preprocessor, scale
68+
from braindecode.preprocessing import preprocess, Preprocessor
69+
from numpy import multiply
6970

7071
high_cut_hz = 30
72+
# Factor to convert from V to uV
73+
factor = 1e6
7174

7275
preprocessors = [
73-
Preprocessor(scale, factor=1e6, apply_on_array=True),
76+
Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV
7477
Preprocessor('filter', l_freq=None, h_freq=high_cut_hz)
7578
]
7679

master/_downloads/8907c83db580c626a4858d4f3c3d5c35/plot_data_augmentation.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
"outputs": [],
6464
"source": [
65-
"from braindecode.preprocessing import (\n exponential_moving_standardize, preprocess, Preprocessor, scale)\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\npreprocess(dataset, preprocessors)"
65+
"from braindecode.preprocessing import (\n exponential_moving_standardize, preprocess, Preprocessor)\nfrom numpy import multiply\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n# Factor to convert from V to uV\nfactor = 1e6\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\npreprocess(dataset, preprocessors)"
6666
]
6767
},
6868
{

master/_downloads/995f58ef1b3d29dce64caee24e5bf457/plot_bcic_iv_2a_moabb_cropped.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,20 @@
8282
dataset = MOABBDataset(dataset_name="BNCI2014001", subject_ids=[subject_id])
8383

8484
from braindecode.preprocessing import (
85-
exponential_moving_standardize, preprocess, Preprocessor, scale)
85+
exponential_moving_standardize, preprocess, Preprocessor)
86+
from numpy import multiply
8687

8788
low_cut_hz = 4. # low cut frequency for filtering
8889
high_cut_hz = 38. # high cut frequency for filtering
8990
# Parameters for exponential moving standardization
9091
factor_new = 1e-3
9192
init_block_size = 1000
93+
# Factor to convert from V to uV
94+
factor = 1e6
9295

9396
preprocessors = [
9497
Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors
95-
Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV
98+
Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV
9699
Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter
97100
Preprocessor(exponential_moving_standardize, # Exponential moving standardization
98101
factor_new=factor_new, init_block_size=init_block_size)

master/_downloads/9f3a9058fba292cd75e5ce23b492bc0c/plot_data_augmentation_search.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,20 @@
6767
#
6868

6969
from braindecode.preprocessing import (
70-
exponential_moving_standardize, preprocess, Preprocessor, scale)
70+
exponential_moving_standardize, preprocess, Preprocessor)
71+
from numpy import multiply
7172

7273
low_cut_hz = 4. # low cut frequency for filtering
7374
high_cut_hz = 38. # high cut frequency for filtering
7475
# Parameters for exponential moving standardization
7576
factor_new = 1e-3
7677
init_block_size = 1000
78+
# Factor to convert from V to uV
79+
factor = 1e6
7780

7881
preprocessors = [
7982
Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors
80-
Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV
83+
Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV
8184
Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter
8285
Preprocessor(exponential_moving_standardize, # Exponential moving standardization
8386
factor_new=factor_new, init_block_size=init_block_size)

master/_downloads/a7671a37e509d66f8a25812de650cb55/plot_hyperparameter_tuning_with_scikit-learn.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,20 @@
6161
#
6262

6363
from braindecode.preprocessing.preprocess import (
64-
exponential_moving_standardize, preprocess, Preprocessor, scale)
64+
exponential_moving_standardize, preprocess, Preprocessor)
65+
from numpy import multiply
6566

6667
low_cut_hz = 4. # low cut frequency for filtering
6768
high_cut_hz = 38. # high cut frequency for filtering
6869
# Parameters for exponential moving standardization
6970
factor_new = 1e-3
7071
init_block_size = 1000
72+
# Factor to convert from V to uV
73+
factor = 1e6
7174

7275
preprocessors = [
7376
Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors
74-
Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV
77+
Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV
7578
Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter
7679
Preprocessor(exponential_moving_standardize, # Exponential moving standardization
7780
factor_new=factor_new, init_block_size=init_block_size)

master/_downloads/a90627a2f09081df5abbe979f9fa0217/plot_data_augmentation_search.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
},
6363
"outputs": [],
6464
"source": [
65-
"from braindecode.preprocessing import (\n exponential_moving_standardize, preprocess, Preprocessor, scale)\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\npreprocess(dataset, preprocessors)"
65+
"from braindecode.preprocessing import (\n exponential_moving_standardize, preprocess, Preprocessor)\nfrom numpy import multiply\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n# Factor to convert from V to uV\nfactor = 1e6\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\npreprocess(dataset, preprocessors)"
6666
]
6767
},
6868
{

master/_downloads/d64670f59a0ee7e125ae228f318fb330/plot_hyperparameter_tuning_with_scikit-learn.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
},
7373
"outputs": [],
7474
"source": [
75-
"from braindecode.preprocessing.preprocess import (\n exponential_moving_standardize, preprocess, Preprocessor, scale)\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(scale, factor=1e6, apply_on_array=True), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
75+
"from braindecode.preprocessing.preprocess import (\n exponential_moving_standardize, preprocess, Preprocessor)\nfrom numpy import multiply\n\nlow_cut_hz = 4. # low cut frequency for filtering\nhigh_cut_hz = 38. # high cut frequency for filtering\n# Parameters for exponential moving standardization\nfactor_new = 1e-3\ninit_block_size = 1000\n# Factor to convert from V to uV\nfactor = 1e6\n\npreprocessors = [\n Preprocessor('pick_types', eeg=True, meg=False, stim=False), # Keep EEG sensors\n Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV\n Preprocessor('filter', l_freq=low_cut_hz, h_freq=high_cut_hz), # Bandpass filter\n Preprocessor(exponential_moving_standardize, # Exponential moving standardization\n factor_new=factor_new, init_block_size=init_block_size)\n]\n\n# Transform the data\npreprocess(dataset, preprocessors)"
7676
]
7777
},
7878
{

master/_downloads/e21937efe066fc624a4b536dced68cd1/plot_relative_positioning.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,15 @@
6868
# a lowpass filter. Since the Sleep Physionet data is already sampled at 100 Hz
6969
# we don't need to apply resampling.
7070

71-
from braindecode.preprocessing.preprocess import preprocess, Preprocessor, scale
71+
from braindecode.preprocessing.preprocess import preprocess, Preprocessor
72+
from numpy import multiply
7273

7374
high_cut_hz = 30
75+
# Factor to convert from V to uV
76+
factor = 1e6
7477

7578
preprocessors = [
76-
Preprocessor(scale, factor=1e6, apply_on_array=True),
79+
Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV
7780
Preprocessor('filter', l_freq=None, h_freq=high_cut_hz, n_jobs=n_jobs)
7881
]
7982

Loading
Loading

0 commit comments

Comments
 (0)