Skip to content

Commit eddcadb

Browse files
committed
update to only use QA folder name (and not optionally quality_assurance) as in the latest version of kpms
1 parent ad41a9d commit eddcadb

File tree

3 files changed

+30
-72
lines changed

3 files changed

+30
-72
lines changed

element_moseq/moseq_report.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,32 +103,17 @@ def make(self, key):
103103
for rec in recording_names:
104104
vid = posefile2vid[rec]
105105

106-
qa_dirs = ["QA", "quality_assurance"]
107-
plot_path = None
108-
109-
for qa_dir in qa_dirs:
110-
potential_path = (
111-
kpms_project_output_dir
112-
/ qa_dir
113-
/ "plots"
114-
/ "keypoint_distance_outliers"
115-
/ f"{rec}.png"
116-
)
117-
if potential_path.exists():
118-
plot_path = potential_path
119-
break
120-
121-
if plot_path is None:
122-
checked_paths = [
123-
kpms_project_output_dir
124-
/ qa_dir
125-
/ "plots"
126-
/ "keypoint_distance_outliers"
127-
/ f"{rec}.png"
128-
for qa_dir in qa_dirs
129-
]
106+
# Look for outlier plot in QA directory
107+
plot_path = (
108+
kpms_project_output_dir
109+
/ "QA"
110+
/ "plots"
111+
/ "keypoint_distance_outliers"
112+
/ f"{rec}.png"
113+
)
114+
if not plot_path.exists():
130115
raise FileNotFoundError(
131-
f"Outlier plot not found for {rec}. Checked paths: {[str(p) for p in checked_paths]}"
116+
f"Outlier plot not found for {rec} at {plot_path}"
132117
)
133118

134119
self.insert1(

element_moseq/moseq_train.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -464,32 +464,17 @@ def make_compute(
464464
**kpms_config,
465465
)
466466

467-
qa_dirs = ["QA", "quality_assurance"]
468-
plot_path = None
469-
470-
for qa_dir in qa_dirs:
471-
potential_path = (
472-
kpms_project_output_dir
473-
/ qa_dir
474-
/ "plots"
475-
/ "keypoint_distance_outliers"
476-
/ f"{recording_name}.png"
477-
)
478-
if potential_path.exists():
479-
plot_path = potential_path
480-
break
481-
482-
if plot_path is None:
483-
checked_paths = [
484-
kpms_project_output_dir
485-
/ qa_dir
486-
/ "plots"
487-
/ "keypoint_distance_outliers"
488-
/ f"{recording_name}.png"
489-
for qa_dir in qa_dirs
490-
]
467+
# Check if outlier plot was created in QA directory
468+
plot_path = (
469+
kpms_project_output_dir
470+
/ "QA"
471+
/ "plots"
472+
/ "keypoint_distance_outliers"
473+
/ f"{recording_name}.png"
474+
)
475+
if not plot_path.exists():
491476
raise FileNotFoundError(
492-
f"Could not create outlier plot for {recording_name}. Checked paths: {[str(p) for p in checked_paths]}"
477+
f"Could not create outlier plot for {recording_name} at {plot_path}"
493478
)
494479
return (
495480
cleaned_coordinates,

element_moseq/plotting/viz_utils.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,16 @@ def plot_medoid_distance_outliers(
6565
"""
6666
from keypoint_moseq.util import get_distance_to_medoid, plot_keypoint_traces
6767

68-
qa_dirs = ["QA", "quality_assurance"]
69-
plot_path = None
70-
71-
for qa_dir in qa_dirs:
72-
potential_path = os.path.join(
73-
project_dir,
74-
qa_dir,
75-
"plots",
76-
"keypoint_distance_outliers",
77-
f"{recording_name}.png",
78-
)
79-
# Create directory if it doesn't exist
80-
os.makedirs(os.path.dirname(potential_path), exist_ok=True)
81-
plot_path = potential_path
82-
break # Use first available directory
83-
84-
if plot_path is None:
85-
raise FileNotFoundError(
86-
f"Could not determine plot directory for {recording_name}"
87-
)
68+
# Use QA directory for outlier plots
69+
plot_path = os.path.join(
70+
project_dir,
71+
"QA",
72+
"plots",
73+
"keypoint_distance_outliers",
74+
f"{recording_name}.png",
75+
)
76+
# Create directory if it doesn't exist
77+
os.makedirs(os.path.dirname(plot_path), exist_ok=True)
8878

8979
original_distances = get_distance_to_medoid(
9080
original_coordinates
@@ -291,8 +281,6 @@ def copy_pdf_to_png(project_dir, model_name):
291281
project_dir (Path): Project directory path
292282
model_name (str): Model name directory
293283
294-
Returns:
295-
None: The function raises errors instead of returning boolean values
296284
"""
297285
from pdf2image import convert_from_path
298286

0 commit comments

Comments
 (0)