Skip to content

Commit

Permalink
Merge pull request #3309 from rkim48/sortingview-curation-fix
Browse files Browse the repository at this point in the history
Fix sortingview curation no merge case
  • Loading branch information
alejoe91 authored Aug 20, 2024
2 parents be0fd8a + b6316b5 commit 77d9eaf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/spikeinterface/curation/curation_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ def convert_from_sortingview_curation_format_v0(sortingview_dict, destination_fo
"""

assert destination_format == "1"

if "mergeGroups" not in sortingview_dict.keys():
sortingview_dict["mergeGroups"] = []
merge_groups = sortingview_dict["mergeGroups"]
merged_units = sum(merge_groups, [])
if len(merged_units) > 0:
unit_id_type = int if isinstance(merged_units[0], int) else str

first_unit_id = next(iter(sortingview_dict["labelsByUnit"].keys()))
if str.isdigit(first_unit_id):
unit_id_type = int
else:
unit_id_type = str

all_units = []
all_labels = []
manual_labels = []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"labelsByUnit":{"2":["mua"],"3":["mua"],"4":["mua"],"5":["accept"],"6":["accept"],"7":["accept"],"8":["artifact"],"9":["artifact"]}}
12 changes: 12 additions & 0 deletions src/spikeinterface/curation/tests/test_sortingview_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,23 @@ def test_label_inheritance_str():
assert np.all(sorting_include_accept.get_property("accept"))


def test_json_no_merge_curation():
"""
Test curation with no merges using a JSON file.
"""
sorting = generate_sorting(num_units=10)

json_file = parent_folder / "sv-sorting-curation-no-merge.json"
sorting_curated = apply_sortingview_curation(sorting, uri_or_json=json_file)


if __name__ == "__main__":
# generate_sortingview_curation_dataset()
# test_sha1_curation()

test_gh_curation()
test_json_curation()
test_false_positive_curation()
test_label_inheritance_int()
test_label_inheritance_str()
test_json_no_merge_curation()

0 comments on commit 77d9eaf

Please sign in to comment.