Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bruAristimunha committed Nov 10, 2023
1 parent 389810a commit 2390df7
Show file tree
Hide file tree
Showing 160 changed files with 1,366 additions and 2,209 deletions.
2 changes: 1 addition & 1 deletion dev/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 9ec5c1237f59370fcf4be3165728dd0a
config: dfa3b204b4ec02ee979e4bf266ee2b9c
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
"outputs": [],
"source": [
"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)"
"from braindecode.preprocessing import preprocess, Preprocessor\nfrom numpy import multiply\n\nhigh_cut_hz = 30\nfactor = 1e6\n\npreprocessors = [\n Preprocessor(lambda data: multiply(data, factor), apply_on_array=True), # 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)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
factor = 1e6

preprocessors = [
Preprocessor(lambda data: multiply(data, factor)), # Convert from V to uV
Preprocessor(lambda data: multiply(data, factor), apply_on_array=True), # Convert from V to uV
Preprocessor('filter', l_freq=None, h_freq=high_cut_hz)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"outputs": [],
"source": [
"# Author: Lukas Gemein <[email protected]>\n#\n# License: BSD (3-clause)\n\nimport tempfile\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport mne\n\nfrom braindecode.datasets import TUH\nfrom braindecode.preprocessing import (\n preprocess, Preprocessor, create_fixed_length_windows, scale as multiply)\n\nmne.set_log_level('ERROR') # avoid messages every time a window is extracted"
"# Author: Lukas Gemein <[email protected]>\n#\n# License: BSD (3-clause)\n\nimport tempfile\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport mne\n\nfrom braindecode.datasets import TUH\nfrom braindecode.preprocessing import (\n preprocess, Preprocessor, create_fixed_length_windows)\nfrom numpy import multiply\n\nmne.set_log_level('ERROR') # avoid messages every time a window is extracted"
]
},
{
Expand Down Expand Up @@ -123,7 +123,7 @@
},
"outputs": [],
"source": [
"def custom_rename_channels(raw, mapping):\n # rename channels which are dependent on referencing:\n # le: EEG 01-LE, ar: EEG 01-REF\n # mne fails if the mapping contains channels as keys that are not present\n # in the raw\n reference = raw.ch_names[0].split('-')[-1].lower()\n assert reference in ['le', 'ref'], 'unexpected referencing'\n reference = 'le' if reference == 'le' else 'ar'\n raw.rename_channels(mapping[reference])\n\n\ndef custom_crop(raw, tmin=0.0, tmax=None, include_tmax=True):\n # crop recordings to tmin \u2013 tmax. can be incomplete if recording\n # has lower duration than tmax\n # by default mne fails if tmax is bigger than duration\n tmax = min((raw.n_times - 1) / raw.info['sfreq'], tmax)\n raw.crop(tmin=tmin, tmax=tmax, include_tmax=include_tmax)\n\n\ntmin = 1 * 60\ntmax = 6 * 60\nsfreq = 100\n\npreprocessors = [\n Preprocessor(custom_crop, tmin=tmin, tmax=tmax, include_tmax=False,\n apply_on_array=False),\n Preprocessor('set_eeg_reference', ref_channels='average', ch_type='eeg'),\n Preprocessor(custom_rename_channels, mapping=ch_mapping,\n apply_on_array=False),\n Preprocessor('pick_channels', ch_names=short_ch_names, ordered=True),\n Preprocessor(multiply, factor=1e6, apply_on_array=True),\n Preprocessor(np.clip, a_min=-800, a_max=800, apply_on_array=True),\n Preprocessor('resample', sfreq=sfreq),\n]"
"def custom_rename_channels(raw, mapping):\n # rename channels which are dependent on referencing:\n # le: EEG 01-LE, ar: EEG 01-REF\n # mne fails if the mapping contains channels as keys that are not present\n # in the raw\n reference = raw.ch_names[0].split('-')[-1].lower()\n assert reference in ['le', 'ref'], 'unexpected referencing'\n reference = 'le' if reference == 'le' else 'ar'\n raw.rename_channels(mapping[reference])\n\n\ndef custom_crop(raw, tmin=0.0, tmax=None, include_tmax=True):\n # crop recordings to tmin \u2013 tmax. can be incomplete if recording\n # has lower duration than tmax\n # by default mne fails if tmax is bigger than duration\n tmax = min((raw.n_times - 1) / raw.info['sfreq'], tmax)\n raw.crop(tmin=tmin, tmax=tmax, include_tmax=include_tmax)\n\n\ntmin = 1 * 60\ntmax = 6 * 60\nsfreq = 100\nfactor = 1e6\n\npreprocessors = [\n Preprocessor(custom_crop, tmin=tmin, tmax=tmax, include_tmax=False,\n apply_on_array=False),\n Preprocessor('set_eeg_reference', ref_channels='average', ch_type='eeg'),\n Preprocessor(custom_rename_channels, mapping=ch_mapping,\n apply_on_array=False),\n Preprocessor('pick_channels', ch_names=short_ch_names, ordered=True),\n Preprocessor(lambda data: multiply(data, factor), apply_on_array=True), # Convert from V to uV\n Preprocessor(np.clip, a_min=-800, a_max=800, apply_on_array=True),\n Preprocessor('resample', sfreq=sfreq),\n]"
]
},
{
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
"outputs": [],
"source": [
"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)"
"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), apply_on_array=True), # 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)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
# a lowpass filter. We omit the downsampling step of [1]_ as the Sleep
# Physionet data is already sampled at a lower 100 Hz.

from braindecode.preprocessing import preprocess, Preprocessor, scale
from braindecode.preprocessing import preprocess, Preprocessor
from numpy import multiply

high_cut_hz = 30
factor = 1e6

preprocessors = [
Preprocessor(scale, factor=1e6, apply_on_array=True),
Preprocessor(lambda data: multiply(data, factor), apply_on_array=True), # Convert from V to uV
Preprocessor('filter', l_freq=None, h_freq=high_cut_hz)
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

from braindecode.datasets import TUH
from braindecode.preprocessing import (
preprocess, Preprocessor, create_fixed_length_windows, scale as multiply)
preprocess, Preprocessor, create_fixed_length_windows)
from numpy import multiply

mne.set_log_level('ERROR') # avoid messages every time a window is extracted

Expand Down Expand Up @@ -243,6 +244,7 @@ def custom_crop(raw, tmin=0.0, tmax=None, include_tmax=True):
tmin = 1 * 60
tmax = 6 * 60
sfreq = 100
factor = 1e6

preprocessors = [
Preprocessor(custom_crop, tmin=tmin, tmax=tmax, include_tmax=False,
Expand All @@ -251,7 +253,7 @@ def custom_crop(raw, tmin=0.0, tmax=None, include_tmax=True):
Preprocessor(custom_rename_channels, mapping=ch_mapping,
apply_on_array=False),
Preprocessor('pick_channels', ch_names=short_ch_names, ordered=True),
Preprocessor(multiply, factor=1e6, apply_on_array=True),
Preprocessor(lambda data: multiply(data, factor), apply_on_array=True), # Convert from V to uV
Preprocessor(np.clip, a_min=-800, a_max=800, apply_on_array=True),
Preprocessor('resample', sfreq=sfreq),
]
Expand Down
Binary file modified dev/_images/sphx_glr_plot_benchmark_preprocessing_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dev/_images/sphx_glr_plot_benchmark_preprocessing_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dev/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const DOCUMENTATION_OPTIONS = {
VERSION: '0.7',
VERSION: '0.8',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
11 changes: 8 additions & 3 deletions dev/_static/versions.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
[
{
"name": "0.8 (devel)",
"name": "0.9 (devel)",
"version": "dev",
"url": "https://braindecode.org/dev/"
},
{
"name": "0.7 (stable)",
"version": "stable",
"name": "0.8 (stable)",
"version": "dev",
"url": "https://braindecode.org/stable/"
},
{
"name": "0.7",
"version": "0.7",
"url": "https://braindecode.org/0.7/"
},
{
"name": "0.6",
"version": "0.6",
Expand Down
28 changes: 12 additions & 16 deletions dev/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<title>API Reference &#8212; Braindecode 0.7 documentation</title>
<title>API Reference &#8212; Braindecode 0.8 documentation</title>



Expand Down Expand Up @@ -41,7 +41,7 @@
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=365ca57ee442770a23c6" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=365ca57ee442770a23c6"></script>

<script src="_static/documentation_options.js?v=df5ae754"></script>
<script src="_static/documentation_options.js?v=aad85e6b"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/design-tabs.js?v=36754332"></script>
Expand All @@ -62,7 +62,7 @@
<script>
DOCUMENTATION_OPTIONS.theme_version = '0.14.3';
DOCUMENTATION_OPTIONS.theme_switcher_json_url = 'https://braindecode.org/stable/_static/versions.json';
DOCUMENTATION_OPTIONS.theme_switcher_version_match = '0.7';
DOCUMENTATION_OPTIONS.theme_switcher_version_match = '0.8';
DOCUMENTATION_OPTIONS.show_version_warning_banner = false;
</script>
<link rel="index" title="Index" href="genindex.html" />
Expand Down Expand Up @@ -469,7 +469,6 @@
<li class="toctree-l1"><a class="reference internal" href="generated/braindecode.preprocessing.create_windows_from_target_channels.html">braindecode.preprocessing.create_windows_from_target_channels</a></li>
<li class="toctree-l1"><a class="reference internal" href="generated/braindecode.preprocessing.exponential_moving_demean.html">braindecode.preprocessing.exponential_moving_demean</a></li>
<li class="toctree-l1"><a class="reference internal" href="generated/braindecode.preprocessing.exponential_moving_standardize.html">braindecode.preprocessing.exponential_moving_standardize</a></li>
<li class="toctree-l1"><a class="reference internal" href="generated/braindecode.preprocessing.scale.html">braindecode.preprocessing.scale</a></li>
<li class="toctree-l1"><a class="reference internal" href="generated/braindecode.preprocessing.filterbank.html">braindecode.preprocessing.filterbank</a></li>
<li class="toctree-l1"><a class="reference internal" href="generated/braindecode.preprocessing.preprocess.html">braindecode.preprocessing.preprocess</a></li>
<li class="toctree-l1"><a class="reference internal" href="generated/braindecode.preprocessing.Preprocessor.html">braindecode.preprocessing.Preprocessor</a></li>
Expand Down Expand Up @@ -801,34 +800,31 @@ <h2><a class="toc-backref" href="#id13" role="doc-backlink">Preprocessing</a><a
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.exponential_moving_standardize.html#braindecode.preprocessing.exponential_moving_standardize" title="braindecode.preprocessing.exponential_moving_standardize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">exponential_moving_standardize</span></code></a>(data[, ...])</p></td>
<td><p>Perform exponential moving standardization.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.scale.html#braindecode.preprocessing.scale" title="braindecode.preprocessing.scale"><code class="xref py py-obj docutils literal notranslate"><span class="pre">scale</span></code></a>(data, factor)</p></td>
<td><p>Scale continuous or windowed data in-place</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.filterbank.html#braindecode.preprocessing.filterbank" title="braindecode.preprocessing.filterbank"><code class="xref py py-obj docutils literal notranslate"><span class="pre">filterbank</span></code></a>(raw, frequency_bands[, ...])</p></td>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.filterbank.html#braindecode.preprocessing.filterbank" title="braindecode.preprocessing.filterbank"><code class="xref py py-obj docutils literal notranslate"><span class="pre">filterbank</span></code></a>(raw, frequency_bands[, ...])</p></td>
<td><p>Applies multiple bandpass filters to the signals in raw.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.preprocess.html#braindecode.preprocessing.preprocess" title="braindecode.preprocessing.preprocess"><code class="xref py py-obj docutils literal notranslate"><span class="pre">preprocess</span></code></a>(concat_ds, preprocessors[, ...])</p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.preprocess.html#braindecode.preprocessing.preprocess" title="braindecode.preprocessing.preprocess"><code class="xref py py-obj docutils literal notranslate"><span class="pre">preprocess</span></code></a>(concat_ds, preprocessors[, ...])</p></td>
<td><p>Apply preprocessors to a concat dataset.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Preprocessor.html#braindecode.preprocessing.Preprocessor" title="braindecode.preprocessing.Preprocessor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Preprocessor</span></code></a>(fn, *[, apply_on_array])</p></td>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Preprocessor.html#braindecode.preprocessing.Preprocessor" title="braindecode.preprocessing.Preprocessor"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Preprocessor</span></code></a>(fn, *[, apply_on_array])</p></td>
<td><p>Preprocessor for an MNE Raw or Epochs object.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Resample.html#braindecode.preprocessing.Resample" title="braindecode.preprocessing.Resample"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Resample</span></code></a>([up, down, npad, axis, window, ...])</p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Resample.html#braindecode.preprocessing.Resample" title="braindecode.preprocessing.Resample"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Resample</span></code></a>([up, down, npad, axis, window, ...])</p></td>
<td><p>Resample an array.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.DropChannels.html#braindecode.preprocessing.DropChannels" title="braindecode.preprocessing.DropChannels"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DropChannels</span></code></a>(ch_names[, on_missing])</p></td>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.DropChannels.html#braindecode.preprocessing.DropChannels" title="braindecode.preprocessing.DropChannels"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DropChannels</span></code></a>(ch_names[, on_missing])</p></td>
<td><p>Drop channel(s).</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.SetEEGReference.html#braindecode.preprocessing.SetEEGReference" title="braindecode.preprocessing.SetEEGReference"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SetEEGReference</span></code></a>([ref_channels, projection, ...])</p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.SetEEGReference.html#braindecode.preprocessing.SetEEGReference" title="braindecode.preprocessing.SetEEGReference"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SetEEGReference</span></code></a>([ref_channels, projection, ...])</p></td>
<td><p>Specify which reference to use for EEG data.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Filter.html#braindecode.preprocessing.Filter" title="braindecode.preprocessing.Filter"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Filter</span></code></a>(l_freq, h_freq[, picks, ...])</p></td>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Filter.html#braindecode.preprocessing.Filter" title="braindecode.preprocessing.Filter"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Filter</span></code></a>(l_freq, h_freq[, picks, ...])</p></td>
<td><p>Filter a subset of channels.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Pick.html#braindecode.preprocessing.Pick" title="braindecode.preprocessing.Pick"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Pick</span></code></a>(picks[, exclude, verbose])</p></td>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Pick.html#braindecode.preprocessing.Pick" title="braindecode.preprocessing.Pick"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Pick</span></code></a>(picks[, exclude, verbose])</p></td>
<td><p>Pick a subset of channels.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Crop.html#braindecode.preprocessing.Crop" title="braindecode.preprocessing.Crop"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Crop</span></code></a>([tmin, tmax, include_tmax, verbose])</p></td>
<tr class="row-even"><td><p><a class="reference internal" href="generated/braindecode.preprocessing.Crop.html#braindecode.preprocessing.Crop" title="braindecode.preprocessing.Crop"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Crop</span></code></a>([tmin, tmax, include_tmax, verbose])</p></td>
<td><p>Crop raw data file.</p></td>
</tr>
</tbody>
Expand Down
Loading

0 comments on commit 2390df7

Please sign in to comment.