Skip to content

Commit d05c664

Browse files
committed
feat: add plotting function to call dlc PlottingResults on PoseEstimation results
1 parent f69c46a commit d05c664

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

element_deeplabcut/plotting/__init__.py

Whitespace-only changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
def plotting_results(pose_estimation_key: dict):
2+
"""
3+
Wrapper for deeplabcut.utils.plotting.PlottingResults,
4+
using dlc_result object from `dlc_reader.PoseEstimation`
5+
Args:
6+
pose_estimation_key (dict): PoseEstimation key
7+
8+
Returns:
9+
plots_dir (Path): Path to the folder containing the plots
10+
"""
11+
import deeplabcut
12+
from element_deeplabcut import dlc_reader, model
13+
14+
output_dir = (model.PoseEstimationTask & pose_estimation_key).fetch1(
15+
"pose_estimation_output_dir"
16+
)
17+
output_dir = model.find_full_path(model.get_dlc_root_data_dir(), output_dir)
18+
19+
dlc_result = dlc_reader.PoseEstimation(output_dir)
20+
21+
plots_dir = output_dir / "plots"
22+
plots_dir.mkdir(exist_ok=True)
23+
24+
deeplabcut.utils.plotting.PlottingResults(
25+
tmpfolder=plots_dir,
26+
Dataframe=dlc_result.rawdata,
27+
cfg=dlc_result.yml,
28+
bodyparts2plot=dlc_result.body_parts.to_list(),
29+
individuals2plot="",
30+
showfigures=False,
31+
suffix=".png",
32+
resolution=100,
33+
linewidth=1.0,
34+
)
35+
36+
return plots_dir

0 commit comments

Comments
 (0)