Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ spikeinterface.core
:inherited-members:
.. autoclass:: BaseSorting
:members:
.. autoclass:: BaseSnippets
:members:
.. autoclass:: BaseEvent
:members:
.. autoclass:: SortingAnalyzer
Expand All @@ -28,10 +26,8 @@ spikeinterface.core
.. autoclass:: BinaryRecordingExtractor
.. autoclass:: BinaryFolderRecording
.. autoclass:: NumpyFolderSorting
.. autoclass:: NpyFolderSnippets
.. autoclass:: NumpyRecording
.. autoclass:: NumpySorting
.. autoclass:: NumpySnippets
.. autoclass:: AppendSegmentRecording
.. autoclass:: ConcatenateSegmentRecording
.. autoclass:: SelectSegmentRecording
Expand Down Expand Up @@ -423,7 +419,6 @@ Core

.. autofunction:: generate_recording
.. autofunction:: generate_sorting
.. autofunction:: generate_snippets
.. autofunction:: generate_templates
.. autofunction:: generate_recording_by_size
.. autofunction:: generate_ground_truth_recording
Expand Down
1 change: 0 additions & 1 deletion doc/get_started/install_sorters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ Waveclus
^^^^^^^^

* Matlab
* Also supports Snippets (waveform cutouts) objects (:py:class:`~spikeinterface.core.BaseSnippets`)
* Url: https://github.com/csn-le/wave_clus/wiki
* Authors: Fernando Chaure, Hernan Rey and Rodrigo Quian Quiroga
* Installation requires Matlab::
Expand Down
2 changes: 1 addition & 1 deletion doc/get_started/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ installed

.. parsed-literal::

Available sorters ['combinato', 'hdsort', 'herdingspikes', 'ironclust', 'kilosort', 'kilosort2', 'kilosort2_5', 'kilosort3', 'kilosort4', 'klusta', 'mountainsort4', 'mountainsort5', 'pykilosort', 'simple', 'spykingcircus', 'spykingcircus2', 'tridesclous', 'tridesclous2', 'waveclus', 'waveclus_snippets', 'yass']
Available sorters ['combinato', 'hdsort', 'herdingspikes', 'ironclust', 'kilosort', 'kilosort2', 'kilosort2_5', 'kilosort3', 'kilosort4', 'klusta', 'mountainsort4', 'mountainsort5', 'pykilosort', 'simple', 'spykingcircus', 'spykingcircus2', 'tridesclous', 'tridesclous2', 'waveclus', 'yass']
Installed sorters ['mountainsort4', 'simple', 'spykingcircus2', 'tridesclous', 'tridesclous2']


Expand Down
71 changes: 6 additions & 65 deletions doc/modules/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ The core classes are: :py:class:`~spikeinterface.core.BaseRecording` (for raw da
:py:class:`~spikeinterface.core.BaseSorting` (for spike-sorted data), and
:py:class:`~spikeinterface.core.SortingAnalyzer` (for postprocessing, quality metrics, and waveform extraction).

There are additional classes to allow to retrieve events (:py:class:`~spikeinterface.core.BaseEvent`) and to
handle unsorted waveform cutouts, or *snippets*, which are recorded by some acquisition systems
(:py:class:`~spikeinterface.core.BaseSnippets`).
In addition, this module includes a base class to retrieve events (:py:class:`~spikeinterface.core.BaseEvent`).


All classes support:
Expand Down Expand Up @@ -483,52 +481,6 @@ with events from two channels:
### NOTE ###
# 'segment_index' is required for multi-segment objects


Snippets
--------

The :py:class:`~spikeinterface.core.BaseSnippets` class serves as basis for all :code:`Snippets`
classes (currently only :py:class:`~spikeinterface.core.NumpySnippets` and
:code:`WaveClusSnippetsExtractor` are implemented).

It represents unsorted waveform cutouts. Some acquisition systems, in fact, allow users to set a
threshold and only record the times at which a peak was detected and the waveform cut out around
the peak.

.. note::

While we support this class (mainly for legacy formats), this approach is a bad practice
and is highly discouraged! Most modern spike sorters, in fact, require the raw traces to perform
template matching to recover spikes!

Here we assume :code:`snippets` is a :py:class:`~spikeinterface.core.BaseSnippets` object
with 16 channels:

.. code-block:: python

channel_ids = snippets.channel_ids
num_channels = snippets.get_num_channels()
# retrieve number of snippets
num_snippets = snippets.get_num_snippets(segment_index=0)
### NOTE ###
# 'segment_index' is required for multi-segment objects
# retrieve total number of snippets across segments
total_snippets = snippets.get_total_snippets()

# retrieve snippet size
nbefore = snippets.nbefore # samples before peak
nsamples_per_snippet = snippets.snippet_len # total
nafter = nsamples_per_snippet - nbefore # samples after peak

# retrieve sample/frame indices
frames = snippets.get_frames(segment_index=0)
# retrieve snippet cutouts
snippet_cutouts = snippets.get_snippets(segment_index=0)
# retrieve snippet cutouts on first 4 channels
snippet_cutouts_slice = snippets.get_snippets(channel_ids=channel_ids[:4],
segment_index=0)


Handling probes
---------------

Expand Down Expand Up @@ -648,15 +600,14 @@ Saving, loading, and compression
--------------------------------

The Base SpikeInterface objects (:py:class:`~spikeinterface.core.BaseRecording`,
:py:class:`~spikeinterface.core.BaseSorting`, and
:py:class:`~spikeinterface.core.BaseSnippets`) hold full information about their history to maintain provenance.
:py:class:`~spikeinterface.core.BaseSorting`) hold full information about their history to maintain provenance.
Each object is in fact internally represented as a dictionary (:code:`si_object.to_dict()`) which can be used to
re-instantiate the object from scratch (this is true for all objects except in-memory ones, see :ref:`in_memory`).

The :code:`save()` function allows to easily store SI objects to a folder on disk.
:py:class:`~spikeinterface.core.BaseRecording` objects are stored in binary (.raw) or
`Zarr <https://zarr.readthedocs.io/en/stable/tutorial.html>`__ (.zarr) format and
:py:class:`~spikeinterface.core.BaseSorting` and :py:class:`~spikeinterface.core.BaseSnippets` object in numpy (.npz)
:py:class:`~spikeinterface.core.BaseSorting` object in numpy (.npy) or Zarr (.zarr) format.
format. With the actual data, the :code:`save()` function also stores the provenance dictionary and all the properties
and annotations associated to the object.
The save function also supports parallel processing to speed up the writing process.
Expand All @@ -673,10 +624,6 @@ This saving/loading features enables us to store SpikeInterface objects efficien
recording_bin = recording.save(folder="recording", **job_kwargs)
# save recording to folder in zarr format (.zarr is appended automatically)
recording_zarr = recording.save(folder="recording", format="zarr", **job_kwargs)
# save snippets to NPZ
snippets_saved = snippets.save(folder="snippets")
# save sorting to NPZ
sorting_saved = sorting.save(folder="sorting")

**NOTE:** the Zarr format by default applies data compression with :code:`Blosc.Zstandard` codec with BIT shuffling.
Any other Zarr-compatible compressors and filters can be applied using the :code:`compressor` and :code:`filters`
Expand Down Expand Up @@ -749,8 +696,7 @@ in-memory objects (for example, for testing a new method) or "manually" add some
workflow.

In order to do this, one can use the :code:`Numpy*` classes, :py:class:`~spikeinterface.core.NumpyRecording`,
:py:class:`~spikeinterface.core.NumpySorting`, :py:class:`~spikeinterface.core.NumpyEvent`, and
:py:class:`~spikeinterface.core.NumpySnippets`. These object behave exactly like normal SpikeInterface objects,
:py:class:`~spikeinterface.core.NumpySorting`, and :py:class:`~spikeinterface.core.NumpyEvent`. These object behave exactly like normal SpikeInterface objects,
but they are not bound to a file.

Also note the class :py:class:`~spikeinterface.core.SharedMemorySorting` which is very similar to
Expand Down Expand Up @@ -814,7 +760,7 @@ Any sorting object can be transformed into a :py:class:`~spikeinterface.core.Num
Manipulating objects: slicing, aggregating
-------------------------------------------

:py:class:`~spikeinterface.core.BaseRecording` (and :py:class:`~spikeinterface.core.BaseSnippets`)
:py:class:`~spikeinterface.core.BaseRecording`
and :py:class:`~spikeinterface.core.BaseSorting` objects can be sliced on the time or channel/unit axis.

These operations are completely lazy, as there is no data duplication. After slicing or aggregating,
Expand Down Expand Up @@ -949,7 +895,7 @@ They are useful to make examples, tests, and small demos:

.. code-block:: python

from spikeinterface.core import generate_recording, generate_sorting, generate_snippets
from spikeinterface.core import generate_recording, generate_sorting

# recording with 2 segments and 4 channels
recording = generate_recording(num_channels=4, sampling_frequency=30000.,
Expand All @@ -959,11 +905,6 @@ They are useful to make examples, tests, and small demos:
sorting = generate_sorting(num_units=5, sampling_frequency=30000., durations=[10.325, 3.5],
firing_rates=15, refractory_period_ms=1.5)

# snippets of 60 samples on 2 channels from 5 units
snippets = generate_snippets(nbefore=20, nafter=40, num_channels=2,
sampling_frequency=30000., durations=[10.325, 3.5],
set_probe=True, num_units=5)


There are also some more advanced functions to generate sorting objects with varioues "mistakes"
(mainly for testing purposes):
Expand Down
15 changes: 0 additions & 15 deletions doc/modules/preprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -532,21 +532,6 @@ Of course, these pipelines can be enhanced and customized using other available




Preprocessing on Snippets
-------------------------

Some preprocessing steps are available also for :py:class:`~spikeinterface.core.BaseSnippets` objects:

align_snippets()
^^^^^^^^^^^^^^^^

This function aligns waveform snippets.

* :py:func:`~spikeinterface.preprocessing.align_snippets()`



References
----------

Expand Down
9 changes: 1 addition & 8 deletions src/spikeinterface/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from .baserecording import BaseRecording, BaseRecordingSegment
from .basesorting import BaseSorting, BaseSortingSegment, SpikeVectorSortingSegment
from .baseevent import BaseEvent, BaseEventSegment
from .basesnippets import BaseSnippets, BaseSnippetsSegment
from .baserecordingsnippets import BaseRecordingSnippets

from .loading import load

Expand All @@ -15,16 +13,13 @@
NumpySorting,
SharedMemorySorting,
NumpyEvent,
NumpySnippets,
)
from .zarrextractors import read_zarr, read_zarr_array, get_default_zarr_compressor
from .binaryfolder import BinaryFolderRecording, read_binary_folder
from .sortingfolder import NumpyFolderSorting, NpzFolderSorting, read_numpy_sorting_folder, read_npz_folder
from .npysnippetsextractor import NpySnippetsExtractor, read_npy_snippets
from .npyfoldersnippets import NpyFolderSnippets, read_npy_snippets_folder

# utility extractors (equivalent to OLD subrecording/subsorting)
from .channelslice import ChannelSliceRecording, ChannelSliceSnippets
from .channelslice import ChannelSliceRecording
from .unitsselectionsorting import UnitsSelectionSorting
from .frameslicerecording import FrameSliceRecording
from .frameslicesorting import FrameSliceSorting
Expand All @@ -38,7 +33,6 @@
generate_sorting,
add_synchrony_to_sorting,
create_sorting_npz,
generate_snippets,
synthesize_random_firings,
inject_some_duplicate_units,
inject_some_split_units,
Expand Down Expand Up @@ -121,7 +115,6 @@
)

from .waveform_tools import extract_waveforms_to_buffers, estimate_templates, estimate_templates_with_accumulator
from .snippets_tools import snippets_from_sorting

# waveform extractor
# Important not for compatibility!!
Expand Down
Loading
Loading