Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3dc5729
Test IBL extractors tests failing for PI update
alejoe91 Dec 29, 2025
d1a0532
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Jan 6, 2026
33c6769
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Jan 16, 2026
2c94bac
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Jan 20, 2026
a412bd8
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Feb 2, 2026
504e19d
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Feb 12, 2026
cd09c19
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Feb 19, 2026
a40d073
Merge branch 'main' of github.com:alejoe91/spikeinterface
alejoe91 Feb 24, 2026
a1da327
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 2, 2026
ef19a8e
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 3, 2026
a098b51
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 6, 2026
61c317a
Fix OpenEphys tests
alejoe91 Mar 6, 2026
c9ff247
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 9, 2026
3520138
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 16, 2026
f61329d
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 16, 2026
d64ae6a
Merge branch 'main' of github.com:alejoe91/spikeinterface
alejoe91 Mar 16, 2026
ef40b73
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 17, 2026
aef197d
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 17, 2026
e82331b
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 20, 2026
710cb6f
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 23, 2026
c2f8db1
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 23, 2026
11c5812
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 24, 2026
ada53f8
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 24, 2026
22ff8fd
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 25, 2026
161d25b
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 27, 2026
1d09ec6
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 30, 2026
afb7d33
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 30, 2026
fa556ba
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 30, 2026
cbc36de
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Mar 31, 2026
6b3e373
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Apr 9, 2026
8e68f16
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Apr 14, 2026
1c80910
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Apr 14, 2026
7eb2251
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Apr 16, 2026
5eff246
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Apr 17, 2026
b6ee0e8
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Apr 20, 2026
2e0de80
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Apr 21, 2026
e880394
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Apr 21, 2026
37a40b9
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 Apr 22, 2026
f8a97d9
Merge branch 'main' of github.com:alejoe91/spikeinterface
alejoe91 Apr 22, 2026
66f7636
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 May 4, 2026
450e87e
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 May 6, 2026
acc027c
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 May 11, 2026
73359a7
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 May 15, 2026
a06b4fc
Merge branch 'main' of github.com:alejoe91/spikeinterface
alejoe91 May 20, 2026
f09655f
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 May 20, 2026
7144c19
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 May 26, 2026
d52575d
Merge branch 'main' of github.com:SpikeInterface/spikeinterface
alejoe91 May 27, 2026
1c29d0e
fix: store use_valid_periods in quality_metrics params
alejoe91 May 27, 2026
a321af2
fix: check if periods and valid periods are match
alejoe91 May 27, 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
9 changes: 7 additions & 2 deletions src/spikeinterface/metrics/quality/quality_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from spikeinterface.core.template_tools import get_template_extremum_channel
from spikeinterface.core.sortinganalyzer import register_result_extension
from spikeinterface.core.analyzer_extension_core import BaseMetricExtension
from spikeinterface.core.sorting_tools import cast_periods_to_unit_period_dtype

from .misc_metrics import misc_metrics_list
from .pca_metrics import pca_metrics_list
Expand Down Expand Up @@ -115,15 +116,19 @@ def _set_params(
metric_names = [m for m in metric_names if m not in pc_metric_names]

if use_valid_periods:
valid_periods = self.sorting_analyzer.get_extension("valid_unit_periods").get_data(outputs="numpy")
if periods is not None:
raise ValueError("If use_valid_periods is True, periods should not be provided.")
periods = self.sorting_analyzer.get_extension("valid_unit_periods").get_data(outputs="numpy")
provided_periods = cast_periods_to_unit_period_dtype(np.asarray(periods))
Comment on lines 120 to +121
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a reason for allowing the user to pass use_valid_periods and periods now? Something to do with reloading??

if not np.array_equal(valid_periods, provided_periods):
raise ValueError("Provided periods do not match valid periods from the sorting analyzer.")
periods = valid_periods

return super()._set_params(
metric_names=metric_names,
metric_params=metric_params,
delete_existing_metrics=delete_existing_metrics,
metrics_to_compute=metrics_to_compute,
use_valid_periods=use_valid_periods,
periods=periods,
peak_sign=peak_sign,
seed=seed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_quality_metrics_with_periods():
seed=2205,
)

# test failure when both periods and use_valid_periods are set
# test failure when periods and valid_unit_periods do not match
with pytest.raises(ValueError):
compute_quality_metrics(
sorting_analyzer,
Expand All @@ -229,6 +229,17 @@ def test_quality_metrics_with_periods():
seed=2205,
)

# should not fail if external periods are the same as valid unit periods
valid_periods = sorting_analyzer.get_extension("valid_unit_periods").get_data(outputs="numpy")
metrics_ext_periods = compute_quality_metrics(
sorting_analyzer,
metric_names=None,
skip_pc_metrics=True,
use_valid_periods=True,
periods=valid_periods,
seed=2205,
)

# test failure if use valid_periods is True but valid_unit_periods extension is missing
sorting_analyzer.delete_extension("valid_unit_periods")
with pytest.raises(AssertionError):
Expand Down
Loading