(
h5file,
bodyparts=None,
individuals=None,
show=False,
resolution=100,
linewidth=1.0,
colormap="viridis",
alpha=1.0,
pcutoff=0.01,
suffix="",
image_type=".png",
dest_folder=None,
)
| 361 | |
| 362 | |
| 363 | def _plot_trajectories( |
| 364 | h5file, |
| 365 | bodyparts=None, |
| 366 | individuals=None, |
| 367 | show=False, |
| 368 | resolution=100, |
| 369 | linewidth=1.0, |
| 370 | colormap="viridis", |
| 371 | alpha=1.0, |
| 372 | pcutoff=0.01, |
| 373 | suffix="", |
| 374 | image_type=".png", |
| 375 | dest_folder=None, |
| 376 | ): |
| 377 | df = pd.read_hdf(h5file) |
| 378 | if bodyparts is None: |
| 379 | bodyparts = list(df.columns.get_level_values("bodyparts").unique()) |
| 380 | if individuals is None: |
| 381 | try: |
| 382 | individuals = set(df.columns.get_level_values("individuals")) |
| 383 | except KeyError: |
| 384 | individuals = [""] |
| 385 | if dest_folder is None: |
| 386 | vname = os.path.basename(h5file).split("DLC")[0] |
| 387 | vid_folder = os.path.dirname(h5file) |
| 388 | dest_folder = os.path.join(vid_folder, "plot-poses", vname) |
| 389 | auxiliaryfunctions.attempt_to_make_folder(dest_folder, recursive=True) |
| 390 | # Keep only the individuals and bodyparts that were labeled |
| 391 | labeled_bpts = [bp for bp in df.columns.get_level_values("bodyparts").unique() if bp in bodyparts] |
| 392 | # Either display the animals defined in the config if they are found |
| 393 | # in the dataframe, or all the trajectories regardless of their names |
| 394 | try: |
| 395 | animals = set(df.columns.get_level_values("individuals")) |
| 396 | except KeyError: |
| 397 | animals = {""} |
| 398 | cfg = { |
| 399 | "colormap": colormap, |
| 400 | "alphavalue": alpha, |
| 401 | "pcutoff": pcutoff, |
| 402 | } |
| 403 | for animal in animals.intersection(individuals) or animals: |
| 404 | PlottingResults( |
| 405 | dest_folder, |
| 406 | df, |
| 407 | cfg, |
| 408 | labeled_bpts, |
| 409 | animal, |
| 410 | show, |
| 411 | suffix + animal + image_type, |
| 412 | resolution=resolution, |
| 413 | linewidth=linewidth, |
| 414 | ) |
| 415 | |
| 416 | |
| 417 | def _plot_paf_performance( |
no test coverage detected