.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_run_open_loop.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_auto_examples_plot_run_open_loop.py: ========================================= Collect data to train your own decoder ========================================= .. currentmodule:: neural_data_simulator The goal of this example is to show how you can run an open loop simulation and collect the electrophysiology data needed for training your own decoder. By default, this script will download the data to be plotted from AWS S3. If you prefer to use your own data, run the following steps: 1. Configure center out reach to `run without a decoder <../tasks.html#running-without-a-decoder>`_. 2. Run the following script:: # for macOS or Linux {center_out_reach; pkill -SIGTERM -f recorder} &; encoder &; ephys_generator &; \ recorder --session "open_loop" --lsl "NDS-RawData"; pkill -f decoder; \ pkill -f ephys_generator; pkill -f encoder; pkill -f center_out_reach # for Windows (PowerShell) Start-Process center_out_reach; Start-Process encoder; Start-Process ephys_generator; ` recorder --session "example" --lsl "NDS-RawData" 3. Press CTRL+C to stop the recording or add a *\--recording_time n* to the recorder script to specify the amount of seconds to record 4. Change the following variable below:: LOCAL_DATA = True 5. Replace the variable with the path to your data:: RAW_DATA_PATH = "the_path_to_your_recorded_raw_data.npz" .. GENERATED FROM PYTHON SOURCE LINES 40-42 Environment setup ------------------ .. GENERATED FROM PYTHON SOURCE LINES 42-44 .. code-block:: default LOCAL_DATA = False .. GENERATED FROM PYTHON SOURCE LINES 45-48 Set data source ---------------- Retrieve the data from AWS S3 or define the path to your local file. .. GENERATED FROM PYTHON SOURCE LINES 48-62 .. code-block:: default from urllib.parse import urljoin import pooch DOWNLOAD_BASE_URL = "https://neural-data-simulator.s3.amazonaws.com/sample_data/v1/" if not LOCAL_DATA: RAW_DATA_PATH = pooch.retrieve( url=urljoin(DOWNLOAD_BASE_URL, "example_NDS-RawData.npz"), known_hash="md5:887d88387674d8a7d27726e11663eee4", ) else: RAW_DATA_PATH = "the_path_to_your_recorded_raw_data.npz" .. rst-class:: sphx-glr-script-out .. code-block:: none Downloading data from 'https://neural-data-simulator.s3.amazonaws.com/sample_data/v1/example_NDS-RawData.npz' to file '/home/runner/.cache/pooch/74e4600874eb5b04fafcc2635bc5f5cc-example_NDS-RawData.npz'. .. GENERATED FROM PYTHON SOURCE LINES 63-66 Load data --------- Load the data to be plotted. .. GENERATED FROM PYTHON SOURCE LINES 66-73 .. code-block:: default import numpy as np raw_data_file = np.load(RAW_DATA_PATH) raw_data = raw_data_file["data"] / 4 raw_data_timestamps = raw_data_file["timestamps"] - raw_data_file["timestamps"][0] .. GENERATED FROM PYTHON SOURCE LINES 74-76 Plot data ---------- .. GENERATED FROM PYTHON SOURCE LINES 76-82 .. code-block:: default import matplotlib.pyplot as plt CHANNEL = 20 plt.plot(raw_data_timestamps, raw_data[:, CHANNEL]) plt.show() .. image-sg:: /auto_examples/images/sphx_glr_plot_run_open_loop_001.png :alt: plot run open loop :srcset: /auto_examples/images/sphx_glr_plot_run_open_loop_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 6.923 seconds) .. _sphx_glr_download_auto_examples_plot_run_open_loop.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_run_open_loop.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_run_open_loop.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_