Skip to content

Commit

Permalink
Remove mearec from testing functions (#2930)
Browse files Browse the repository at this point in the history
* Replace mearec with lazy sorting in testing

* Update curations tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* changed gh uri

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
chrishalcrow and pre-commit-ci[bot] authored May 31, 2024
1 parent f925c44 commit 5715d53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/spikeinterface/curation/tests/sv-sorting-curation.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"labelsByUnit":{"#2":["mua"],"#3":["mua"],"#4":["mua"],"#5":["accept"],"#6":["accept"],"#7":["accept"],"#8":["artifact"],"#9":["artifact"]},"mergeGroups":[["#8","#9"]]}
{"labelsByUnit":{"2":["mua"],"3":["mua"],"4":["mua"],"5":["accept"],"6":["accept"],"7":["accept"],"8":["artifact"],"9":["artifact"]},"mergeGroups":[[8,9]]}
27 changes: 11 additions & 16 deletions src/spikeinterface/curation/tests/test_sortingview_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import numpy as np

import spikeinterface as si
from spikeinterface.core import generate_sorting
import spikeinterface.extractors as se
from spikeinterface.extractors import read_mearec
from spikeinterface import set_global_tmp_folder
from spikeinterface.postprocessing import (
compute_correlograms,
Expand Down Expand Up @@ -34,8 +34,6 @@
# def generate_sortingview_curation_dataset():
# import spikeinterface.widgets as sw

# local_path = si.download_dataset(remote_path="mearec/mearec_test_10s.h5")
# recording, sorting = read_mearec(local_path)

# sorting_analyzer = si.create_sorting_analyzer(sorting, recording, format="memory")
# sorting_analyzer.compute("random_spikes")
Expand All @@ -50,23 +48,22 @@
# w = sw.plot_sorting_summary(sorting_analyzer, curation=True, backend="sortingview")

# # curation_link:
# # https://figurl.org/f?v=gs://figurl/spikesortingview-10&d=sha1://bd53f6b707f8121cadc901562a89b67aec81cc81&label=SpikeInterface%20-%20Sorting%20Summary
# # https://figurl.org/f?v=npm://@fi-sci/figurl-sortingview@12/dist&d=sha1://058ab901610aa9d29df565595a3cc2a81a1b08e5


@pytest.mark.skipif(ON_GITHUB and not KACHERY_CLOUD_SET, reason="Kachery cloud secrets not available")
def test_gh_curation():
"""
Test curation using GitHub URI.
"""
local_path = si.download_dataset(remote_path="mearec/mearec_test_10s.h5")
_, sorting = read_mearec(local_path)
sorting = generate_sorting(num_units=10)
# curated link:
# https://figurl.org/f?v=gs://figurl/spikesortingview-10&d=sha1://bd53f6b707f8121cadc901562a89b67aec81cc81&label=SpikeInterface%20-%20Sorting%20Summary&s={%22sortingCuration%22:%22gh://alejoe91/spikeinterface/fix-codecov/spikeinterface/curation/tests/sv-sorting-curation.json%22}
# https://figurl.org/f?v=npm://@fi-sci/figurl-sortingview@12/dist&d=sha1://058ab901610aa9d29df565595a3cc2a81a1b08e5
gh_uri = "gh://SpikeInterface/spikeinterface/main/src/spikeinterface/curation/tests/sv-sorting-curation.json"
sorting_curated_gh = apply_sortingview_curation(sorting, uri_or_json=gh_uri, verbose=True)

assert len(sorting_curated_gh.unit_ids) == 9
assert "#8-#9" in sorting_curated_gh.unit_ids
assert 1, 2 in sorting_curated_gh.unit_ids
assert "accept" in sorting_curated_gh.get_property_keys()
assert "mua" in sorting_curated_gh.get_property_keys()
assert "artifact" in sorting_curated_gh.get_property_keys()
Expand All @@ -86,18 +83,17 @@ def test_sha1_curation():
"""
Test curation using SHA1 URI.
"""
local_path = si.download_dataset(remote_path="mearec/mearec_test_10s.h5")
_, sorting = read_mearec(local_path)
sorting = generate_sorting(num_units=10)

# from SHA1
# curated link:
# https://figurl.org/f?v=gs://figurl/spikesortingview-10&d=sha1://bd53f6b707f8121cadc901562a89b67aec81cc81&label=SpikeInterface%20-%20Sorting%20Summary&s={%22sortingCuration%22:%22sha1://1182ba19671fcc7d3f8e0501b0f8c07fb9736c22%22}
sha1_uri = "sha1://1182ba19671fcc7d3f8e0501b0f8c07fb9736c22"
# https://figurl.org/f?v=npm://@fi-sci/figurl-sortingview@12/dist&d=sha1://058ab901610aa9d29df565595a3cc2a81a1b08e5
sha1_uri = "sha1://449a428e8824eef9ad9bcc3241e45a2cee02d381"
sorting_curated_sha1 = apply_sortingview_curation(sorting, uri_or_json=sha1_uri, verbose=True)
# print(f"From SHA: {sorting_curated_sha1}")

assert len(sorting_curated_sha1.unit_ids) == 9
assert "#8-#9" in sorting_curated_sha1.unit_ids
assert 1, 2 in sorting_curated_sha1.unit_ids
assert "accept" in sorting_curated_sha1.get_property_keys()
assert "mua" in sorting_curated_sha1.get_property_keys()
assert "artifact" in sorting_curated_sha1.get_property_keys()
Expand All @@ -116,16 +112,15 @@ def test_json_curation():
"""
Test curation using a JSON file.
"""
local_path = si.download_dataset(remote_path="mearec/mearec_test_10s.h5")
_, sorting = read_mearec(local_path)
sorting = generate_sorting(num_units=10)

# from curation.json
json_file = parent_folder / "sv-sorting-curation.json"
# print(f"Sorting: {sorting.get_unit_ids()}")
sorting_curated_json = apply_sortingview_curation(sorting, uri_or_json=json_file, verbose=True)

assert len(sorting_curated_json.unit_ids) == 9
assert "#8-#9" in sorting_curated_json.unit_ids
assert 1, 2 in sorting_curated_json.unit_ids
assert "accept" in sorting_curated_json.get_property_keys()
assert "mua" in sorting_curated_json.get_property_keys()
assert "artifact" in sorting_curated_json.get_property_keys()
Expand Down

0 comments on commit 5715d53

Please sign in to comment.