Plots poses vs time; pose x vs pose y; histogram of differences and likelihoods.
(
tmpfolder,
Dataframe,
cfg,
bodyparts2plot,
individuals2plot,
showfigures=False,
suffix=".png",
resolution=100,
linewidth=1.0,
)
| 51 | |
| 52 | |
| 53 | def PlottingResults( |
| 54 | tmpfolder, |
| 55 | Dataframe, |
| 56 | cfg, |
| 57 | bodyparts2plot, |
| 58 | individuals2plot, |
| 59 | showfigures=False, |
| 60 | suffix=".png", |
| 61 | resolution=100, |
| 62 | linewidth=1.0, |
| 63 | ): |
| 64 | """Plots poses vs time; pose x vs pose y; histogram of differences and |
| 65 | likelihoods.""" |
| 66 | pcutoff = cfg["pcutoff"] |
| 67 | colors = visualization.get_cmap(len(bodyparts2plot), name=cfg["colormap"]) |
| 68 | alphavalue = cfg["alphavalue"] |
| 69 | if individuals2plot: |
| 70 | Dataframe = Dataframe.loc(axis=1)[:, individuals2plot] |
| 71 | animal_bpts = Dataframe.columns.get_level_values("bodyparts") |
| 72 | # Close previous figures before plotting |
| 73 | plt.close("all") |
| 74 | |
| 75 | # Pose X vs pose Y |
| 76 | fig1 = plt.figure(figsize=(8, 6)) |
| 77 | ax1 = fig1.add_subplot(111) |
| 78 | ax1.set_xlabel("X position in pixels") |
| 79 | ax1.set_ylabel("Y position in pixels") |
| 80 | ax1.invert_yaxis() |
| 81 | |
| 82 | # Poses vs time |
| 83 | fig2 = plt.figure(figsize=(10, 3)) |
| 84 | ax2 = fig2.add_subplot(111) |
| 85 | ax2.set_xlabel("Frame Index") |
| 86 | ax2.set_ylabel("X-(dashed) and Y- (solid) position in pixels") |
| 87 | |
| 88 | # Likelihoods |
| 89 | fig3 = plt.figure(figsize=(10, 3)) |
| 90 | ax3 = fig3.add_subplot(111) |
| 91 | ax3.set_xlabel("Frame Index") |
| 92 | ax3.set_ylabel("Likelihood (use to set pcutoff)") |
| 93 | |
| 94 | # Histograms |
| 95 | fig4 = plt.figure() |
| 96 | ax4 = fig4.add_subplot(111) |
| 97 | ax4.set_ylabel("Count") |
| 98 | ax4.set_xlabel("DeltaX and DeltaY") |
| 99 | bins = np.linspace(0, np.amax(Dataframe.max()), 100) |
| 100 | |
| 101 | with np.errstate(invalid="ignore"): |
| 102 | for bpindex, bp in enumerate(bodyparts2plot): |
| 103 | if bp in animal_bpts: # Avoid 'unique' bodyparts only present in the 'single' animal |
| 104 | prob = Dataframe.xs((bp, "likelihood"), level=(-2, -1), axis=1).values.squeeze() |
| 105 | mask = prob < pcutoff |
| 106 | temp_x = np.ma.array( |
| 107 | Dataframe.xs((bp, "x"), level=(-2, -1), axis=1).values.squeeze(), |
| 108 | mask=mask, |
| 109 | ) |
| 110 | temp_y = np.ma.array( |
no test coverage detected