|
3 | 3 | import numpy as np |
4 | 4 | from warnings import warn |
5 | 5 |
|
6 | | -from .base import BaseWidget, to_attr, default_backend_kwargs |
| 6 | +from spikeinterface.core import SortingAnalyzer, BaseSorting |
| 7 | +from .base import BaseWidget, to_attr |
7 | 8 | from .utils import get_some_colors |
8 | 9 |
|
9 | 10 |
|
@@ -278,39 +279,46 @@ class RasterWidget(BaseRasterWidget): |
278 | 279 |
|
279 | 280 | Parameters |
280 | 281 | ---------- |
281 | | - sorting : SortingExtractor | None, default: None |
282 | | - A sorting object |
283 | | - sorting_analyzer : SortingAnalyzer | None, default: None |
284 | | - A sorting analyzer object |
285 | | - segment_index : None or int |
286 | | - The segment index. |
287 | | - unit_ids : list |
288 | | - List of unit ids |
289 | | - time_range : list |
| 282 | + sorting_analyzer_or_sorting : SortingAnalyzer | BaseSorting | None, default: None |
| 283 | + The object containing the sorting information for the raster plot |
| 284 | + segment_index : None | int, default: None |
| 285 | + The segment index. If None, uses first segment. |
| 286 | + unit_ids : list | None, default: None |
| 287 | + List of unit ids. If None, uses all unit ids. |
| 288 | + time_range : list | None, default: None |
290 | 289 | List with start time and end time |
291 | | - color : matplotlib color |
| 290 | + color : matplotlib color, default: "k" |
292 | 291 | The color to be used |
| 292 | + sorting : SortingExtractor | None, default: None |
| 293 | + A sorting object. Deprecated. |
| 294 | + sorting_analyzer : SortingAnalyzer | None, default: None |
| 295 | + A sorting analyzer object. Deprecated. |
293 | 296 | """ |
294 | 297 |
|
295 | 298 | def __init__( |
296 | 299 | self, |
297 | | - sorting=None, |
298 | | - sorting_analyzer=None, |
299 | | - segment_index=None, |
300 | | - unit_ids=None, |
301 | | - time_range=None, |
| 300 | + sorting_analyzer_or_sorting: SortingAnalyzer | BaseSorting | None = None, |
| 301 | + segment_index: int | None = None, |
| 302 | + unit_ids: list | None = None, |
| 303 | + time_range: list | None = None, |
302 | 304 | color="k", |
303 | | - backend=None, |
| 305 | + backend: str | None = None, |
| 306 | + sorting: BaseSorting | None = None, |
| 307 | + sorting_analyzer: SortingAnalyzer | None = None, |
304 | 308 | **backend_kwargs, |
305 | 309 | ): |
306 | | - if sorting is None and sorting_analyzer is None: |
307 | | - raise Exception("Must supply either a sorting or a sorting_analyzer") |
308 | | - elif sorting is not None and sorting_analyzer is not None: |
309 | | - raise Exception("Should supply either a sorting or a sorting_analyzer, not both") |
310 | | - elif sorting_analyzer is not None: |
311 | | - sorting = sorting_analyzer.sorting |
312 | | - |
313 | | - sorting = self.ensure_sorting(sorting) |
| 310 | + |
| 311 | + if sorting is not None: |
| 312 | + # When removed, make `sorting_analyzer_or_sorting` a required argument rather than None. |
| 313 | + deprecation_msg = "`sorting` argument is deprecated and will be removed in version 0.105.0. Please use `sorting_analyzer_or_sorting` instead" |
| 314 | + warn(deprecation_msg, category=DeprecationWarning, stacklevel=2) |
| 315 | + sorting_analyzer_or_sorting = sorting |
| 316 | + if sorting_analyzer is not None: |
| 317 | + deprecation_msg = "`sorting_analyzer` argument is deprecated and will be removed in version 0.105.0. Please use `sorting_analyzer_or_sorting` instead" |
| 318 | + warn(deprecation_msg, category=DeprecationWarning, stacklevel=2) |
| 319 | + sorting_analyzer_or_sorting = sorting_analyzer |
| 320 | + |
| 321 | + sorting = self.ensure_sorting(sorting_analyzer_or_sorting) |
314 | 322 |
|
315 | 323 | if sorting.get_num_segments() > 1: |
316 | 324 | if segment_index is None: |
|
0 commit comments