SpikeInterface
0.98.0

Contents:

  • Overview
  • Installation
  • Modules documentation
  • How to guides
  • Modules example gallery
    • Core tutorials
    • Extractors tutorials
    • Quality metrics tutorial
    • Comparison tutorial
    • Widgets tutorials
      • Core tutorials
      • Extractors tutorials
      • Quality metrics tutorial
      • Comparison tutorial
      • Widgets tutorials
        • RecordingExtractor Widgets Gallery
        • SortingExtractor Widgets Gallery
        • Waveforms Widgets Gallery
        • Peaks Widgets Gallery
  • Installing Spike Sorters
  • Viewers
  • Development
  • API
  • Release notes
  • Contact Us
SpikeInterface
  • Modules example gallery
  • Widgets tutorials
  • Peaks Widgets Gallery
  • Edit on GitHub

Note

Go to the end to download the full example code

Peaks Widgets Gallery¶

Some widgets are useful before sorting and works with “peaks” given by detect_peaks() function.

They are useful to check drift before running sorters.

import matplotlib.pyplot as plt

import spikeinterface.full as si
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/checkouts/0.98.0/examples/modules_gallery/widgets/plot_4_peaks_gallery.py", line 13, in <module>
    import spikeinterface.full as si
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/full.py", line 17, in <module>
    from .extractors import *
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/__init__.py", line 1, in <module>
    from .extractorlist import *
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/extractorlist.py", line 15, in <module>
    from .neoextractors import *
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/neoextractors/__init__.py", line 1, in <module>
    from .alphaomega import AlphaOmegaRecordingExtractor, AlphaOmegaEventExtractor, read_alphaomega, read_alphaomega_event
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/neoextractors/alphaomega.py", line 3, in <module>
    from .neobaseextractor import NeoBaseRecordingExtractor, NeoBaseEventExtractor
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/neoextractors/neobaseextractor.py", line 332, in <module>
    class NeoBaseSortingExtractor(_NeoBaseExtractor, BaseSorting):
  File "/home/docs/checkouts/readthedocs.org/user_builds/spikeinterface/conda/0.98.0/lib/python3.9/site-packages/spikeinterface/extractors/neoextractors/neobaseextractor.py", line 480, in NeoBaseSortingExtractor
    def _infer_t_start_from_signal_stream(self, segment_index: int, stream_id: Optional[str] = None) -> float | None:
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

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')
rec, sorting = si.read_mearec(local_path)

Lets filter and detect peak on it

from spikeinterface.sortingcomponents.peak_detection import detect_peaks

rec_filtred = si.bandpass_filter(rec, freq_min=300., freq_max=6000., margin_ms=5.0)
print(rec_filtred)
peaks = detect_peaks(
        rec_filtred, method='locally_exclusive',
        peak_sign='neg', detect_threshold=6, exclude_sweep_ms=0.3,
        local_radius_um=100,
        noise_levels=None,
        random_chunk_kwargs={},
        chunk_memory='10M', n_jobs=1, progress_bar=True)

peaks is a numpy 1D array with structured dtype that contains several fields:

print(peaks.dtype)
print(peaks.shape)
print(peaks.dtype.fields.keys())
This “peaks” vector can be used in several widgets, for instance

plot_peak_activity_map()

si.plot_peak_activity_map(rec_filtred, peaks=peaks)

can be also animated with bin_duration_s=1.

si.plot_peak_activity_map(rec_filtred, bin_duration_s=1.)

plot_drift_over_time()¶

Plots detected peaks over time in scatter mode heatmap mode. Here bin_duration_s=1.0 because the recording is short (10s). A better value could 60s for normal recordings

si.plot_drift_over_time(rec_filtred, peaks=peaks, bin_duration_s=1.,
                        weight_with_amplitudes=True, mode='heatmap')

Plots detected peaks over time in scatter mode

si.plot_drift_over_time(rec_filtred, peaks=peaks, weight_with_amplitudes=False, mode='scatter')


plt.show()

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

Download Python source code: plot_4_peaks_gallery.py

Download Jupyter notebook: plot_4_peaks_gallery.ipynb

Gallery generated by Sphinx-Gallery

Previous Next

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

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