module plot
Global Variables
- global_config
function plot_embedding
plot_embedding(
dataset: DataFrame,
col_names: list = ['embedding_0', 'embedding_1'],
color_col: str = None,
figsize: tuple = (10, 10),
**kwargs
) → tuple
Scatterplot of a 2D TSNE or UMAP embedding from the dataset.
Args:
dataset
: datacol_names
: list of column names to use for the x and y axescolor_col
: if provided, a column that will be used to color the points in the scatter plotfigsize
: tuple with the dimensions of the plot (in inches)kwargs
: All other keyword pairs are sent to Matplotlib's scatter function
Returns: tuple (fig, axes). The Figure and Axes objects.
function plot_unsupervised_results
plot_unsupervised_results(
dataset: DataFrame,
cluster_results: tuple,
col_names: list = ['embedding_0', 'embedding_1'],
figsize: tuple = (15, 4),
**kwargs
)
Set of plots for unsupervised behavior clustering results
Args:
dataset
: datacluster_results
: tuple output by 'cluster_behaviors'col_names
: list of column names to use for the x and y axesfigsize
: tuple with the plot dimensions, in incheskwargs
: all other keyword pairs are sent to Matplotlib's scatter function
Returns: tuple (fig, axes). The Figure and Axes objects.
function plot_ethogram
plot_ethogram(
dataset: DataFrame,
vid_key: str,
query_label: str = 'unsup_behavior_label',
frame_limit: int = 4000,
figsize: tuple = (16, 2)
) → tuple
Simple ethogram of one video, up to a certain frame number.
Args:
dataset:
- vid_key
: key (in dataset.metadata) pointing to the video to make ethogram for
- query_label
: the column containing the behavior labels to plot
- frame_limit
: only make the ethogram for frames between [0, frame_limit]
- figsize
: tuple with figure size (in inches)
Returns: tuple (fig, axes). The Figure and Axes objects
function create_ethogram_video
create_ethogram_video(
dataset: DataFrame,
vid_key: str,
query_label: str,
out_file: str,
frame_limit: int = 4000,
im_dim: float = 16,
min_frames: int = 3
) → None
Overlay ethogram on top of source video with ffmpeg
Args:
dataset
: source datasetvid_key
: the key (in dataset.metadata) pointing to the video to make ethogram for. metadata must have field 'video' that points to the source video locationquery_label
: the column containing the behavior labels to plotout_file
: output path for created videoframe_limit
: only make the ethogram/video for frames [0, frame_limit]in_dim
: x dimension (in inches) of ethogrammin_frames
: any behaviors occurring for less than this number of frames are not labeled
Returns: None
function create_sample_videos
create_sample_videos(
dataset: DataFrame,
video_dir: str,
out_dir: str,
query_col: str = 'unsup_behavior_label',
N_sample_rows: int = 16,
window_size: int = 2,
fps: float = 30,
N_supersample_rows: int = 1000
) → None
Create a sample of videos displaying the labeled behaviors using ffmpeg.
For each behavior label, randomly choose frames from the entire dataset and extract short clips from source videos based around those points. Tries to select frames where the labeled behavior is exhibited in many frames of the clip.
Args:
dataset
: source datasetvideo_dir
: location of source video filesout_dir
: base output directory to save videos. Videos are saved in the form: [out_dir]/[behavior_label]/[video_name]_[time in seconds].aviquery_label
: the column containing the behavior labels to extract clips for. Each unique value in this column is treated as a separate behaviorN_sample_rows
: number of clips to extract per behaviorwindow_size
: amount of video to extract on either side of the sampled frame, in secondsfps
: frames per second of videosN_supersample_rows
: this many rows are randomly sampled for each behavior label, and the top N_sample_rows are returned (in terms of number of adjacent frames also exhibiting that behavior). Shouldn't need to play with this.
Returns: None
function create_mosaic_video
create_mosaic_video(
vid_dir: str,
output_file: str,
ndim: tuple = (1600, 1200)
) → None
Take a set of video clips and turn them into a mosaic using ffmpeg
16 videos are tiled.
Args:
vid_dir
: source directory with videos in itoutput_file
: output video pathndim
: tuple with the output video dimensions, in pixels
Returns: None
class MplColorHelper
method __init__
__init__(cmap_name, start_val, stop_val)
method get_rgb
get_rgb(val)
This file was automatically generated via lazydocs.