Skip to content

Commit

Permalink
feat: add plotting function to call dlc PlottingResults on PoseEsti…
Browse files Browse the repository at this point in the history
…mation results
  • Loading branch information
ttngu207 committed Sep 20, 2024
1 parent f69c46a commit d05c664
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Empty file.
36 changes: 36 additions & 0 deletions element_deeplabcut/plotting/dlc_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
def plotting_results(pose_estimation_key: dict):
"""
Wrapper for deeplabcut.utils.plotting.PlottingResults,
using dlc_result object from `dlc_reader.PoseEstimation`
Args:
pose_estimation_key (dict): PoseEstimation key
Returns:
plots_dir (Path): Path to the folder containing the plots
"""
import deeplabcut
from element_deeplabcut import dlc_reader, model

output_dir = (model.PoseEstimationTask & pose_estimation_key).fetch1(
"pose_estimation_output_dir"
)
output_dir = model.find_full_path(model.get_dlc_root_data_dir(), output_dir)

dlc_result = dlc_reader.PoseEstimation(output_dir)

plots_dir = output_dir / "plots"
plots_dir.mkdir(exist_ok=True)

deeplabcut.utils.plotting.PlottingResults(
tmpfolder=plots_dir,
Dataframe=dlc_result.rawdata,
cfg=dlc_result.yml,
bodyparts2plot=dlc_result.body_parts.to_list(),
individuals2plot="",
showfigures=False,
suffix=".png",
resolution=100,
linewidth=1.0,
)

return plots_dir

0 comments on commit d05c664

Please sign in to comment.