.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorials/qualitymetrics/plot_3_quality_metrics.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_qualitymetrics_plot_3_quality_metrics.py: Quality Metrics Tutorial ======================== After spike sorting, you might want to validate the 'goodness' of the sorted units. This can be done using the :code:`qualitymetrics` submodule, which computes several quality metrics of the sorted units. .. GENERATED FROM PYTHON SOURCE LINES 9-21 .. code-block:: Python import spikeinterface.core as si import spikeinterface.extractors as se from spikeinterface.postprocessing import compute_principal_components from spikeinterface.qualitymetrics import ( compute_snrs, compute_firing_rates, compute_isi_violations, calculate_pc_metrics, compute_quality_metrics, ) .. GENERATED FROM PYTHON SOURCE LINES 22-24 First, let's download a simulated dataset from the repo 'https://gin.g-node.org/NeuralEnsemble/ephy_testing_data' .. GENERATED FROM PYTHON SOURCE LINES 24-30 .. code-block:: Python local_path = si.download_dataset(remote_path="mearec/mearec_test_10s.h5") recording, sorting = se.read_mearec(local_path) print(recording) print(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 31-35 Create SortingAnalyzer ----------------------- For quality metrics we need first to create a :code:`SortingAnalyzer`. .. GENERATED FROM PYTHON SOURCE LINES 35-39 .. code-block:: Python analyzer = si.create_sorting_analyzer(sorting=sorting, recording=recording, format="memory") print(analyzer) .. rst-class:: sphx-glr-script-out .. code-block:: none estimate_sparsity (no parallelization): 0%| | 0/10 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_3_quality_metrics.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_3_quality_metrics.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_