Skip to content

Commit af4ce80

Browse files
Merge pull request #126 from ttngu207/main
add plotting function to call dlc PlottingResults on PoseEstimation results
2 parents a1073bb + ddd5c16 commit af4ce80

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
44
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
55

6+
## [0.3.3] - TBD
7+
8+
+ Add - Plotting with `deeplabcut.utils.plotting.PlottingResults`
9+
610
## [0.3.2] - 2024-09-09
711

812
+ Fix - Save config file to output directory as `dj_dlc_config`

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

element_deeplabcut/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Package metadata
33
"""
44

5-
__version__ = "0.3.2"
5+
__version__ = "0.3.3"

0 commit comments

Comments
 (0)