.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_gallery/mkh5/mkh5_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_mkh5_mkh5_quickstart.py: .. _mkh5_quickstart: mkh5 Quickstart =============== .. GENERATED FROM PYTHON SOURCE LINES 11-29 #. In a terminal window use ``mamba`` (recommended) or ``conda`` (if necessary) to install mkpy along with jupyter or jupyterlab into a fresh environment and activate it: .. code-block:: bash $ mamba create --name mkpy_041221 mkpy jupyterlab \ -c kutaslab -c conda-forge -c defaults \ --strict-channel-priority $ conda activate mkpy_041221 #. In a terminal window navigate to the directory where you want to work and run:: $ jupyter notebook #. Open a notebook with a Python 3 kernel and proceed. .. GENERATED FROM PYTHON SOURCE LINES 32-33 Single subject single session workflow .. GENERATED FROM PYTHON SOURCE LINES 34-49 .. code-block:: default from mkpy import mkh5 as mkh5 DATA_H5_F = "../mkh5_data/_sub000p3.h5" data_h5 = mkh5.mkh5(DATA_H5_F) data_h5.reset_all() # load the crw, log, and YAML header data_h5.create_mkdata( "sub000", "../mkdig_data/sub000p3.crw", "../mkdig_data/sub000p3.x.log", "../mkdig_data/sub000p3.yhdr", ) .. GENERATED FROM PYTHON SOURCE LINES 50-51 If calibration pulses are not in the .crw file, append them like so: .. GENERATED FROM PYTHON SOURCE LINES 52-72 .. code-block:: default data_h5.append_mkdata( "sub000", "../mkdig_data/sub000c.crw", "../mkdig_data/sub000c.log", "../mkdig_data/sub000c.yhdr", ) # Visually check the calibration parameters. pts, pulse, lo, hi, ccode = 3, 10, -50, 50, 0 fig, ax = data_h5.plotcals( DATA_H5_F, "sub000", n_points=pts, # pts to average, either side of cursor cal_size=pulse, # uV lo_cursor=lo, # lo_cursor ms hi_cursor=hi, # hi_cursor ms cal_ccode=ccode, ) fig.show() .. image-sg:: /examples_gallery/mkh5/images/sphx_glr_mkh5_quickstart_001.png :alt: calibration pulses (recorded N=209) from: ../mkh5_data/_sub000p3.h5 sub000 n_points=3 cal_size=10 lo_cursor=-50 hi_cursor=50 cal_ccode=0, scale=17.67, trimmed 5, scale=20.30, trimmed 6, scale=20.05, trimmed 8, scale=20.79, trimmed 5, scale=20.59, trimmed 2, scale=40.13, trimmed 6, scale=39.63, trimmed 9, scale=40.82, trimmed 6, scale=40.47, trimmed 3, scale=40.01, trimmed 11, scale=38.82, trimmed 6, scale=35.58, trimmed 16, scale=36.46, trimmed 3, scale=40.63, trimmed 14, scale=37.88, trimmed 15, scale=39.60, trimmed 13, scale=42.02, trimmed 15, scale=39.58, trimmed 16, scale=41.42, trimmed 5, scale=40.49, trimmed 12, scale=40.11, trimmed 7, scale=40.81, trimmed 7, scale=40.65, trimmed 6, scale=39.84, trimmed 12, scale=40.59, trimmed 24, scale=40.37, trimmed 11, scale=40.81, trimmed 9, scale=41.27, trimmed 7, scale=40.73, trimmed 9, scale=40.92, trimmed 4, scale=20.57, trimmed 5, scale=20.59, trimmed 14 :srcset: /examples_gallery/mkh5/images/sphx_glr_mkh5_quickstart_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Plotting cals /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/mkh5.py:3666: UserWarning: negative event code(s) found for cal condition code 0 -16384 warnings.warn(msg) Found cals in /sub000/dblock_4 .. GENERATED FROM PYTHON SOURCE LINES 73-74 Scale the EEG A/D to microvolts. .. GENERATED FROM PYTHON SOURCE LINES 75-85 .. code-block:: default data_h5.calibrate_mkdata( "sub000", n_points=pts, cal_size=pulse, lo_cursor=lo, hi_cursor=hi, cal_ccode=ccode, use_cals=None, ) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none /usr/share/miniconda/envs/env_3.8/lib/python3.8/site-packages/mkpy/mkh5.py:3666: UserWarning: negative event code(s) found for cal condition code 0 -16384 warnings.warn(msg) Found cals in /sub000/dblock_4 Calibrating block /sub000/dblock_0 of 5: (31232,) Calibrating block /sub000/dblock_1 of 5: (32768,) Calibrating block /sub000/dblock_2 of 5: (31744,) Calibrating block /sub000/dblock_3 of 5: (32512,) Calibrating block /sub000/dblock_4 of 5: (28416,) .. GENERATED FROM PYTHON SOURCE LINES 86-87 Examine some header info with :py:meth:`.mkh5.headinfo` .. GENERATED FROM PYTHON SOURCE LINES 87-89 .. code-block:: default data_h5.headinfo("dblock_0.*samplerate") data_h5.headinfo("dblock_0.*MiPa") .. rst-class:: sphx-glr-script-out Out: .. code-block:: none sub000/dblock_0/samplerate: 250.0 sub000/dblock_0/apparatus/streams/MiPa/pos: MiPa sub000/dblock_0/apparatus/streams/MiPa/neg: A1 sub000/dblock_0/apparatus/streams/MiPa/gain: 20000 sub000/dblock_0/apparatus/streams/MiPa/hphz: 0.01 sub000/dblock_0/apparatus/streams/MiPa/lphz: 100.0 sub000/dblock_0/apparatus/streams/MiPa/mne_type: eeg sub000/dblock_0/apparatus/sensors/MiPa/x: 0.0 sub000/dblock_0/apparatus/sensors/MiPa/y: -2.7 sub000/dblock_0/apparatus/sensors/MiPa/z: 13.2 sub000/dblock_0/streams/MiPa/jdx: 23 sub000/dblock_0/streams/MiPa/source: dig_chan_0016 sub000/dblock_0/streams/MiPa/name: MiPa sub000/dblock_0/streams/MiPa/dt: ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: mkh5_quickstart.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_