Skip to content

Commit

Permalink
Change Curation to CurationV1
Browse files Browse the repository at this point in the history
  • Loading branch information
khl02007 committed Oct 9, 2023
1 parent 4d9b772 commit 59c16c5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
22 changes: 12 additions & 10 deletions src/spyglass/spikesorting/v1/curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def insert_curation(
description: str = "",
):
"""Given a sorting_id and the parent_sorting_id (and optional
arguments) insert an entry into Curation.
arguments) insert an entry into CurationV1.
Parameters
----------
Expand Down Expand Up @@ -76,16 +76,18 @@ def insert_curation(
parent_curation_id = -1
# check to see if this sorting with a parent of -1 has already been inserted and if so, warn the user
if (
len((Curation & [sorting_id, parent_curation_id]).fetch("KEY"))
len(
(CurationV1 & [sorting_id, parent_curation_id]).fetch("KEY")
)
> 0
):
Warning(f"Sorting has already been inserted.")
return (Curation & [sorting_id, parent_curation_id]).fetch(
return (CurationV1 & [sorting_id, parent_curation_id]).fetch(
"KEY"
)

# generate curation ID
existing_curation_ids = (Curation & sorting_id).fetch("curation_id")
existing_curation_ids = (CurationV1 & sorting_id).fetch("curation_id")
if len(existing_curation_ids) > 0:
curation_id = max(existing_curation_ids) + 1
else:
Expand Down Expand Up @@ -116,7 +118,7 @@ def insert_curation(
"merges_applied": str(apply_merge),
"description": description,
}
Curation.insert1(key, skip_duplicates=True)
CurationV1.insert1(key, skip_duplicates=True)

return key

Expand All @@ -127,7 +129,7 @@ def get_recording(key: dict) -> si.BaseRecording:
Parameters
----------
key : dict
primary key of Curation table
primary key of CurationV1 table
"""

recording_id = (SpikeSorting & key).fetch1("recording_id")
Expand All @@ -150,15 +152,15 @@ def get_sorting(key: dict) -> si.BaseSorting:
Parameters
----------
key : dict
primary key of Curation table
primary key of CurationV1 table
Returns
-------
sorting : si.BaseSorting
"""

analysis_file_name = (Curation & key).fetch1("analysis_file_name")
analysis_file_name = (CurationV1 & key).fetch1("analysis_file_name")
analysis_file_abs_path = AnalysisNwbfile.get_abs_path(
analysis_file_name
)
Expand All @@ -173,14 +175,14 @@ def get_merged_sorting(key: dict) -> si.BaseSorting:
Parameters
----------
key : dict
Curation key
CurationV1 key
Returns
-------
sorting : si.BaseSorting
"""
curation_key = (Curation & key).fetch1()
curation_key = (CurationV1 & key).fetch1()

sorting_analysis_file_abs_path = AnalysisNwbfile.get_abs_path(
curation_key["analysis_file_name"]
Expand Down
18 changes: 9 additions & 9 deletions src/spyglass/spikesorting/v1/figurl_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from spyglass.common.common_nwbfile import AnalysisNwbfile
from spyglass.spikesorting.v1.sorting import SpikeSorting
from spyglass.spikesorting.v1.curation import Curation, _merge_dict_to_list
from spyglass.spikesorting.v1.curation import CurationV1, _merge_dict_to_list

import kachery_cloud as kcl
import sortingview.views as vv
Expand All @@ -19,21 +19,21 @@
@schema
class FigURLCurationSelection(dj.Manual):
definition = """
-> Curation
-> CurationV1
curation_uri: varchar(1000) = NULL # kachery-cloud URI to sorting curation
metrics_figurl: longblob # metrics to display in the figURL
"""

@staticmethod
def generate_curation_uri(key: Dict) -> str:
"""Generates a kachery-cloud URI containing curation info from a row in Curation table
"""Generates a kachery-cloud URI containing curation info from a row in CurationV1 table
Parameters
----------
key : dict
primary key from Curation
primary key from CurationV1
"""
curation_key = (Curation & key).fetch1()
curation_key = (CurationV1 & key).fetch1()
analysis_file_abs_path = AnalysisNwbfile.get_abs_path(
curation_key["analysis_file_name"]
)
Expand Down Expand Up @@ -81,18 +81,18 @@ class FigURLCuration(dj.Computed):

def make(self, key: dict):
# FETCH
sorting_analysis_file_name = (Curation & key).fetch1(
sorting_analysis_file_name = (CurationV1 & key).fetch1(
"analysis_file_name"
)
object_id = (Curation & key).fetch1("object_id")
object_id = (CurationV1 & key).fetch1("object_id")
recording_label = (SpikeSorting & key).fetch1("recording_id")

# DO
sorting_analysis_file_abs_path = AnalysisNwbfile.get_abs_path(
sorting_analysis_file_name
)
recording = Curation.get_recording(key)
sorting = Curation.get_sorting(key)
recording = CurationV1.get_recording(key)
sorting = CurationV1.get_sorting(key)
sorting_label = key["sorting_id"]
curation_uri = key["curation_uri"]

Expand Down
8 changes: 4 additions & 4 deletions src/spyglass/spikesorting/v1/metric_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from spyglass.spikesorting.v1.recording import SpikeSortingRecording
from spyglass.spikesorting.v1.sorting import SpikeSorting
from spyglass.spikesorting.v1.curation import (
Curation,
CurationV1,
_list_to_merge_dict,
_merge_dict_to_list,
)
Expand Down Expand Up @@ -160,7 +160,7 @@ def insert_default(cls):
@schema
class MetricCurationSelection(dj.Manual):
definition = """
-> Curation
-> CurationV1
-> WaveformParameter
-> MetricParameter
-> MetricCurationParameter
Expand Down Expand Up @@ -194,8 +194,8 @@ def make(self, key):
nwb_file_name=nwb_file_name, initial="MC", len_uuid=6
)
# load recording and sorting
recording = Curation.get_recording(key)
sorting = Curation.get_sorting(key)
recording = CurationV1.get_recording(key)
sorting = CurationV1.get_sorting(key)
# extract waveforms
if "whiten" in waveform_param:
if waveform_param.pop("whiten"):
Expand Down
2 changes: 1 addition & 1 deletion src/spyglass/spikesorting/v1/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def get_recording(cls, key: dict) -> si.BaseRecording:
Parameters
----------
key : dict
primary key of Curation table
primary key of SpikeSorting table
"""

analysis_file_name = (cls & key).fetch1("analysis_file_name")
Expand Down

0 comments on commit 59c16c5

Please sign in to comment.