Skip to content

Commit 59c6571

Browse files
committed
warn for multi-segment
1 parent 6e22a6a commit 59c6571

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/spikeinterface/widgets/amplitudes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ def __init__(
7373
if unit_ids is None:
7474
unit_ids = sorting.unit_ids
7575

76+
if sorting.get_num_segments() > 1:
77+
if segment_index is None:
78+
warn("More than one segment available! Using `segment_index = 0`.")
79+
segment_index = 0
80+
else:
81+
segment_index = 0
82+
7683
amplitudes_segment = amplitudes[segment_index]
7784
total_duration = sorting_analyzer.get_num_samples(segment_index) / sorting_analyzer.sampling_frequency
7885

src/spikeinterface/widgets/rasters.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,19 @@ def __init__(
305305
):
306306
if sorting is None and sorting_analyzer is None:
307307
raise Exception("Must supply either a sorting or a sorting_analyzer")
308-
if sorting is not None and sorting_analyzer is not None:
308+
elif sorting is not None and sorting_analyzer is not None:
309309
raise Exception("Should supply either a sorting or a sorting_analyzer, not both")
310-
if sorting_analyzer is not None:
310+
elif sorting_analyzer is not None:
311311
sorting = sorting_analyzer.sorting
312312

313313
sorting = self.ensure_sorting(sorting)
314314

315-
if segment_index is None and sorting.get_num_segments() != 1:
316-
raise ValueError("You must provide segment_index=...")
315+
if sorting.get_num_segments() > 1:
316+
if segment_index is None:
317+
warn("More than one segment available! Using `segment_index = 0`.")
318+
segment_index = 0
319+
else:
320+
segment_index = 0
317321

318322
if unit_ids is None:
319323
unit_ids = sorting.unit_ids

0 commit comments

Comments
 (0)