Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6dd7269
Try to remove get_template_extremum_channel()
samuelgarcia Feb 6, 2026
eede722
Put main_channel_peak_sign and main_channel_peak_mode in analyzer set…
samuelgarcia Feb 6, 2026
e7a32b5
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
samuelgarcia Feb 17, 2026
7b6a109
continue the tedious refactoring
samuelgarcia Feb 17, 2026
99da9a1
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
samuelgarcia Mar 25, 2026
84e8d37
wip peak sign remove
samuelgarcia Mar 25, 2026
413a907
Merge remote-tracking branch 'origin/main' into less_peak_sign_more_m…
chrishalcrow Jun 23, 2026
91206ac
Change Template's default for get_main_channels output format
chrishalcrow Jun 23, 2026
6e00b92
get most tests passing
chrishalcrow Jun 23, 2026
a51a24f
Make main_channel_index a property
chrishalcrow Jun 23, 2026
0b81eb0
get waveform extractor working
chrishalcrow Jun 23, 2026
49b5199
fix 3d channel stuff
chrishalcrow Jun 23, 2026
72e2ced
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 23, 2026
01e2b22
2d 3d channel locations fix
chrishalcrow Jun 23, 2026
1895255
fix more bugs
chrishalcrow Jun 23, 2026
978d490
more bug fixes
chrishalcrow Jun 24, 2026
c09f8cb
deprecation warnings and return_to_uv None in template functions
chrishalcrow Jun 24, 2026
2df4187
change main_channel_peak_sign to peak_sign
chrishalcrow Jun 24, 2026
94b4372
good grouping for make_sorting_analyzer in tests
chrishalcrow Jun 24, 2026
b61bebf
respond to Erick
chrishalcrow Jun 25, 2026
a391558
oups
chrishalcrow Jun 25, 2026
61b790b
Remove peak_sign and peak_mode from compute_sparsity (were not being
chrishalcrow Jun 25, 2026
f84f1f7
Merge branch 'main' into less_peak_sign_more_main_channel
chrishalcrow Jun 25, 2026
ec6fac3
Remove more peak_amplitude from compute_sparsity
chrishalcrow Jun 25, 2026
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
1 change: 0 additions & 1 deletion src/spikeinterface/benchmark/benchmark_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from spikeinterface.core.job_tools import fix_job_kwargs, split_job_kwargs
from .benchmark_base import Benchmark, BenchmarkStudy, MixinStudyUnitCount
from spikeinterface.core.sortinganalyzer import create_sorting_analyzer
from spikeinterface.core.template_tools import get_template_extremum_channel


class ClusteringBenchmark(Benchmark):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

from spikeinterface.benchmark.tests.common_benchmark_testing import make_dataset
from spikeinterface.benchmark.benchmark_clustering import ClusteringStudy
from spikeinterface.core.sortinganalyzer import create_sorting_analyzer
from spikeinterface.core.template_tools import get_template_extremum_channel

from pathlib import Path

Expand All @@ -33,7 +31,8 @@ def test_benchmark_clustering(create_cache_folder):

# sorting_analyzer = create_sorting_analyzer(gt_sorting, recording, format="memory", sparse=False)
# sorting_analyzer.compute(["random_spikes", "templates"])
extremum_channel_inds = get_template_extremum_channel(gt_analyzer, outputs="index")
extremum_channel_inds = gt_analyzer.get_main_channels(outputs="index", with_dict=True)

spikes = gt_analyzer.sorting.to_spike_vector(extremum_channel_inds=extremum_channel_inds)
peaks[dataset] = spikes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_benchmark_matching(create_cache_folder):
recording, gt_sorting, ms_before=2.0, ms_after=3.0, return_in_uV=False, **job_kwargs
)
noise_levels = get_noise_levels(recording, **job_kwargs)
sparsity = compute_sparsity(gt_templates, noise_levels, method="snr", amplitude_mode="peak_to_peak", threshold=0.25)
sparsity = compute_sparsity(gt_templates, noise_levels, method="snr", threshold=0.25)
gt_templates = gt_templates.to_sparse(sparsity)

# create study
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from spikeinterface.benchmark.tests.common_benchmark_testing import make_dataset
from spikeinterface.benchmark.benchmark_peak_detection import PeakDetectionStudy
from spikeinterface.core.sortinganalyzer import create_sorting_analyzer
from spikeinterface.core.template_tools import get_template_extremum_channel


@pytest.mark.skip()
Expand All @@ -30,7 +29,7 @@ def test_benchmark_peak_detection(create_cache_folder):
sorting_analyzer = create_sorting_analyzer(gt_sorting, recording, format="memory", sparse=False, **job_kwargs)
sorting_analyzer.compute("random_spikes")
sorting_analyzer.compute("templates", **job_kwargs)
extremum_channel_inds = get_template_extremum_channel(sorting_analyzer, outputs="index")
extremum_channel_inds = sorting_analyzer.get_main_channels(outputs="index", with_dict=True)
spikes = gt_sorting.to_spike_vector(extremum_channel_inds=extremum_channel_inds)
peaks[dataset] = spikes

Expand Down
9 changes: 6 additions & 3 deletions src/spikeinterface/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@
# template tools
from .template_tools import (
get_template_amplitudes,
get_template_extremum_channel,
get_template_extremum_channel_peak_shift,
get_template_extremum_amplitude,
get_template_main_channel_peak_shift,
get_template_main_channel_amplitude,
# this is not needed anymore
get_template_extremum_channel, # keep for backward compatibility can be removed in 0.105
get_template_extremum_channel_peak_shift, # keep for backward compatibility can be removed in 0.105
get_template_extremum_amplitude, # keep for backward compatibility can be removed in 0.105
)


Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/core/analyzer_extension_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class ComputeTemplates(AnalyzerExtension):

extension_name = "templates"
depend_on = ["random_spikes|waveforms"]
need_recording = True
need_recording = False

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have waveforms, you do not need the Recording. Not sure how to deal with this.

use_nodepipeline = False
need_job_kwargs = True
need_backward_compatibility_on_load = True
Expand Down
8 changes: 7 additions & 1 deletion src/spikeinterface/core/basesorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class BaseSorting(BaseExtractor):
Abstract class representing several segment several units and relative spiketrains.
"""

_main_properties = [
"main_channel_index",
]

def __init__(self, sampling_frequency: float, unit_ids: list):
BaseExtractor.__init__(self, unit_ids)
self._sampling_frequency = float(sampling_frequency)
Expand Down Expand Up @@ -913,6 +917,7 @@ def _compute_and_cache_spike_vector(self) -> None:
self._cached_spike_vector = spikes
self._cached_spike_vector_segment_slices = segment_slices

# TODO sam : change extremum_channel_inds to main_channel_index with vector
def to_spike_vector(
self,
concatenated=True,
Expand All @@ -933,7 +938,8 @@ def to_spike_vector(
extremum_channel_inds : None or dict, default: None
If a dictionnary of unit_id to channel_ind is given then an extra field "channel_index".
This can be convinient for computing spikes postion after sorter.
This dict can be computed with `get_template_extremum_channel(we, outputs="index")`
This dict can be given by analyzer.get_main_channels(outputs="index", with_dict=True)

use_cache : bool, default: True
When True the spikes vector is cached as an attribute of the object (`_cached_spike_vector`).
This caching only occurs when extremum_channel_inds=None.
Expand Down
4 changes: 4 additions & 0 deletions src/spikeinterface/core/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,10 @@ def generate_ground_truth_recording(
**generate_templates_kwargs,
)
sorting.set_property("gt_unit_locations", unit_locations)
distances = np.linalg.norm(unit_locations[:, np.newaxis, :2] - channel_locations[np.newaxis, :, :2], axis=2)
main_channel_index = np.argmin(distances, axis=1)
sorting.set_property("main_channel_index", main_channel_index)

else:
assert templates.shape[0] == num_units

Expand Down
3 changes: 3 additions & 0 deletions src/spikeinterface/core/node_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def compute(self, traces, start_frame, end_frame, segment_index, max_margin, pea
return (local_peaks,)


# TODO sam replace extremum_channels_indices by main_channel_index


# this is not implemented yet this will be done in separted PR
class SpikeRetriever(PeakSource):
"""
Expand Down
Loading
Loading