Skip to content

Commit 609361b

Browse files
authored
Merge branch 'main' into token
2 parents 67e1cf3 + 42d4855 commit 609361b

34 files changed

Lines changed: 795 additions & 221 deletions

doc/api.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Low-level
7676
.. autoclass:: ChunkRecordingExecutor
7777

7878

79-
Back-compatibility with ``WaveformExtractor`` (version < 0.101.0)
79+
Back-compatibility with ``WaveformExtractor`` (version > 0.100.0)
8080
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8181

8282
.. automodule:: spikeinterface.core
@@ -179,6 +179,8 @@ spikeinterface.preprocessing
179179
.. autofunction:: correct_motion
180180
.. autofunction:: get_motion_presets
181181
.. autofunction:: get_motion_parameters_preset
182+
.. autofunction:: load_motion_info
183+
.. autofunction:: save_motion_info
182184
.. autofunction:: depth_order
183185
.. autofunction:: detect_bad_channels
184186
.. autofunction:: directional_derivative

doc/get_started/import.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ For example:
7373
.. code-block:: python
7474
7575
from spikeinterface.preprocessing import bandpass_filter, common_reference
76-
from spikeinterface.core import extract_waveforms
76+
from spikeinterface.core import create_sorting_analyzer
7777
from spikeinterface.extractors import read_binary
7878
7979
As mentioned this approach only imports exactly what you plan on using so it is the most minimalist. It does require

doc/get_started/install_sorters.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ and in many cases the easiest way to run them is to do so via Docker or Singular
1212
**This is the approach we recommend for all users.**
1313
To run containerized sorters see our documentation here: :ref:`containerizedsorters`.
1414

15-
There are some cases where users will need to install the spike sorting algorithms in their own environment. If you
15+
There are some cases where you will need to install the spike sorting algorithms on your own computer. If you
1616
are on a system where it is infeasible to run Docker or Singularity containers, or if you are actively developing the
1717
spike sorting software, you will likely need to install each spike sorter yourself.
1818

@@ -24,7 +24,7 @@ opencl (Tridesclous) to use hardware acceleration (GPU).
2424
Here is a list of the implemented wrappers and some instructions to install them on your local machine.
2525
Installation instructions are given for an **Ubuntu** platform. Please check the documentation of the different spike
2626
sorters to retrieve installation instructions for other operating systems.
27-
We use **pip** to install packages, but **conda** should also work in many cases.
27+
We use **pip** to install packages, but **conda** or **uv** should also work in many cases.
2828

2929
Some novel spike sorting algorithms are implemented directly in SpikeInterface using the
3030
:py:mod:`spikeinterface.sortingcomponents` module. Checkout the :ref:`get_started/install_sorters:SpikeInterface-based spike sorters` section of this page
@@ -140,10 +140,12 @@ Kilosort4
140140

141141
* Python, requires CUDA for GPU acceleration (highly recommended)
142142
* Url: https://github.com/MouseLand/Kilosort
143-
* Authors: Marius Pachitariu, Shashwat Sridhar, Carsen Stringer
143+
* Authors: Marius Pachitariu, Shashwat Sridhar, Carsen Stringer, Jacob Pennington
144144
* Installation::
145145

146-
pip install kilosort==4.0 torch
146+
pip install kilosort
147+
pip uninstall torch
148+
pip install torch --index-url https://download.pytorch.org/whl/cu118
147149

148150
* For more installation instruction refer to https://github.com/MouseLand/Kilosort
149151

@@ -240,7 +242,7 @@ Waveclus
240242
* Also supports Snippets (waveform cutouts) objects (:py:class:`~spikeinterface.core.BaseSnippets`)
241243
* Url: https://github.com/csn-le/wave_clus/wiki
242244
* Authors: Fernando Chaure, Hernan Rey and Rodrigo Quian Quiroga
243-
* Installation needs Matlab::
245+
* Installation requires Matlab::
244246

245247
git clone https://github.com/csn-le/wave_clus/
246248
# provide installation path by setting the WAVECLUS_PATH environment variable
@@ -270,7 +272,7 @@ with SpikeInterface.
270272
SpykingCircus2
271273
^^^^^^^^^^^^^^
272274

273-
This is a upgraded version of SpykingCircus, natively written in SpikeInterface.
275+
This is an upgraded version of SpykingCircus, natively written in SpikeInterface.
274276
The main differences are located in the clustering (now using on-the-fly features and less prone to finding
275277
noise clusters), and in the template-matching procedure, which is now a fully orthogonal matching pursuit,
276278
working not only at peak times but at all times, recovering more spikes close to noise thresholds.
@@ -289,7 +291,7 @@ Tridesclous2
289291
^^^^^^^^^^^^
290292

291293
This is an upgraded version of Tridesclous, natively written in SpikeInterface.
292-
#Same add his notes.
294+
293295

294296
* Python
295297
* Requires: HDBSCAN and Numba
@@ -314,7 +316,7 @@ Klusta (LEGACY)
314316
* Authors: Cyrille Rossant, Shabnam Kadir, Dan Goodman, Max Hunter, Kenneth Harris
315317
* Installation::
316318

317-
pip install Cython h5py tqdm
319+
pip install cython h5py tqdm
318320
pip install click klusta klustakwik2
319321

320322
* See also: https://github.com/kwikteam/phy

doc/get_started/installation.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ Requirements
8181

8282
* numpy
8383
* probeinterface
84-
* neo>=0.9.0
85-
* joblib
84+
* neo
8685
* threadpoolctl
8786
* tqdm
87+
* zarr
88+
* pydantic
89+
* numcodecs
90+
* packaging
8891

8992
Sub-modules have more dependencies, so you should also install:
9093

91-
* zarr
9294
* h5py
9395
* scipy
9496
* pandas
@@ -98,8 +100,13 @@ Sub-modules have more dependencies, so you should also install:
98100
* matplotlib
99101
* numba
100102
* distinctipy
103+
* skops
104+
* huggingface_hub
101105
* cuda-python (for non-macOS users)
102106

103107

108+
For developers we offer a :code:`[dev]` option which installs testing, documentation, and linting packages necessary
109+
for testing and building the docs.
110+
104111
All external spike sorters can be either run inside containers (Docker or Singularity - see :ref:`containerizedsorters`)
105112
or must be installed independently (see :ref:`get_started/install_sorters:Installing Spike Sorters`).

doc/how_to/handle_drift.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,8 +1322,6 @@ A preset is a nested dict that contains theses methods/parameters.
13221322
Run motion correction with one function!
13231323
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13241324

1325-
Correcting for drift is easy! You just need to run a single function. We
1326-
will try this function with some presets.
13271325

13281326
Here we also save the motion correction results into a folder to be able
13291327
to load them later.
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
.. code:: ipython3
2+
3+
%matplotlib inline
4+
5+
Read various format into SpikeInterface
6+
=======================================
7+
8+
SpikeInterface can read various formats of “recording” (traces) and
9+
“sorting” (spike train) data.
10+
11+
Internally, to read different formats, SpikeInterface either uses: \* a
12+
wrapper to ``neo <https://github.com/NeuralEnsemble/python-neo>``\ \_
13+
rawio classes \* or a direct implementation
14+
15+
Note that:
16+
17+
- file formats contain a “recording”, a “sorting”, or “both”
18+
- file formats can be file-based (NWB, …) or folder based (SpikeGLX,
19+
OpenEphys, …)
20+
21+
In this example we demonstrate how to read different file formats into
22+
SI
23+
24+
.. code:: ipython3
25+
26+
import matplotlib.pyplot as plt
27+
28+
import spikeinterface.core as si
29+
import spikeinterface.extractors as se
30+
31+
Let’s download some datasets in different formats from the
32+
``ephy_testing_data <https://gin.g-node.org/NeuralEnsemble/ephy_testing_data>``\ \_
33+
repo:
34+
35+
- MEArec: a simulator format which is hdf5-based. It contains both a
36+
“recording” and a “sorting” in the same file.
37+
- Spike2: file from spike2 devices. It contains “recording” information
38+
only.
39+
40+
.. code:: ipython3
41+
42+
43+
spike2_file_path = si.download_dataset(remote_path="spike2/130322-1LY.smr")
44+
print(spike2_file_path)
45+
46+
mearec_folder_path = si.download_dataset(remote_path="mearec/mearec_test_10s.h5")
47+
print(mearec_folder_path)
48+
49+
50+
.. parsed-literal::
51+
52+
Downloading data from 'https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/mearec/mearec_test_10s.h5' to file '/Users/christopherhalcrow/spikeinterface_datasets/ephy_testing_data/mearec/mearec_test_10s.h5'.
53+
54+
55+
.. parsed-literal::
56+
57+
modified: spike2/130322-1LY.smr (file)
58+
1 annex'd file (15.8 MB recorded total size)
59+
/Users/christopherhalcrow/spikeinterface_datasets/ephy_testing_data/spike2/130322-1LY.smr
60+
1 annex'd file (59.4 MB recorded total size)
61+
nothing to save, working tree clean
62+
63+
64+
.. parsed-literal::
65+
66+
100%|█████████████████████████████████████| 62.3M/62.3M [00:00<00:00, 76.7GB/s]
67+
68+
69+
.. parsed-literal::
70+
71+
/Users/christopherhalcrow/spikeinterface_datasets/ephy_testing_data/mearec/mearec_test_10s.h5
72+
73+
74+
Now that we have downloaded the files, let’s load them into SI.
75+
76+
The :py:func:``~spikeinterface.extractors.read_spike2`` function returns
77+
one object, a :py:class:``~spikeinterface.core.BaseRecording``.
78+
79+
Note that internally this file contains 2 data streams (‘0’ and ‘1’), so
80+
we need to specify which one we want to retrieve (‘0’ in our case). the
81+
stream information can be retrieved by using the
82+
:py:func:``~spikeinterface.extractors.get_neo_streams`` function.
83+
84+
.. code:: ipython3
85+
86+
stream_names, stream_ids = se.get_neo_streams("spike2", spike2_file_path)
87+
print(stream_names)
88+
print(stream_ids)
89+
stream_id = stream_ids[0]
90+
print("stream_id", stream_id)
91+
92+
recording = se.read_spike2(spike2_file_path, stream_id="0")
93+
print(recording)
94+
print(type(recording))
95+
print(isinstance(recording, si.BaseRecording))
96+
97+
98+
.. parsed-literal::
99+
100+
['Signal stream 0', 'Signal stream 1']
101+
['0', '1']
102+
stream_id 0
103+
Spike2RecordingExtractor: 1 channels - 20833.333333 Hz - 1 segments - 4,126,365 samples
104+
198.07s (3.30 minutes) - int16 dtype - 7.87 MiB
105+
file_path: /Users/christopherhalcrow/spikeinterface_datasets/ephy_testing_data/spike2/130322-1LY.smr
106+
<class 'spikeinterface.extractors.neoextractors.spike2.Spike2RecordingExtractor'>
107+
True
108+
109+
110+
The
111+
:py:func::literal:`~spikeinterface.extractors.read_spike2`\` function is equivalent to instantiating a :py:class:`\ ~spikeinterface.extractors.Spike2RecordingExtractor\`
112+
object:
113+
114+
.. code:: ipython3
115+
116+
recording = se.read_spike2(spike2_file_path, stream_id="0")
117+
print(recording)
118+
119+
120+
.. parsed-literal::
121+
122+
Spike2RecordingExtractor: 1 channels - 20833.333333 Hz - 1 segments - 4,126,365 samples
123+
198.07s (3.30 minutes) - int16 dtype - 7.87 MiB
124+
file_path: /Users/christopherhalcrow/spikeinterface_datasets/ephy_testing_data/spike2/130322-1LY.smr
125+
126+
127+
The :py:func:``~spikeinterface.extractors.read_mearec`` function returns
128+
two objects, a :py:class:``~spikeinterface.core.BaseRecording`` and a
129+
:py:class:``~spikeinterface.core.BaseSorting``:
130+
131+
.. code:: ipython3
132+
133+
recording, sorting = se.read_mearec(mearec_folder_path)
134+
print(recording)
135+
print(type(recording))
136+
print()
137+
print(sorting)
138+
print(type(sorting))
139+
140+
141+
142+
.. parsed-literal::
143+
144+
MEArecRecordingExtractor: 32 channels - 32.0kHz - 1 segments - 320,000 samples - 10.00s
145+
float32 dtype - 39.06 MiB
146+
file_path: /Users/christopherhalcrow/spikeinterface_datasets/ephy_testing_data/mearec/mearec_test_10s.h5
147+
<class 'spikeinterface.extractors.neoextractors.mearec.MEArecRecordingExtractor'>
148+
149+
MEArecSortingExtractor: 10 units - 1 segments - 32.0kHz
150+
file_path: /Users/christopherhalcrow/spikeinterface_datasets/ephy_testing_data/mearec/mearec_test_10s.h5
151+
<class 'spikeinterface.extractors.neoextractors.mearec.MEArecSortingExtractor'>
152+
153+
154+
SI objects (:py:class:``~spikeinterface.core.BaseRecording`` and
155+
:py:class:``~spikeinterface.core.BaseSorting``) can be plotted quickly
156+
with the :py:mod:``spikeinterface.widgets`` submodule:
157+
158+
.. code:: ipython3
159+
160+
import spikeinterface.widgets as sw
161+
162+
w_ts = sw.plot_traces(recording, time_range=(0, 5))
163+
w_rs = sw.plot_rasters(sorting, time_range=(0, 5))
164+
165+
plt.show()
166+
167+
168+
169+
.. image:: read_various_formats_files/read_various_formats_12_0.png
170+
171+
172+
173+
.. image:: read_various_formats_files/read_various_formats_12_1.png
54.2 KB
Loading
12.9 KB
Loading

doc/modules/comparison.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,8 @@ The :py:func:`~spikeinterface.comparison.compare_two_sorters()` returns the comp
276276
import spikeinterface.comparisons as sc
277277
import spikinterface.widgets as sw
278278
279-
# First, let's download a simulated dataset
280-
local_path = si.download_dataset(remote_path='mearec/mearec_test_10s.h5')
281-
recording, sorting = se.read_mearec(local_path)
282-
279+
# First, let's generate a simulated dataset
280+
recording, sorting = si.generate_ground_truth_recording()
283281
# Then run two spike sorters and compare their outputs.
284282
sorting_HS = ss.run_sorter(sorter_name='herdingspikes', recording=recording)
285283
sorting_TDC = ss.run_sorter(sorter_name='tridesclous', recording=recording)
@@ -332,9 +330,8 @@ Comparison of multiple sorters uses the following procedure:
332330

333331
.. code-block:: python
334332
335-
# Download a simulated dataset
336-
local_path = si.download_dataset(remote_path='mearec/mearec_test_10s.h5')
337-
recording, sorting = se.read_mearec(local_path)
333+
# Generate a simulated dataset
334+
recording, sorting = si.generate_ground_truth_recording()
338335
339336
# Then run 3 spike sorters and compare their outputs.
340337
sorting_MS4 = ss.run_sorter(sorter_name='mountainsort4', recording=recording)

0 commit comments

Comments
 (0)