-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add plotting function to call dlc
PlottingResults
on PoseEsti…
…mation results
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |