Skip to content

Commit 7fa402c

Browse files
authored
Merge branch 'main' into rt-sort
2 parents 9f2a992 + aa3d561 commit 7fa402c

100 files changed

Lines changed: 2409 additions & 890 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/api.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ spikeinterface.core
2222
.. autofunction:: estimate_sparsity
2323
.. autoclass:: ChannelSparsity
2424
:members:
25+
.. autoclass:: Motion
26+
:members:
2527
.. autoclass:: BinaryRecordingExtractor
2628
.. autoclass:: ZarrRecordingExtractor
2729
.. autoclass:: BinaryFolderRecording
@@ -277,8 +279,6 @@ spikeinterface.comparison
277279

278280
.. autoclass:: CollisionGTComparison
279281
.. autoclass:: CorrelogramGTComparison
280-
.. autoclass:: CollisionGTStudy
281-
.. autoclass:: CorrelogramGTStudy
282282

283283

284284

@@ -449,7 +449,6 @@ Motion Correction
449449
~~~~~~~~~~~~~~~~~
450450
.. automodule:: spikeinterface.sortingcomponents.motion
451451

452-
.. autoclass:: Motion
453452
.. autofunction:: estimate_motion
454453
.. autofunction:: interpolate_motion
455454
.. autofunction:: correct_motion_on_peaks

doc/conf.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@
3131
folders = [
3232
'../examples/tutorials/core/my_recording',
3333
'../examples/tutorials/core/my_sorting',
34-
'../examples/tutorials/core/waveform_folder',
35-
'../examples/tutorials/core/waveform_folder_parallel',
36-
'../examples/tutorials/core/waveform_folder_sparse',
37-
'../examples/tutorials/core/waveform_folder_sparse_direct',
38-
'../examples/tutorials/core/waveform_folder2',
39-
'../examples/tutorials/core/waveform_folder',
40-
'../examples/tutorials/qualitymetrics/waveforms_mearec',
41-
'../examples/tutorials/qualitymetrics/wfs_mearec',
34+
'../examples/tutorials/core/analyzer_folder',
35+
'../examples/tutorials/core/analyzer_some_units',
36+
'../examples/tutorials/core/analyzer.zarr',
37+
'../examples/tutorials/curation/my_folder',
38+
'../examples/tutorials/qualitymetrics/curated_sorting',
39+
'../examples/tutorials/qualitymetrics/clean_analyzer.zarr',
4240
'../examples/tutorials/widgets/waveforms_mearec',
4341

4442
]
@@ -101,7 +99,6 @@
10199
import sphinx_rtd_theme
102100

103101
html_theme = "sphinx_rtd_theme"
104-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
105102
except ImportError:
106103
print("RTD theme not installed, using default")
107104
html_theme = 'alabaster'
@@ -110,8 +107,9 @@
110107
# relative to this directory. They are copied after the builtin static files,
111108
# so a file named "default.css" will overwrite the builtin "default.css".
112109
# html_static_path = ['_static']
113-
114-
html_favicon = "images/favicon-32x32.png"
110+
# html_css_files = ['custom.css']
111+
html_favicon = "images/logo.png"
112+
html_logo = "images/logo.png"
115113

116114

117115
from sphinx_gallery.sorting import ExplicitOrder

doc/how_to/load_your_data_into_sorting.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ the requested unit_ids).
6565
6666
# in this case we are making a monosegment sorting
6767
# we have four spikes that are spread among two neurons
68-
my_sorting = NumpySorting.from_times_labels(
69-
times_list=[
68+
my_sorting = NumpySorting.from_samples_and_labels(
69+
samples_list=[
7070
np.array([1000,12000,15000,22000]) # Note these are samples/frames not times in seconds
7171
],
7272
labels_list=[
@@ -120,7 +120,7 @@ Loading multisegment data into a :code:`Sorting`
120120
One of the great advantages of SpikeInterface :code:`Sorting` objects is that they can also handle
121121
multisegment recordings and sortings (e.g. you have a baseline, stimulus, post-stimulus). The
122122
exact same machinery can be used to generate your sorting, but in this case we do a list of arrays instead of
123-
a single list. Let's go through one example for using :code:`from_times_labels`:
123+
a single list. Let's go through one example for using :code:`from_samples_and_labels`:
124124

125125
.. code-block:: python
126126
@@ -130,8 +130,8 @@ a single list. Let's go through one example for using :code:`from_times_labels`:
130130
# in this case we are making three-segment sorting
131131
# we have four spikes that are spread among two neurons
132132
# in each segment
133-
my_sorting = NumpySorting.from_times_labels(
134-
times_list=[
133+
my_sorting = NumpySorting.from_samples_and_labels(
134+
samples_list=[
135135
np.array([1000,12000,15000,22000]),
136136
np.array([30000,33000, 41000, 47000]),
137137
np.array([50000,53000,64000,70000]),

doc/index.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ Welcome to SpikeInterface's documentation!
22
==========================================
33

44

5-
.. image:: images/logo.png
6-
:scale: 100 %
7-
:align: center
8-
9-
105
SpikeInterface is a Python module to analyze extracellular electrophysiology data.
116

127
With a few lines of code, SpikeInterface enables you to load and pre-process the recording, run several

doc/modules/comparison.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ For spike train comparison, there are three use cases:
2626

2727
A ground-truth dataset can be a paired recording, in which a neuron is recorded both extracellularly and with
2828
a patch or juxtacellular electrode (either **in vitro** or **in vivo**), or it can be a simulated dataset
29-
(**in silico**) using spiking activity simulators such as `MEArec`_.
29+
(**in silico**) using spiking activity simulators such as `MEArec <https://github.com/SpikeInterface/MEArec>`_.
3030

3131
The comparison to ground-truth datasets is useful to benchmark spike sorting algorithms.
3232

doc/modules/core.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,13 @@ In this example, we create a recording and a sorting object from numpy objects:
711711
spike_trains += spike_trains_i
712712
labels += labels_i
713713
714-
sorting_memory = NumpySorting.from_times_labels(times=spike_trains, labels=labels,
715-
sampling_frequency=sampling_frequency)
714+
# construct a mono-segment
715+
samples_list = [np.array(spike_trains)]
716+
labels_list = [np.array(labels)]
717+
718+
sorting_memory = NumpySorting.from_samples_and_labels(
719+
samples_list=samples_list, labels_list=labels_list, sampling_frequency=sampling_frequency
720+
)
716721
717722
718723
Any sorting object can be transformed into a :py:class:`~spikeinterface.core.NumpySorting` or

doc/modules/curation.rst

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,31 +120,31 @@ the unit (among the redundant ones), with a better template alignment.
120120
Auto-merging units
121121
^^^^^^^^^^^^^^^^^^
122122

123-
The :py:func:`~spikeinterface.curation.get_potential_auto_merge` function returns a list of potential merges.
123+
The :py:func:`~spikeinterface.curation.compute_merge_unit_groups` function returns a list of potential merges.
124124
The list of potential merges can be then applied to the sorting output.
125-
:py:func:`~spikeinterface.curation.get_potential_auto_merge` has many internal tricks and steps to identify potential
125+
:py:func:`~spikeinterface.curation.compute_merge_unit_groups` has many internal tricks and steps to identify potential
126126
merges. It offers multiple "presets" and the flexibility to apply individual steps, with different parameters.
127127
**Read the function documentation carefully and do not apply it blindly!**
128128

129129

130130
.. code-block:: python
131131
132132
from spikeinterface import create_sorting_analyzer
133-
from spikeinterface.curation import get_potential_auto_merge
133+
from spikeinterface.curation import compute_merge_unit_groups
134134
135135
analyzer = create_sorting_analyzer(sorting=sorting, recording=recording)
136136
137137
# some extensions are required
138138
analyzer.compute(["random_spikes", "templates", "template_similarity", "correlograms"])
139139
140140
# merges is a list of unit pairs, with unit_ids to be merged.
141-
merge_unit_pairs = get_potential_auto_merge(
141+
merge_unit_pairs = compute_merge_unit_groups(
142142
analyzer=analyzer,
143143
preset="similarity_correlograms",
144144
)
145145
# with resolve_graph=True, merges_resolved is a list of merge groups,
146146
# which can contain more than two units
147-
merge_unit_groups = get_potential_auto_merge(
147+
merge_unit_groups = compute_merge_unit_groups(
148148
analyzer=analyzer,
149149
preset="similarity_correlograms",
150150
resolve_graph=True
@@ -153,6 +153,44 @@ merges. It offers multiple "presets" and the flexibility to apply individual ste
153153
# here we apply the merges
154154
analyzer_merged = analyzer.merge_units(merge_unit_groups=merge_unit_groups)
155155
156+
There is also the convenient :py:func:`~spikeinterface.curation.auto_merge_units` function that combines the
157+
:py:func:`~spikeinterface.curation.compute_merge_unit_groups` and :py:func:`~spikeinterface.core.SortingAnalyzer.merge_units` functions.
158+
This is a high level function that allows you to apply either one or several presets/lists of steps in one go. For example, let's
159+
assume you want to apply the "x_contamination" preset, but iteratively and with slightly different parameters: first,
160+
you want to focus on the templates that are very similar, according to their template similarities, before
161+
considering those that might be more distant. Such a greedy and iterative scheme has been proved to be less
162+
prone to wrong merges. To do so, you'll need to do the following:
163+
164+
.. code-block:: python
165+
166+
from spikeinterface import create_sorting_analyzer
167+
from spikeinterface.curation import auto_merge_units
168+
169+
analyzer = create_sorting_analyzer(sorting=sorting, recording=recording)
170+
171+
# some extensions are required
172+
analyzer.compute(["random_spikes", "templates", "template_similarity", "correlograms"])
173+
analyzer.compute("unit_locations", method="monopolar_triangulation")
174+
175+
template_diff_thresh = [0.05, 0.15, 0.25]
176+
presets = ["x_contaminations"] * len(template_diff_thresh)
177+
steps_params = [
178+
{"template_similarity": {"template_diff_thresh": i}}
179+
for i in template_diff_thresh
180+
]
181+
182+
analyzer_merged = auto_merge_units(
183+
analyzer,
184+
presets=presets,
185+
steps_params=steps_params,
186+
recursive=True,
187+
**job_kwargs,
188+
)
189+
190+
The extra keyword ``recursive`` specifies that for each presets/sequences of steps, merges are performed
191+
until no further merges are possible. The ``job_kwargs`` are the parameters for the parallelization.
192+
**Be careful that the merges can not be reverted, so be sure to not erase your analyzer and create a new variable**
193+
156194

157195
Manual curation
158196
---------------

doc/modules/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ Modules documentation
1717
sortingcomponents
1818
motion_correction
1919
generation
20+
benchmark

doc/modules/sorters.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,6 @@ Here is the list of external sorters accessible using the run_sorter wrapper:
474474
* **HDSort** :code:`run_sorter(sorter_name='hdsort')`
475475
* **YASS** :code:`run_sorter(sorter_name='yass')`
476476

477-
Internal Sorters
478-
----------------
479477

480478
Here a list of internal sorter based on `spikeinterface.sortingcomponents`; they are totally
481479
experimental for now:

examples/tutorials/core/plot_2_sorting_extractor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
##############################################################################
4141
# And instantiate a :py:class:`~spikeinterface.core.NumpySorting` object:
4242

43-
sorting = se.NumpySorting.from_times_labels([times0, times1], [labels0, labels1], sampling_frequency)
43+
sorting = se.NumpySorting.from_samples_and_labels([times0, times1], [labels0, labels1], sampling_frequency)
4444
print(sorting)
4545

4646
##############################################################################

0 commit comments

Comments
 (0)