SpikeInterface Logo

Contents:

  • Overview
  • Getting started
  • Tutorials
  • How to Guides
  • Modules documentation
  • API
  • Development
  • Release notes
  • Contact Us
  • How to Cite
SpikeInterface
  • Waveforms Widgets Gallery
  • View page source

Note

Go to the end to download the full example code.

Waveforms Widgets Gallery

Here is a gallery of all the available widgets using a pair of RecordingExtractor-SortingExtractor objects.

import matplotlib.pyplot as plt

import spikeinterface as si
import spikeinterface.extractors as se
import spikeinterface.postprocessing as spost
import spikeinterface.widgets as sw
First, let’s download a simulated dataset

from the repo ‘https://gin.g-node.org/NeuralEnsemble/ephy_testing_data’

local_path = si.download_dataset(remote_path="mearec/mearec_test_10s.h5")
recording, sorting = se.read_mearec(local_path)
print(recording)
print(sorting)
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

Extract spike waveforms

For convenience, metrics are computed on the SortingAnalyzer object that gathers recording/sorting and the extracted waveforms in a single object

analyzer = si.create_sorting_analyzer(sorting=sorting, recording=recording, format="memory")
# core extensions
analyzer.compute(["random_spikes", "waveforms", "templates", "noise_levels"])

# more extensions
analyzer.compute(["spike_amplitudes", "unit_locations", "spike_locations", "template_metrics"])
estimate_sparsity (no parallelization):   0%|          | 0/10 [00:00<?, ?it/s]
estimate_sparsity (no parallelization): 100%|██████████| 10/10 [00:00<00:00, 1342.91it/s]

compute_waveforms (no parallelization):   0%|          | 0/10 [00:00<?, ?it/s]
compute_waveforms (no parallelization): 100%|██████████| 10/10 [00:00<00:00, 497.31it/s]

noise_level (no parallelization):   0%|          | 0/20 [00:00<?, ?it/s]
noise_level (no parallelization):  40%|████      | 8/20 [00:00<00:00, 72.94it/s]
noise_level (no parallelization):  80%|████████  | 16/20 [00:00<00:00, 72.91it/s]
noise_level (no parallelization): 100%|██████████| 20/20 [00:00<00:00, 72.86it/s]

Compute : spike_amplitudes + spike_locations (no parallelization):   0%|          | 0/10 [00:00<?, ?it/s]
Compute : spike_amplitudes + spike_locations (no parallelization): 100%|██████████| 10/10 [00:00<00:00, 307.41it/s]

plot_unit_waveforms()

unit_ids = sorting.unit_ids[:4]

sw.plot_unit_waveforms(analyzer, unit_ids=unit_ids, figsize=(16, 4))
template #0, template #1, template #2, template #3
<spikeinterface.widgets.unit_waveforms.UnitWaveformsWidget object at 0x73b959b81090>

plot_unit_templates()

unit_ids = sorting.unit_ids

sw.plot_unit_templates(analyzer, unit_ids=unit_ids, ncols=5, figsize=(16, 8))
template #0, template #1, template #2, template #3, template #4, template #5, template #6, template #7, template #8, template #9
<spikeinterface.widgets.unit_templates.UnitTemplatesWidget object at 0x73b959b807f0>

plot_amplitudes()

sw.plot_amplitudes(analyzer, plot_histograms=True, figsize=(12, 8))
plot 3 waveforms gallery
<spikeinterface.widgets.amplitudes.AmplitudesWidget object at 0x73b959b833d0>

plot_unit_locations()

sw.plot_unit_locations(analyzer, figsize=(4, 8))
plot 3 waveforms gallery
<spikeinterface.widgets.unit_locations.UnitLocationsWidget object at 0x73b959b83dc0>

plot_unit_waveform_density_map()

This is your best friend to check for overmerge

unit_ids = sorting.unit_ids[:4]
sw.plot_unit_waveforms_density_map(analyzer, unit_ids=unit_ids, figsize=(14, 8))
plot 3 waveforms gallery
<spikeinterface.widgets.unit_waveforms_density_map.UnitWaveformDensityMapWidget object at 0x73b95cbfac80>

plot_amplitudes_distribution()

sw.plot_all_amplitudes_distributions(analyzer, figsize=(10, 10))
plot 3 waveforms gallery
<spikeinterface.widgets.all_amplitudes_distributions.AllAmplitudesDistributionsWidget object at 0x73b959b82e60>

plot_units_depths()

sw.plot_unit_depths(analyzer, figsize=(10, 10))
plot 3 waveforms gallery
<spikeinterface.widgets.unit_depths.UnitDepthsWidget object at 0x73b95e30b4c0>

plot_unit_probe_map()

unit_ids = sorting.unit_ids[:4]
sw.plot_unit_probe_map(analyzer, unit_ids=unit_ids, figsize=(20, 8))


plt.show()
#0, #1, #2, #3

Total running time of the script: (0 minutes 2.339 seconds)

Download Jupyter notebook: plot_3_waveforms_gallery.ipynb

Download Python source code: plot_3_waveforms_gallery.py

Download zipped: plot_3_waveforms_gallery.zip

Gallery generated by Sphinx-Gallery


© Copyright 2022, Alessio Paolo Buccino, Samuel Garcia, Cole Hurwitz, Jeremy Magland, Matthias Hennig.

Built with Sphinx using a theme provided by Read the Docs.