Skip to content

Commit 0898ce5

Browse files
committed
feat: ✨ add quality label mapping
1 parent bab86b7 commit 0898ce5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

element_array_ephys/ephys_no_curation.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,21 @@ def make(self, key):
10111011
zip(*electrode_query.fetch("channel", "electrode"))
10121012
)
10131013

1014+
# Get unit id to quality label mapping
1015+
cluster_quality_label_map = {}
1016+
try:
1017+
cluster_quality_label_map = pd.read_csv(
1018+
sorting_dir / "sorter_output" / "cluster_KSLabel.tsv",
1019+
delimiter="\t",
1020+
)
1021+
cluster_quality_label_map: dict[
1022+
int, str
1023+
] = cluster_quality_label_map.set_index("cluster_id")[
1024+
"KSLabel"
1025+
].to_dict() # {unit: quality_label}
1026+
except FileNotFoundError:
1027+
pass
1028+
10141029
# Get channel to electrode mapping
10151030
channel2depth_map = dict(zip(*electrode_query.fetch("channel", "y_coord")))
10161031

@@ -1038,7 +1053,9 @@ def make(self, key):
10381053
units.append(
10391054
{
10401055
"unit": unit_id,
1041-
"cluster_quality_label": "n.a.",
1056+
"cluster_quality_label": cluster_quality_label_map.get(
1057+
unit_id, "n.a."
1058+
),
10421059
"spike_times": si_sorting.get_unit_spike_train(
10431060
unit_id, return_times=True
10441061
),

0 commit comments

Comments
 (0)