Skip to content

Commit cead752

Browse files
committed
Fix empty merge_unit_groups
1 parent 0deac03 commit cead752

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

src/spikeinterface/curation/curation_format.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def apply_curation_labels(sorting, new_unit_ids, curation_dict):
242242
all_values = np.zeros(sorting.unit_ids.size, dtype=values.dtype)
243243
for unit_ind, unit_id in enumerate(sorting.unit_ids):
244244
if unit_id not in new_unit_ids:
245-
ind = curation_dict["unit_ids"].index(unit_id)
245+
ind = list(curation_dict["unit_ids"]).index(unit_id)
246246
all_values[unit_ind] = values[ind]
247247
sorting.set_property(key, all_values)
248248

@@ -343,18 +343,22 @@ def apply_curation(
343343

344344
elif isinstance(sorting_or_analyzer, SortingAnalyzer):
345345
analyzer = sorting_or_analyzer
346-
analyzer = analyzer.remove_units(curation_dict["removed_units"])
347-
analyzer, new_unit_ids = analyzer.merge_units(
348-
curation_dict["merge_unit_groups"],
349-
censor_ms=censor_ms,
350-
merging_mode=merging_mode,
351-
sparsity_overlap=sparsity_overlap,
352-
new_id_strategy=new_id_strategy,
353-
return_new_unit_ids=True,
354-
format="memory",
355-
verbose=verbose,
356-
**job_kwargs,
357-
)
346+
if len(curation_dict["removed_units"]) > 0:
347+
analyzer = analyzer.remove_units(curation_dict["removed_units"])
348+
if len(curation_dict["merge_unit_groups"]) > 0:
349+
analyzer, new_unit_ids = analyzer.merge_units(
350+
curation_dict["merge_unit_groups"],
351+
censor_ms=censor_ms,
352+
merging_mode=merging_mode,
353+
sparsity_overlap=sparsity_overlap,
354+
new_id_strategy=new_id_strategy,
355+
return_new_unit_ids=True,
356+
format="memory",
357+
verbose=verbose,
358+
**job_kwargs,
359+
)
360+
else:
361+
new_unit_ids = []
358362
apply_curation_labels(analyzer.sorting, new_unit_ids, curation_dict)
359363
return analyzer
360364
else:

0 commit comments

Comments
 (0)