Skip to content

Commit bf81f92

Browse files
committed
Add sa_or_sort to ISIDistributionWidget
1 parent 2914abd commit bf81f92

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

src/spikeinterface/widgets/isi_distribution.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import numpy as np
44
from warnings import warn
55

6+
from spikeinterface.core import SortingAnalyzer, BaseSorting
7+
68
from .base import BaseWidget, to_attr
7-
from .utils import get_unit_colors
89

910

1011
class ISIDistributionWidget(BaseWidget):
@@ -13,8 +14,10 @@ class ISIDistributionWidget(BaseWidget):
1314
1415
Parameters
1516
----------
16-
sorting : SortingExtractor
17-
The sorting extractor object
17+
sorting_analyzer_or_sorting : SortingAnalyzer | BaseSorting | None = None
18+
The object containing the sorting information for the isi distribution plo
19+
sorting : BaseSorting | None = None
20+
Deprecated argument.
1821
unit_ids : list
1922
List of unit ids
2023
bins_ms : int
@@ -24,7 +27,30 @@ class ISIDistributionWidget(BaseWidget):
2427
2528
"""
2629

27-
def __init__(self, sorting, unit_ids=None, window_ms=100.0, bin_ms=1.0, backend=None, **backend_kwargs):
30+
def __init__(
31+
self,
32+
sorting_analyzer_or_sorting: SortingAnalyzer | BaseSorting | None = None,
33+
sorting: BaseSorting | None = None,
34+
unit_ids: list | None = None,
35+
window_ms: float = 100.0,
36+
bin_ms: float = 1.0,
37+
backend: str | None = None,
38+
**backend_kwargs,
39+
):
40+
41+
if sorting is not None:
42+
# When removed, make `sorting_analyzer_or_sorting` a required argument rather than None.
43+
deprecation_msg = "`sorting` argument is deprecated and will be removed in version 0.105.0. Please use `sorting_analyzer_or_sorting` instead"
44+
warn(deprecation_msg, category=DeprecationWarning, stacklevel=2)
45+
sorting_analyzer_or_sorting = sorting
46+
47+
if isinstance(sorting_analyzer_or_sorting, SortingAnalyzer):
48+
sorting = sorting_analyzer_or_sorting.sorting
49+
elif isinstance(sorting_analyzer_or_sorting, BaseSorting):
50+
sorting = sorting_analyzer_or_sorting
51+
else:
52+
raise TypeError("`plot_isis_distribution` expects a `SortingAnalyzer` or a `Sorting`.")
53+
2854
if unit_ids is None:
2955
unit_ids = sorting.get_unit_ids()
3056

0 commit comments

Comments
 (0)