Skip to content

Commit 417219f

Browse files
committed
refactor: ♻️ Fix metrics directory in QualityMetrics
1 parent 1df41ea commit 417219f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

element_array_ephys/ephys_no_curation.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
import numpy as np
1010
import pandas as pd
1111
import spikeinterface as si
12-
from element_interface.utils import (dict_to_uuid, find_full_path,
13-
find_root_directory)
12+
from element_interface.utils import dict_to_uuid, find_full_path, find_root_directory
1413
from spikeinterface import exporters, postprocessing, qualitymetrics, sorters
1514

1615
from . import ephys_report, probe
@@ -1032,7 +1031,7 @@ def make(self, key):
10321031
probe.ProbeType.Electrode * probe.ElectrodeConfig.Electrode
10331032
& electrode_config_key
10341033
) * (dj.U("electrode", "channel_idx") & EphysRecording.Channel)
1035-
1034+
10361035
channel2electrode_map = dict(
10371036
zip(*electrode_query.fetch("channel_idx", "electrode"))
10381037
) # {channel: electrode}
@@ -1053,7 +1052,9 @@ def make(self, key):
10531052
pass
10541053

10551054
# Get channel to electrode mapping
1056-
channel2depth_map = dict(zip(*electrode_query.fetch("channel_idx", "y_coord"))) # {channel: depth}
1055+
channel2depth_map = dict(
1056+
zip(*electrode_query.fetch("channel_idx", "y_coord"))
1057+
) # {channel: depth}
10571058

10581059
peak_electrode_ind = np.array(
10591060
[
@@ -1570,9 +1571,14 @@ class Waveform(dj.Part):
15701571
def make(self, key):
15711572
"""Populates tables with quality metrics data."""
15721573
# Load metrics.csv
1573-
output_dir = (ClusteringTask & key).fetch1("clustering_output_dir")
1574+
clustering_method, output_dir = (
1575+
ClusteringTask * ClusteringParamSet & key
1576+
).fetch1("clustering_method", "clustering_output_dir")
15741577
output_dir = find_full_path(get_ephys_root_data_dir(), output_dir)
1575-
metric_fp = output_dir / "metrics.csv"
1578+
sorter_name = (
1579+
"kilosort2_5" if clustering_method == "kilosort2.5" else clustering_method
1580+
)
1581+
metric_fp = output_dir / sorter_name / "metrics" / "metrics.csv"
15761582
if not metric_fp.exists():
15771583
raise FileNotFoundError(f"QC metrics file not found: {metric_fp}")
15781584
metrics_df = pd.read_csv(metric_fp)

0 commit comments

Comments
 (0)