.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_mne_dataset_example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here <sphx_glr_download_auto_examples_plot_mne_dataset_example.py>` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_mne_dataset_example.py: MNE Dataset Example =================== .. GENERATED FROM PYTHON SOURCE LINES 6-8 This example shows how to convert data from mne.Raws or mne.Epochs to a braindecode compatible data format. .. GENERATED FROM PYTHON SOURCE LINES 8-18 .. code-block:: default # Authors: Lukas Gemein <l.gemein@gmail.com> # # License: BSD (3-clause) import mne from braindecode.datasets import ( create_from_mne_raw, create_from_mne_epochs) .. GENERATED FROM PYTHON SOURCE LINES 19-20 First, fetch some data using mne: .. GENERATED FROM PYTHON SOURCE LINES 20-35 .. code-block:: default # 5, 6, 7, 10, 13, 14 are codes for executed and imagined hands/feet subject_id = 22 event_codes = [5, 6, 9, 10, 13, 14] # event_codes = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] # This will download the files if you don't have them yet, # and then return the paths to the files. physionet_paths = mne.datasets.eegbci.load_data( subject_id, event_codes, update_path=False) # Load each of the files parts = [mne.io.read_raw_edf(path, preload=True, stim_channel='auto') for path in physionet_paths] .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Extracting EDF parameters from /home/runner/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S022/S022R05.edf... EDF file detected Setting channel info structure... Creating raw.info structure... Reading 0 ... 19999 = 0.000 ... 124.994 secs... Extracting EDF parameters from /home/runner/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S022/S022R06.edf... EDF file detected Setting channel info structure... Creating raw.info structure... Reading 0 ... 19999 = 0.000 ... 124.994 secs... Extracting EDF parameters from /home/runner/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S022/S022R09.edf... EDF file detected Setting channel info structure... Creating raw.info structure... Reading 0 ... 19999 = 0.000 ... 124.994 secs... Extracting EDF parameters from /home/runner/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S022/S022R10.edf... EDF file detected Setting channel info structure... Creating raw.info structure... Reading 0 ... 19999 = 0.000 ... 124.994 secs... Extracting EDF parameters from /home/runner/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S022/S022R13.edf... EDF file detected Setting channel info structure... Creating raw.info structure... Reading 0 ... 19999 = 0.000 ... 124.994 secs... Extracting EDF parameters from /home/runner/mne_data/MNE-eegbci-data/files/eegmmidb/1.0.0/S022/S022R14.edf... EDF file detected Setting channel info structure... Creating raw.info structure... Reading 0 ... 19999 = 0.000 ... 124.994 secs... .. GENERATED FROM PYTHON SOURCE LINES 36-37 Convert Raw objects to a compatible data format: .. GENERATED FROM PYTHON SOURCE LINES 37-49 .. code-block:: default descriptions = [{"event_code": code, "subject": subject_id} for code in event_codes] windows_dataset = create_from_mne_raw( parts, trial_start_offset_samples=0, trial_stop_offset_samples=0, window_size_samples=500, window_stride_samples=500, drop_last_window=False, descriptions=descriptions, ) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Used Annotations descriptions: ['T0', 'T1', 'T2'] Adding metadata with 4 columns Replacing existing metadata with 4 columns 60 matching events found No baseline correction applied 0 projection items activated Loading data for 60 events and 500 original time points ... 0 bad epochs dropped Used Annotations descriptions: ['T0', 'T1', 'T2'] Adding metadata with 4 columns Replacing existing metadata with 4 columns 60 matching events found No baseline correction applied 0 projection items activated Loading data for 60 events and 500 original time points ... 0 bad epochs dropped Used Annotations descriptions: ['T0', 'T1', 'T2'] Adding metadata with 4 columns Replacing existing metadata with 4 columns 60 matching events found No baseline correction applied 0 projection items activated Loading data for 60 events and 500 original time points ... 0 bad epochs dropped Used Annotations descriptions: ['T0', 'T1', 'T2'] Adding metadata with 4 columns Replacing existing metadata with 4 columns 60 matching events found No baseline correction applied 0 projection items activated Loading data for 60 events and 500 original time points ... 0 bad epochs dropped Used Annotations descriptions: ['T0', 'T1', 'T2'] Adding metadata with 4 columns Replacing existing metadata with 4 columns 60 matching events found No baseline correction applied 0 projection items activated Loading data for 60 events and 500 original time points ... 0 bad epochs dropped Used Annotations descriptions: ['T0', 'T1', 'T2'] Adding metadata with 4 columns Replacing existing metadata with 4 columns 60 matching events found No baseline correction applied 0 projection items activated Loading data for 60 events and 500 original time points ... 0 bad epochs dropped .. GENERATED FROM PYTHON SOURCE LINES 50-51 If trials were already cut beforehand and are available as mne.Epochs: .. GENERATED FROM PYTHON SOURCE LINES 51-61 .. code-block:: default list_of_epochs = [mne.Epochs(raw, [[0, 0, 0]], tmin=0, baseline=None) for raw in parts] windows_dataset = create_from_mne_epochs( list_of_epochs, window_size_samples=50, window_stride_samples=50, drop_last_window=False ) windows_dataset.description .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Not setting metadata Not setting metadata 1 matching events found No baseline correction applied 0 projection items activated Not setting metadata Not setting metadata 1 matching events found No baseline correction applied 0 projection items activated Not setting metadata Not setting metadata 1 matching events found No baseline correction applied 0 projection items activated Not setting metadata Not setting metadata 1 matching events found No baseline correction applied 0 projection items activated Not setting metadata Not setting metadata 1 matching events found No baseline correction applied 0 projection items activated Not setting metadata Not setting metadata 1 matching events found No baseline correction applied 0 projection items activated Creating RawArray with float64 data, n_channels=64, n_times=81 Range : 0 ... 80 = 0.000 ... 0.500 secs Ready. Adding metadata with 4 columns Replacing existing metadata with 4 columns 2 matching events found No baseline correction applied 0 projection items activated Loading data for 2 events and 50 original time points ... 0 bad epochs dropped Creating RawArray with float64 data, n_channels=64, n_times=81 Range : 0 ... 80 = 0.000 ... 0.500 secs Ready. Adding metadata with 4 columns Replacing existing metadata with 4 columns 2 matching events found No baseline correction applied 0 projection items activated Loading data for 2 events and 50 original time points ... 0 bad epochs dropped Creating RawArray with float64 data, n_channels=64, n_times=81 Range : 0 ... 80 = 0.000 ... 0.500 secs Ready. Adding metadata with 4 columns Replacing existing metadata with 4 columns 2 matching events found No baseline correction applied 0 projection items activated Loading data for 2 events and 50 original time points ... 0 bad epochs dropped Creating RawArray with float64 data, n_channels=64, n_times=81 Range : 0 ... 80 = 0.000 ... 0.500 secs Ready. Adding metadata with 4 columns Replacing existing metadata with 4 columns 2 matching events found No baseline correction applied 0 projection items activated Loading data for 2 events and 50 original time points ... 0 bad epochs dropped Creating RawArray with float64 data, n_channels=64, n_times=81 Range : 0 ... 80 = 0.000 ... 0.500 secs Ready. Adding metadata with 4 columns Replacing existing metadata with 4 columns 2 matching events found No baseline correction applied 0 projection items activated Loading data for 2 events and 50 original time points ... 0 bad epochs dropped Creating RawArray with float64 data, n_channels=64, n_times=81 Range : 0 ... 80 = 0.000 ... 0.500 secs Ready. Adding metadata with 4 columns Replacing existing metadata with 4 columns 2 matching events found No baseline correction applied 0 projection items activated Loading data for 2 events and 50 original time points ... 0 bad epochs dropped .. raw:: html <div class="output_subarea output_html rendered_html output_result"> <div> <style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; } </style> <table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th>0</th> </tr> </thead> <tbody> <tr> <th>0</th> <td>None</td> </tr> <tr> <th>1</th> <td>None</td> </tr> <tr> <th>2</th> <td>None</td> </tr> <tr> <th>3</th> <td>None</td> </tr> <tr> <th>4</th> <td>None</td> </tr> <tr> <th>5</th> <td>None</td> </tr> </tbody> </table> </div> </div> <br /> <br /> .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.827 seconds) **Estimated memory usage:** 77 MB .. _sphx_glr_download_auto_examples_plot_mne_dataset_example.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_mne_dataset_example.py <plot_mne_dataset_example.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_mne_dataset_example.ipynb <plot_mne_dataset_example.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_