.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_gallery/mkh5eeglab/eeglab_quickstart.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_gallery_mkh5eeglab_eeglab_quickstart.py: .. _eeglab_quickstart: Quickstart: mkh5 to EEGLAB ########################## .. GENERATED FROM PYTHON SOURCE LINES 10-30 Converting mkh5 to EEGLAB .set requires MNE Python under the hood. An apparatus map with standard mkh5 Right Anterior Superior (RAS) electrode locations is required and rotated automatically to the EEGLAB default coordinates. This can be included in the .yhdr YAML file when creating the mkh5 file or added later when converting to EEGLAB as shown here. The apparatus map format is the same. .. note:: The first time you load the .set file into EEGLAB clean up the EEGLAB events and center the channel locations with spherical coordinates. In MATLAB .. code-block:: >> eeglab >> EEG = pop_loadset('filename','sub00.set') >> EEG = eeg_checkset(EEG, 'eventconsistency') >> pop_chanedit(EEG) .. GENERATED FROM PYTHON SOURCE LINES 33-34 FYI ... environment and versions. .. GENERATED FROM PYTHON SOURCE LINES 34-44 .. code-block:: default import os import mne import mkpy from mkpy.io import mkh5eeglab, mkh5mne print("conda env", os.environ["CONDA_DEFAULT_ENV"]) for pkg in [mkpy, mne]: print(pkg.__name__, pkg.__version__) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none conda env env_3.8 mkpy 0.2.7 mne 1.0.3 .. GENERATED FROM PYTHON SOURCE LINES 45-57 :py:func:`.mkh5eeglab.mkh5_to_set` ================================== Convert an mkh5 **file** into an EEGLAB format .set file * Adding `epochs_name` is optional, it adds the event tags from the named epochs table to EEG.events and EEG.urevents. * Adding `garv_annotations` is optional but adds "boundary" events to EEG.events and EEG.urevents The sample data is a single subject mkh5 data file for an auditory oddball paradigm. .. GENERATED FROM PYTHON SOURCE LINES 60-62 Minimal export: EEG data, datablock labels and boundaries, and log event codes. The mkh5 file has electrode locations baked in via the YAML .yhdr .. GENERATED FROM PYTHON SOURCE LINES 63-65 .. code-block:: default mkh5eeglab.mkh5_to_set("../mkh5_data/sub000p3.h5", "sub000p3.set") .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ../mkh5_data/sub000p3.h5 looking up data block paths, larger files take longer ... ok checking info, montage sub000/dblock_1 checking info, montage sub000/dblock_2 checking info, montage sub000/dblock_3 checking info, montage sub000/dblock_4 Creating RawArray with float64 data, n_channels=39, n_times=31232 Range : 0 ... 31231 = 0.000 ... 124.924 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting positions of 5 eog channels found in montage: ['lle', 'lhz', 'HEOG', 'rle', 'rhz'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_0 setting mkh5 epochs table ms100 events and metadata sub000/dblock_0 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_0 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_0 setting mkh5 epochs table ms3000 events and metadata Creating RawArray with float64 data, n_channels=39, n_times=32768 Range : 0 ... 32767 = 0.000 ... 131.068 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting positions of 5 eog channels found in montage: ['lle', 'lhz', 'HEOG', 'rle', 'rhz'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_1 setting mkh5 epochs table ms100 events and metadata sub000/dblock_1 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_1 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_1 setting mkh5 epochs table ms3000 events and metadata Creating RawArray with float64 data, n_channels=39, n_times=31744 Range : 0 ... 31743 = 0.000 ... 126.972 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting positions of 5 eog channels found in montage: ['lle', 'lhz', 'HEOG', 'rle', 'rhz'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_2 setting mkh5 epochs table ms100 events and metadata sub000/dblock_2 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_2 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_2 setting mkh5 epochs table ms3000 events and metadata Creating RawArray with float64 data, n_channels=39, n_times=32512 Range : 0 ... 32511 = 0.000 ... 130.044 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting positions of 5 eog channels found in montage: ['lle', 'lhz', 'HEOG', 'rle', 'rhz'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_3 setting mkh5 epochs table ms100 events and metadata sub000/dblock_3 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_3 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_3 setting mkh5 epochs table ms3000 events and metadata Creating RawArray with float64 data, n_channels=39, n_times=28416 Range : 0 ... 28415 = 0.000 ... 113.660 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting positions of 5 eog channels found in montage: ['lle', 'lhz', 'HEOG', 'rle', 'rhz'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_4 setting mkh5 epochs table ms100 events and metadata sub000/dblock_4 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_4 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_4 setting mkh5 epochs table ms3000 events and metadata EEG data marked as already having the desired reference. .. GENERATED FROM PYTHON SOURCE LINES 66-67 Export with alternate electrode locations .. GENERATED FROM PYTHON SOURCE LINES 68-74 .. code-block:: default mkh5eeglab.mkh5_to_set( "../mkh5_data/sub000p3.h5", "sub000p3.set", apparatus_yaml="ras_32chan_xyz_spherical.yml", ) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ../mkh5_data/sub000p3.h5 looking up data block paths, larger files take longer ... ok /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_0 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) checking info, montage sub000/dblock_1 /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_1 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) checking info, montage sub000/dblock_2 /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_2 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) checking info, montage sub000/dblock_3 /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_3 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) checking info, montage sub000/dblock_4 /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_4 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_0 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=31232 Range : 0 ... 31231 = 0.000 ... 124.924 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_0 setting mkh5 epochs table ms100 events and metadata sub000/dblock_0 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_0 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_0 setting mkh5 epochs table ms3000 events and metadata /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_1 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=32768 Range : 0 ... 32767 = 0.000 ... 131.068 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_1 setting mkh5 epochs table ms100 events and metadata sub000/dblock_1 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_1 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_1 setting mkh5 epochs table ms3000 events and metadata /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_2 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=31744 Range : 0 ... 31743 = 0.000 ... 126.972 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_2 setting mkh5 epochs table ms100 events and metadata sub000/dblock_2 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_2 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_2 setting mkh5 epochs table ms3000 events and metadata /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_3 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=32512 Range : 0 ... 32511 = 0.000 ... 130.044 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_3 setting mkh5 epochs table ms100 events and metadata sub000/dblock_3 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_3 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_3 setting mkh5 epochs table ms3000 events and metadata /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_4 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=28416 Range : 0 ... 28415 = 0.000 ... 113.660 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_4 setting mkh5 epochs table ms100 events and metadata sub000/dblock_4 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_4 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_4 setting mkh5 epochs table ms3000 events and metadata EEG data marked as already having the desired reference. .. GENERATED FROM PYTHON SOURCE LINES 75-77 Complete export with codemap event tags from epochs table "ms1500" and garv annotations for those events. .. GENERATED FROM PYTHON SOURCE LINES 78-90 .. code-block:: default mkh5eeglab.mkh5_to_set( "../mkh5_data/sub000p3.h5", # file to convert "sub000p3.set", # eeglab file apparatus_yaml="ras_32chan_xyz_spherical.yml", # electrode locations epochs_name="ms1500", # epochs table with tagged events garv_annotations={ "event_channel": "ms1500", # mark garv artifacts for tagged events "tmin": -750, "tmax": 750, "units": "ms", }, ) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none ../mkh5_data/sub000p3.h5 looking up data block paths, larger files take longer ... ok /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_0 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) checking info, montage sub000/dblock_1 /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_1 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) checking info, montage sub000/dblock_2 /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_2 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) checking info, montage sub000/dblock_3 /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_3 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) checking info, montage sub000/dblock_4 /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_4 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_0 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=31232 Range : 0 ... 31231 = 0.000 ... 124.924 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_0 setting mkh5 epochs table ms100 events and metadata sub000/dblock_0 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_0 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_0 setting mkh5 epochs table ms3000 events and metadata annotating garv artifacts {'event_channel': 'ms1500', 'tmin': -750, 'tmax': 750, 'units': 'ms'} /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_1 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=32768 Range : 0 ... 32767 = 0.000 ... 131.068 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_1 setting mkh5 epochs table ms100 events and metadata sub000/dblock_1 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_1 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_1 setting mkh5 epochs table ms3000 events and metadata annotating garv artifacts {'event_channel': 'ms1500', 'tmin': -750, 'tmax': 750, 'units': 'ms'} /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_2 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=31744 Range : 0 ... 31743 = 0.000 ... 126.972 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_2 setting mkh5 epochs table ms100 events and metadata sub000/dblock_2 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_2 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_2 setting mkh5 epochs table ms3000 events and metadata annotating garv artifacts {'event_channel': 'ms1500', 'tmin': -750, 'tmax': 750, 'units': 'ms'} /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_3 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=32512 Range : 0 ... 32511 = 0.000 ... 130.044 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_3 setting mkh5 epochs table ms100 events and metadata sub000/dblock_3 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_3 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_3 setting mkh5 epochs table ms3000 events and metadata annotating garv artifacts {'event_channel': 'ms1500', 'tmin': -750, 'tmax': 750, 'units': 'ms'} /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1190: UserWarning: Overriding /sub000/dblock_4 with sensor locations from ras_32chan_xyz_spherical.yml warnings.warn(msg) Creating RawArray with float64 data, n_channels=39, n_times=28416 Range : 0 ... 28415 = 0.000 ... 113.660 secs Ready. /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/io/mkh5mne.py:1478: RuntimeWarning: Not setting position of 1 eog channel found in montage: ['HEOG'] Consider setting the channel types to be of EEG/sEEG/ECoG/DBS/fNIRS using inst.set_channel_types before calling inst.set_montage, or omit these channels when creating your montage. raw_dblock.set_montage(montage) sub000/dblock_4 setting mkh5 epochs table ms100 events and metadata sub000/dblock_4 setting mkh5 epochs table ms10000 events and metadata sub000/dblock_4 setting mkh5 epochs table ms1500 events and metadata sub000/dblock_4 setting mkh5 epochs table ms3000 events and metadata annotating garv artifacts {'event_channel': 'ms1500', 'tmin': -750, 'tmax': 750, 'units': 'ms'} EEG data marked as already having the desired reference. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 1 minutes 3.451 seconds) .. _sphx_glr_download_examples_gallery_mkh5eeglab_eeglab_quickstart.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: eeglab_quickstart.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: eeglab_quickstart.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_