.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorials/extractors/plot_1_read_various_formats.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_tutorials_extractors_plot_1_read_various_formats.py: Read various format into SpikeInterface ======================================= SpikeInterface can read various formats of "recording" (traces) and "sorting" (spike train) data. Internally, to read different formats, SpikeInterface either uses: * a wrapper to `neo `_ rawio classes * or a direct implementation Note that: * file formats contain a "recording", a "sorting", or "both" * file formats can be file-based (NWB, ...) or folder based (SpikeGLX, OpenEphys, ...) In this example we demonstrate how to read different file formats into SI .. GENERATED FROM PYTHON SOURCE LINES 18-24 .. code-block:: Python import matplotlib.pyplot as plt import spikeinterface.core as si import spikeinterface.extractors as se .. GENERATED FROM PYTHON SOURCE LINES 25-30 Let's download some datasets in different formats from the `ephy_testing_data `_ repo: * MEArec: a simulator format which is hdf5-based. It contains both a "recording" and a "sorting" in the same file. * Spike2: file from spike2 devices. It contains "recording" information only. .. GENERATED FROM PYTHON SOURCE LINES 30-38 .. code-block:: Python spike2_file_path = si.download_dataset(remote_path="spike2/130322-1LY.smr") print(spike2_file_path) mearec_folder_path = si.download_dataset(remote_path="mearec/mearec_test_10s.h5") print(mearec_folder_path) .. rst-class:: sphx-glr-script-out .. code-block:: none 0%| | 0.00/16.6M [00:00 True .. GENERATED FROM PYTHON SOURCE LINES 60-63 The :py:func:`~spikeinterface.extractors.read_spike2`` function is equivalent to instantiating a :py:class:`~spikeinterface.extractors.Spike2RecordingExtractor` object: .. GENERATED FROM PYTHON SOURCE LINES 63-67 .. code-block:: Python recording = se.Spike2RecordingExtractor(spike2_file_path, stream_id="0") print(recording) .. rst-class:: sphx-glr-script-out .. code-block:: none Spike2RecordingExtractor: 1 channels - 20833.333333 Hz - 1 segments - 4,126,365 samples 198.07s (3.30 minutes) - int16 dtype - 7.87 MiB file_path: /home/docs/spikeinterface_datasets/ephy_testing_data/spike2/130322-1LY.smr .. GENERATED FROM PYTHON SOURCE LINES 68-70 The :py:func:`~spikeinterface.extractors.read_mearec` function returns two objects, a :py:class:`~spikeinterface.core.BaseRecording` and a :py:class:`~spikeinterface.core.BaseSorting`: .. GENERATED FROM PYTHON SOURCE LINES 70-78 .. code-block:: Python recording, sorting = se.read_mearec(mearec_folder_path) print(recording) print(type(recording)) print() print(sorting) print(type(sorting)) .. rst-class:: sphx-glr-script-out .. code-block:: none MEArecRecordingExtractor: 32 channels - 32.0kHz - 1 segments - 320,000 samples - 10.00s float32 dtype - 39.06 MiB file_path: /home/docs/spikeinterface_datasets/ephy_testing_data/mearec/mearec_test_10s.h5 MEArecSortingExtractor: 10 units - 1 segments - 32.0kHz file_path: /home/docs/spikeinterface_datasets/ephy_testing_data/mearec/mearec_test_10s.h5 .. GENERATED FROM PYTHON SOURCE LINES 79-80 The :py:func:`~spikeinterface.extractors.read_mearec` function is equivalent to: .. GENERATED FROM PYTHON SOURCE LINES 80-84 .. code-block:: Python recording = se.MEArecRecordingExtractor(mearec_folder_path) sorting = se.MEArecSortingExtractor(mearec_folder_path) .. GENERATED FROM PYTHON SOURCE LINES 85-87 SI objects (:py:class:`~spikeinterface.core.BaseRecording` and :py:class:`~spikeinterface.core.BaseSorting`) can be plotted quickly with the :py:mod:`spikeinterface.widgets` submodule: .. GENERATED FROM PYTHON SOURCE LINES 87-94 .. code-block:: Python import spikeinterface.widgets as sw w_ts = sw.plot_traces(recording, time_range=(0, 5)) w_rs = sw.plot_rasters(sorting, time_range=(0, 5)) plt.show() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /tutorials/extractors/images/sphx_glr_plot_1_read_various_formats_001.png :alt: plot 1 read various formats :srcset: /tutorials/extractors/images/sphx_glr_plot_1_read_various_formats_001.png :class: sphx-glr-multi-img * .. image-sg:: /tutorials/extractors/images/sphx_glr_plot_1_read_various_formats_002.png :alt: plot 1 read various formats :srcset: /tutorials/extractors/images/sphx_glr_plot_1_read_various_formats_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 42.646 seconds) .. _sphx_glr_download_tutorials_extractors_plot_1_read_various_formats.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_1_read_various_formats.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_1_read_various_formats.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_1_read_various_formats.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_