Bases: SpyglassMixin
, Computed
Source code in src/spyglass/spikesorting/v0/curation_figurl.py
| @schema
class CurationFigurl(SpyglassMixin, dj.Computed):
definition = """
-> CurationFigurlSelection
---
url: varchar(2000)
initial_curation_uri: varchar(2000)
new_curation_uri: varchar(2000)
"""
def make(self, key: dict):
"""Create a Curation Figurl
Parameters
----------
key : dict
primary key of an entry from CurationFigurlSelection table
"""
# get new_curation_uri from selection table
new_curation_uri = (CurationFigurlSelection & key).fetch1(
"new_curation_uri"
)
# fetch
recording_path = (SpikeSortingRecording & key).fetch1("recording_path")
sorting_path = (SpikeSorting & key).fetch1("sorting_path")
recording_label = SpikeSortingRecording._get_recording_name(key)
sorting_label = SpikeSorting._get_sorting_name(key)
unit_metrics = _reformat_metrics(
(Curation & key).fetch1("quality_metrics")
)
initial_labels = (Curation & key).fetch1("curation_labels")
initial_merge_groups = (Curation & key).fetch1("merge_groups")
# new_curation_uri = key["new_curation_uri"]
# Create the initial curation and store it in kachery
for k, v in initial_labels.items():
new_list = []
for item in v:
if item not in new_list:
new_list.append(item)
initial_labels[k] = new_list
initial_curation = {
"labelsByUnit": initial_labels,
"mergeGroups": initial_merge_groups,
}
initial_curation_uri = kcl.store_json(initial_curation)
# Get the recording/sorting extractors
R = si.load_extractor(recording_path)
if R.get_num_segments() > 1:
R = si.concatenate_recordings([R])
S = si.load_extractor(sorting_path)
# Generate the figURL
url = _generate_the_figurl(
R=R,
S=S,
initial_curation_uri=initial_curation_uri,
new_curation_uri=new_curation_uri,
recording_label=recording_label,
sorting_label=sorting_label,
unit_metrics=unit_metrics,
)
# insert
key["url"] = url
key["initial_curation_uri"] = initial_curation_uri
key["new_curation_uri"] = new_curation_uri
self.insert1(key)
|
make(key)
Create a Curation Figurl
Parameters:
Name |
Type |
Description |
Default |
key |
dict
|
primary key of an entry from CurationFigurlSelection table
|
required
|
Source code in src/spyglass/spikesorting/v0/curation_figurl.py
| def make(self, key: dict):
"""Create a Curation Figurl
Parameters
----------
key : dict
primary key of an entry from CurationFigurlSelection table
"""
# get new_curation_uri from selection table
new_curation_uri = (CurationFigurlSelection & key).fetch1(
"new_curation_uri"
)
# fetch
recording_path = (SpikeSortingRecording & key).fetch1("recording_path")
sorting_path = (SpikeSorting & key).fetch1("sorting_path")
recording_label = SpikeSortingRecording._get_recording_name(key)
sorting_label = SpikeSorting._get_sorting_name(key)
unit_metrics = _reformat_metrics(
(Curation & key).fetch1("quality_metrics")
)
initial_labels = (Curation & key).fetch1("curation_labels")
initial_merge_groups = (Curation & key).fetch1("merge_groups")
# new_curation_uri = key["new_curation_uri"]
# Create the initial curation and store it in kachery
for k, v in initial_labels.items():
new_list = []
for item in v:
if item not in new_list:
new_list.append(item)
initial_labels[k] = new_list
initial_curation = {
"labelsByUnit": initial_labels,
"mergeGroups": initial_merge_groups,
}
initial_curation_uri = kcl.store_json(initial_curation)
# Get the recording/sorting extractors
R = si.load_extractor(recording_path)
if R.get_num_segments() > 1:
R = si.concatenate_recordings([R])
S = si.load_extractor(sorting_path)
# Generate the figURL
url = _generate_the_figurl(
R=R,
S=S,
initial_curation_uri=initial_curation_uri,
new_curation_uri=new_curation_uri,
recording_label=recording_label,
sorting_label=sorting_label,
unit_metrics=unit_metrics,
)
# insert
key["url"] = url
key["initial_curation_uri"] = initial_curation_uri
key["new_curation_uri"] = new_curation_uri
self.insert1(key)
|