From d05c66417e59e483bbcc0f6e05604f12c5580f7e Mon Sep 17 00:00:00 2001 From: Thinh Nguyen Date: Fri, 20 Sep 2024 14:22:40 -0500 Subject: [PATCH 1/2] feat: add plotting function to call dlc `PlottingResults` on PoseEstimation results --- element_deeplabcut/plotting/__init__.py | 0 element_deeplabcut/plotting/dlc_plots.py | 36 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 element_deeplabcut/plotting/__init__.py create mode 100644 element_deeplabcut/plotting/dlc_plots.py diff --git a/element_deeplabcut/plotting/__init__.py b/element_deeplabcut/plotting/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/element_deeplabcut/plotting/dlc_plots.py b/element_deeplabcut/plotting/dlc_plots.py new file mode 100644 index 0000000..c0867df --- /dev/null +++ b/element_deeplabcut/plotting/dlc_plots.py @@ -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 From ddd5c16bb5716ef3a4f7fc343af1d8c245eb6b41 Mon Sep 17 00:00:00 2001 From: Thinh Nguyen Date: Fri, 20 Sep 2024 14:24:10 -0500 Subject: [PATCH 2/2] bump version --- CHANGELOG.md | 4 ++++ element_deeplabcut/version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 651558f..2d38eab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention. +## [0.3.3] - TBD + ++ Add - Plotting with `deeplabcut.utils.plotting.PlottingResults` + ## [0.3.2] - 2024-09-09 + Fix - Save config file to output directory as `dj_dlc_config` diff --git a/element_deeplabcut/version.py b/element_deeplabcut/version.py index 931952f..d73e036 100644 --- a/element_deeplabcut/version.py +++ b/element_deeplabcut/version.py @@ -2,4 +2,4 @@ Package metadata """ -__version__ = "0.3.2" +__version__ = "0.3.3"