.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/3_create_dataset.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_3_create_dataset.py: Creating a dataset =========================== This example shows how to create a dataset for training a deep learning model. .. GENERATED FROM PYTHON SOURCE LINES 11-14 In this example we will create a dataset that was used in our real-time paper [1]_. .. [1] Sîmpetru, R.C., März, M., Del Vecchio, A., 2023. Proportional and Simultaneous Real-Time Control of the Full Human Hand From High-Density Electromyography. IEEE TNSRE 31, 3118–3131. https://doi.org/10/gsgk4s .. GENERATED FROM PYTHON SOURCE LINES 14-75 .. code-block:: Python from functools import partial from pathlib import Path import numpy as np from scipy.signal import butter from doc_octopy.datasets.filters.emg_augmentations import WaveletDecomposition from doc_octopy.datasets.filters.generic import ApplyFunctionFilter, IndexDataFilter from doc_octopy.datasets.filters.temporal import SOSFrequencyFilter from doc_octopy.datasets.supervised import EMGDataset dataset = EMGDataset( emg_data_path=Path("data/emg.pkl").resolve(), ground_truth_data_path=Path("data/kinematics.pkl").resolve(), sampling_frequency=2044.0, tasks_to_use=["1", "2"], save_path=Path("data/dataset.zarr").resolve(), emg_filter_pipeline_after_chunking=[ [ SOSFrequencyFilter( sos_filter_coefficients=butter( 4, [47.5, 52.5], "bandstop", output="sos", fs=2044 ), is_output=True, name="Raw No Powerline", ), SOSFrequencyFilter( sos_filter_coefficients=butter(4, 20, "lowpass", output="sos", fs=2044), is_output=True, name="Raw No Powerline Lowpassed 20 Hz", ), ] ], emg_representations_to_filter_after_chunking=["Last"], ground_truth_filter_pipeline_before_chunking=[ [ ApplyFunctionFilter(function=np.reshape, newshape=(63, -1)), IndexDataFilter(indices=(slice(3, 63),)), ] ], ground_truth_representations_to_filter_before_chunking=["Input"], ground_truth_filter_pipeline_after_chunking=[ [ ApplyFunctionFilter( function=partial(np.mean, axis=-1), is_output=True, name="Mean Kinematics per EMG Chunk", ), ] ], ground_truth_representations_to_filter_after_chunking=["Last"], testing_split_ratio=0.3, validation_split_ratio=0.1, augmentation_pipelines=[ [WaveletDecomposition(nr_of_grids=5, is_output=True, level=2)] ], ) dataset.create_dataset() .. rst-class:: sphx-glr-script-out .. code-block:: none Filtering and splitting data: 0%| | 0/2 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 3_create_dataset.py <3_create_dataset.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 3_create_dataset.zip <3_create_dataset.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_