Skip to content

deeplabcut.cli

Functions:

Name Description
add_new_videos

Add new videos to the config file at any stage of the project.

analyze_videos

Makes prediction on videos using a trained network.

check_labels

Check if labels were stored correctly by plotting annotations and inspect them

create_labeled_video

Labels the bodyparts in a video.

create_new_project

Create a new project directory, sub-directories and a basic configuration file.

create_training_dataset

Combine frame and label information into an array. Create training and test sets.

evaluate_network

Evaluates a trained Feature detector model.

export_model

Export DLC models for the model zoo or for live inference.

extract_frames

Extracts frames from the videos in the config.yaml file.

extract_outlier_frames

Extracts the outlier frames in case, the predictions are not correct for a

label_frames

Manually label/annotate the extracted frames.

plot_trajectories

Plots the trajectories of various bodyparts across the video.

refine_labels

Refines the labels of the outlier frames extracted from the analyzed videos.

train_network

Train a trained Feature detector with a specific training data set.

add_new_videos

add_new_videos(_, *args, **kwargs)

Add new videos to the config file at any stage of the project.

Delegates to deeplabcut.add_new_videos.

Parameters:

Name Type Description Default

config

string

String containing the full path of the config file in the project.

required

videos

list

A list of string containing the full paths of the videos to include in the project.

required

copy_videos

bool

If True, symlinks of the videos are copied to project/videos. Default True; must be True or False.

required

Examples:

To add a new video to the project:

python3 dlc.py add_new_videos
    /home/project/reaching-task-Tanmay-2018-08-23/config.yaml \
    /data/videos/mouse5.avi
Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.argument("videos", nargs=-1, type=click.Path(exists=True, dir_okay=False))
@click.option(
    "--copy_videos/--dont_copy_videos",
    is_flag=True,
    default=True,
    help="Specify if you need to create the symlinks of the video and store in the videos directory. Default is True.",
)
@click.pass_context
def add_new_videos(_, *args, **kwargs):
    """Add new videos to the config file at any stage of the project.

    Delegates to ``deeplabcut.add_new_videos``.

    Args:
        config (string): String containing the full path of the config file in the project.
        videos (list): A list of string containing the full paths of the videos to include in the project.
        copy_videos (bool, optional): If True, symlinks of the videos are copied to
            project/videos. Default ``True``; must be ``True`` or ``False``.

    Examples:
        To add a new video to the project:

        ```bash
        python3 dlc.py add_new_videos
            /home/project/reaching-task-Tanmay-2018-08-23/config.yaml \\
            /data/videos/mouse5.avi
        ```
    """
    from deeplabcut.create_project import add

    add.add_new_videos(*args, **kwargs)

analyze_videos

analyze_videos(_, *args, **kwargs)

Makes prediction on videos using a trained network.

Delegates to deeplabcut.analyze_videos.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file in the train directory of a project.

required

videos

list

Full path(s) to video(s).

required

shuffle

int

Shuffle index of the training dataset. Defaults to 1.

required

video_extensions

string

Video extension when the input is a directory. Defaults to .avi.

required

save_as_csv

bool

Also save predictions as a CSV file. Defaults to False.

required

Examples:

To analyze a video:

python3 dlc.py analyze_videos /home/project/reaching/config.yaml \
    /home/project/reaching/newVideo/1.avi

Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.argument("videos", nargs=-1)
@click.option(
    "-num",
    "--num_shuffles",
    "shuffle",
    default=1,
    help="Shuffle index of the training dataset. Default is set to 1.",
)
@click.option(
    "-vtype",
    "--video_type",
    "video_extensions",
    default=".avi",
    help="The extension of video in case the input is a directory",
)
@click.option(
    "-c",
    "--save",
    "save_as_csv",
    is_flag=True,
    help="Saves as a .csv file. Default is False.",
)
@click.pass_context
def analyze_videos(_, *args, **kwargs):
    """Makes prediction on videos using a trained network.

    Delegates to ``deeplabcut.analyze_videos``.

    Args:
        config (string): Full path of the config.yaml file in the train directory of a
            project.
        videos (list): Full path(s) to video(s).
        shuffle (int, optional): Shuffle index of the training dataset. Defaults to 1.
        video_extensions (string, optional): Video extension when the input is a directory.
            Defaults to ``.avi``.
        save_as_csv (bool, optional): Also save predictions as a CSV file. Defaults to
            False.

    Examples:
        To analyze a video:
        ```bash
        python3 dlc.py analyze_videos /home/project/reaching/config.yaml \\
            /home/project/reaching/newVideo/1.avi
        ```

    """
    from deeplabcut.pose_estimation_tensorflow import predict_videos

    predict_videos.analyze_videos(*args, **kwargs)

check_labels

check_labels(_, config)

Check if labels were stored correctly by plotting annotations and inspect them visually.

Delegates to deeplabcut.check_labels.

If some are wrong, then use the refine_labels to correct the labels.

Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.pass_context
def check_labels(_, config):
    """Check if labels were stored correctly by plotting annotations and inspect them
    visually.

    Delegates to ``deeplabcut.check_labels``.

    If some are wrong, then use the refine_labels to correct the labels.
    """
    from deeplabcut.generate_training_dataset.trainingsetmanipulation import check_labels as _check_labels

    _check_labels(config)

create_labeled_video

create_labeled_video(_, *args, **kwargs)

Labels the bodyparts in a video.

Delegates to deeplabcut.create_labeled_video.

Make sure the video is already analyzed by the function analyze_videos.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file.

required

videos

list

Full path(s) to video(s).

required

shuffle

int

Shuffle index of the training dataset. Defaults to 1.

required

video_extensions

string

Video extension when the input is a directory. Defaults to .avi.

required

save_frames

bool

Save individual frames before combining into video. Defaults to False.

required

delete

bool

Delete individual frames after video generation. Defaults to False.

required
Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.argument("videos", nargs=-1)
@click.option(
    "-num",
    "--num_shuffles",
    "shuffle",
    default=1,
    help="Number of shuffles of training dataset. Default is set to 1.",
)
@click.option(
    "-v",
    "--video_type",
    "video_extensions",
    default=".avi",
    help="Checks for the extension of the video in case the input is a directory.\
          Only videos with this extension are analyzed. The default is ``.avi``",
)
@click.option(
    "-s",
    "--save_frames",
    "save_frames",
    is_flag=True,
    default=False,
    help="If true creates each frame individual and then combines into a video. \
          This variant is relatively slow as it stores all individual frames. However, it \
          uses matplotlib to create the frames and is therefore much more flexible \
          (one can set transparency of markers, crop, and easily customize.",
)
@click.option(
    "-d",
    "--delete",
    "delete",
    is_flag=True,
    default=False,
    help="If true then the individual frames created during the video generation will be deleted.\
          Only the video will be left.",
)
@click.pass_context
def create_labeled_video(_, *args, **kwargs):
    """Labels the bodyparts in a video.

    Delegates to ``deeplabcut.create_labeled_video``.

    Make sure the video is already analyzed by the function ``analyze_videos``.

    Args:
        config (string): Full path of the config.yaml file.
        videos (list): Full path(s) to video(s).
        shuffle (int, optional): Shuffle index of the training dataset. Defaults to 1.
        video_extensions (string, optional): Video extension when the input is a directory.
            Defaults to ``.avi``.
        save_frames (bool, optional): Save individual frames before combining into video.
            Defaults to False.
        delete (bool, optional): Delete individual frames after video generation.
            Defaults to False.
    """
    from deeplabcut.utils import make_labeled_video

    make_labeled_video.create_labeled_video(*args, **kwargs)

create_new_project

create_new_project(_, *args, **kwargs)

Create a new project directory, sub-directories and a basic configuration file.

Delegates to deeplabcut.create_new_project.

The configuration file is loaded with default values. Change its parameters to your projects need.

Parameters:

Name Type Description Default

project

string

String containing the name of the project.

required

experimenter

string

String containing the name of the experimenter.

required

videos

list

A list of string containing the full paths of the videos to include in the project.

required

working_directory

string

The directory where the project will be created. The default is the current working directory; if provided, it must be a string.

required

copy_videos

bool

If True, symlink videos into project/videos directory. The default is True; if provided it must be either True or False.

required

Examples:

To create the project in the current working directory without symbolic links:

python3 dlc.py create_new_project reaching-task Tanmay \
/data/videos/mouse1.avi /data/videos/mouse2.avi \
/data/videos/mouse3.avi /analysis/project/ -c False
To create the project in the current working directory with symbolic links:
python3 dlc.py create_new_project reaching-task Tanmay \
    /data/videos/mouse1.avi /data/videos/mouse2.avi \
    /data/videos/mouse3.avi /analysis/project/ -c False

To create the project in another directory:

python3 dlc.py create_new_project reaching-task Tanmay \
    /data/vies/mouse1.avi /data/videos/mouse2.avi \
    /data/videos/mouse3.avi analysis/project -d home/project
Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("project")
@click.argument("experimenter")
@click.argument("videos", nargs=-1, type=click.Path(exists=True, dir_okay=False))
@click.option(
    "-d",
    "--wd",
    "working_directory",
    type=click.Path(exists=True, file_okay=False, resolve_path=True),
    default=Path.cwd(),
    help="Directory to create project in. Default is cwd().",
)
@click.option(
    "--copy_videos/--dont_copy_videos",
    is_flag=True,
    default=True,
    help="Specify if you need to create the symlinks of the video and store in the videos directory. Default is True.",
)
#              type=click.Path(exists=True, file_okay=False, resolve_path=True), default=Path.cwd(),
#              help='Directory to create project in. Default is cwd().')
@click.pass_context
def create_new_project(_, *args, **kwargs):
    """Create a new project directory, sub-directories and a basic configuration file.

    Delegates to ``deeplabcut.create_new_project``.

    The configuration file is loaded with default values. Change its parameters to your
    projects need.

    Args:
        project (string): String containing the name of the project.
        experimenter (string): String containing the name of the experimenter.
        videos (list): A list of string containing the full paths of the videos to include in the project.
        working_directory (string, optional): The directory where the project will be created.
            The default is the ``current working directory``; if provided, it must be a string.
        copy_videos (bool, optional): If True, symlink videos into project/videos directory.
            The default is ``True``; if provided it must be either ``True`` or ``False``.

    Examples:
        To create the project in the current working directory without symbolic links:
        ```bash
        python3 dlc.py create_new_project reaching-task Tanmay \\
        /data/videos/mouse1.avi /data/videos/mouse2.avi \\
        /data/videos/mouse3.avi /analysis/project/ -c False
        ```
        To create the project in the current working directory with symbolic links:
        ```bash
        python3 dlc.py create_new_project reaching-task Tanmay \\
            /data/videos/mouse1.avi /data/videos/mouse2.avi \\
            /data/videos/mouse3.avi /analysis/project/ -c False
        ```

        To create the project in another directory:

        ```bash
        python3 dlc.py create_new_project reaching-task Tanmay \\
            /data/vies/mouse1.avi /data/videos/mouse2.avi \\
            /data/videos/mouse3.avi analysis/project -d home/project
        ```
    """
    from deeplabcut.create_project import new

    new.create_new_project(*args, **kwargs)

create_training_dataset

create_training_dataset(_, *args, **kwargs)

Combine frame and label information into an array. Create training and test sets.

Delegates to deeplabcut.create_training_dataset.

Update parameters TrainFraction and iteration in config.yaml. Also update parameters for pose_config.yaml as wanted.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file in the train directory of a

required

num_shuffles

int

Number of shuffles of training dataset to create.

required

Examples:

To create a training dataset with only 1 shuffle:

python3 dlc.py create_training_dataset \
    /analysis/project/reaching-task/config.yaml

To create a training dataset with only 2 shuffles:

python3 dlc.py create_training_dataset \
    /analysis/project/reaching-task/config.yaml num_shuffles 2
Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.option(
    "-num",
    "--num_shuffles",
    "num_shuffles",
    default=1,
    help="Number of shuffles of training dataset to create. Default is set to 1.",
)
@click.pass_context
def create_training_dataset(_, *args, **kwargs):
    """Combine frame and label information into an array. Create training and test sets.

    Delegates to ``deeplabcut.create_training_dataset``.

    Update parameters TrainFraction and iteration in config.yaml. Also update
    parameters for pose_config.yaml as wanted.

    Args:
        config (string): Full path of the config.yaml file in the train directory of a
        project.
        num_shuffles (int, optional): Number of shuffles of training dataset to create.
        Defaults to 1.

    Examples:
        To create a training dataset with only 1 shuffle:

        ```bash
        python3 dlc.py create_training_dataset \\
            /analysis/project/reaching-task/config.yaml
        ```

        To create a training dataset with only 2 shuffles:

        ```bash
        python3 dlc.py create_training_dataset \\
            /analysis/project/reaching-task/config.yaml num_shuffles 2
        ```
    """
    from deeplabcut.generate_training_dataset.trainingsetmanipulation import (
        create_training_dataset as _create_training_dataset,
    )

    _create_training_dataset(*args, **kwargs)

evaluate_network

evaluate_network(_, config, **kwargs)

Evaluates a trained Feature detector model.

Delegates to deeplabcut.evaluate_network.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file in the train directory of a

required

shuffle

list

Shuffle index of the training dataset. Defaults to [1].

required

plotting

bool

Make evaluation plots. Defaults to False.

required

Examples:

Evalaute the network:

python3 dlc.py evaluate_network /home/project/reaching/config.yaml
Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.option(
    "-num",
    "--num_shuffles",
    "shuffle",
    default=[1],
    help="Shuffle index of the training dataset. Default is set to 1.",
)
@click.option("-p", "--plot", "plotting", is_flag=True, help="Make plots. Default is False.")
@click.pass_context
def evaluate_network(_, config, **kwargs):
    """Evaluates a trained Feature detector model.

    Delegates to ``deeplabcut.evaluate_network``.

    Args:
        config (string): Full path of the config.yaml file in the train directory of a
        project.
        shuffle (list, optional): Shuffle index of the training dataset. Defaults to [1].
        plotting (bool, optional): Make evaluation plots. Defaults to False.

    Examples:
        Evalaute the network:

        ```bash
        python3 dlc.py evaluate_network /home/project/reaching/config.yaml
        ```
    """
    from deeplabcut.pose_estimation_tensorflow.core.evaluate import evaluate_network as _evaluate_network

    _evaluate_network(config, **kwargs)

export_model

export_model(_, *args, **kwargs)

Export DLC models for the model zoo or for live inference.

Delegates to deeplabcut.export_model.

Saves the pose configuration, snapshot files, and frozen graph of the model to a directory named exported-models within the project directory.

Parameters:

Name Type Description Default

cfg_path

string

Path to the DLC Project config.yaml file.

required

iteration

int

The model iteration you wish to export. If None, uses the iteration listed in the config file.

required

shuffle

int

The shuffle of the model to export. Defaults to 1.

required

trainingsetindex

int

Index of the training fraction for the model to export. Defaults to 0.

required

snapshotindex

int

The snapshot index for the weights you wish to export. If None, uses the snapshotindex as defined in config.yaml. Defaults to None.

required

TFGPUinference

bool

Use the tensorflow inference model? Defaults to True. For DeepLabCut-live, set TFGPUinference=False.

required

overwrite

bool

If the model was already exported, whether to overwrite. Defaults to False.

required

make_tar

bool

Compress the exported directory to a tar file? Defaults to True. Required for model zoo export, not for live inference.

required
Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("cfg-path", nargs=1, type=click.STRING)
@click.option(
    "-i",
    "--iteration",
    "iteration",
    default=None,
    required=False,
    type=int,
    help="the model iteration you wish to export. If None, uses the iteration listed in the config file",
)
@click.option(
    "-s",
    "--shuffle",
    "shuffle",
    default=1,
    required=False,
    type=int,
    help="the shuffle of the model to export. Default is set to 1.",
)
@click.option(
    "-t",
    "--trainingsetindex",
    "trainingsetindex",
    default=0,
    required=False,
    type=int,
    help="the index of the training fraction for the model you wish to export. default = 0",
)
@click.option(
    "-n",
    "--snapshotindex",
    "snapshotindex",
    default=None,
    required=False,
    type=int,
    help="the snapshot index for the weights you wish to export",
)
@click.option(
    "--TFGPUinference/--NPinference",
    "TFGPUinference",
    default=True,
    required=False,
    help="use the tensorflow inference model? Default = True",
)
@click.option(
    "--overwrite",
    "-o",
    is_flag=True,
    required=False,
    help="if the model you wish to export has already been exported, whether to overwrite. default = False",
)
@click.option(
    "--make-tar/--no-tar",
    "make_tar",
    default=True,
    required=False,
    help="Do you want to compress the exported directory to a tar file? Default = True",
)
@click.pass_context
def export_model(_, *args, **kwargs):
    """Export DLC models for the model zoo or for live inference.

    Delegates to ``deeplabcut.export_model``.

    Saves the pose configuration, snapshot files, and frozen graph of the model to a
    directory named exported-models within the project directory.

    Args:
        cfg_path (string): Path to the DLC Project config.yaml file.
        iteration (int, optional): The model iteration you wish to export.
            If None, uses the iteration listed in the config file.
        shuffle (int, optional): The shuffle of the model to export. Defaults to 1.
        trainingsetindex (int, optional): Index of the training fraction for the model
            to export. Defaults to 0.
        snapshotindex (int, optional): The snapshot index for the weights you wish to
            export. If None, uses the snapshotindex as defined in config.yaml.
            Defaults to None.
        TFGPUinference (bool, optional): Use the tensorflow inference model?
            Defaults to True. For DeepLabCut-live, set TFGPUinference=False.
        overwrite (bool, optional): If the model was already exported, whether to
            overwrite. Defaults to False.
        make_tar (bool, optional): Compress the exported directory to a tar file?
            Defaults to True. Required for model zoo export, not for live inference.
    """
    from deeplabcut import export_model

    export_model(*args, **kwargs)

extract_frames

extract_frames(_, *args, **kwargs)

Extracts frames from the videos in the config.yaml file.

Delegates to deeplabcut.extract_frames.

Only the videos in the config.yaml will be used to select the frames. Use the function add_new_videos at any stage of the project to add new videos to the config file and extract their frames.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file as a string.

required

mode

string

Mode of extraction. Must be either automatic or manual.

required

algo

string

For automatic extraction, the algorithm to use:

required

crop

bool

If True, crop frames according to config.yaml parameters.

required

Examples:

For selecting frames automatically with 'kmeans' and do not want to crop the frames:

python3 dlc.py extract_frames /analysis/project/reaching-task/config.yaml \
    automatic --algo kmeans

For selecting frames automatically with 'uniform' and want to crop the frames based on the crop parameters in config.yaml:

python3 dlc.py extract_frames /analysis/project/reaching-task/config.yaml \
    automatic --crop

To select frames manually:

python3 dlc.py extract_frames /analysis/project/reaching-task/config.yaml manual

While selecting the frames manually, you do not need to specify the cropping parameters. Rather, you will get a prompt in the graphic user interface to choose if you need to crop or not.

Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.argument("mode")
@click.option(
    "-a",
    "--algo",
    "algo",
    default="uniform",
    help='For automatic extraction, specify the algorithm- "kmeans" or "uniform". Default is uniform.',
)
@click.option(
    "--crop",
    is_flag=True,
    default=False,
    help="Specify if you need to crop the image. Default is True.",
)
@click.pass_context
def extract_frames(_, *args, **kwargs):
    """Extracts frames from the videos in the config.yaml file.

    Delegates to ``deeplabcut.extract_frames``.

    Only the videos in the config.yaml will be used to select the frames. Use the
    function ``add_new_videos`` at any stage of the project to add new videos to the
    config file and extract their frames.

    Args:
        config (string): Full path of the config.yaml file as a string.
        mode (string): Mode of extraction. Must be either ``automatic`` or ``manual``.
        algo (string, optional): For automatic extraction, the algorithm to use:
        ``kmeans`` or ``uniform``. Defaults to ``uniform``.
        crop (bool, optional): If True, crop frames according to config.yaml parameters.
        Defaults to False.

    Examples:
        For selecting frames automatically with 'kmeans' and do not want to crop the frames:

        ```bash
        python3 dlc.py extract_frames /analysis/project/reaching-task/config.yaml \\
            automatic --algo kmeans
        ```

        For selecting frames automatically with 'uniform' and want to crop the frames based on
        the ``crop`` parameters in config.yaml:

        ```bash
        python3 dlc.py extract_frames /analysis/project/reaching-task/config.yaml \\
            automatic --crop
        ```

        To select frames manually:

        ```bash
        python3 dlc.py extract_frames /analysis/project/reaching-task/config.yaml manual
        ```

        While selecting the frames manually, you do not need to specify the cropping parameters.
        Rather, you will get a prompt in the graphic user interface to choose if you need to crop or not.
    """
    from deeplabcut.generate_training_dataset.frame_extraction import extract_frames as _extract_frames

    _extract_frames(*args, **kwargs)

extract_outlier_frames

extract_outlier_frames(_, *args, **kwargs)

Extracts the outlier frames in case, the predictions are not correct for a certain video from the cropped video running from start to stop as defined in config.yaml.

Delegates to deeplabcut.extract_outlier_frames.

Another crucial parameter in config.yaml is how many frames to extract 'numframes2extract'.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file as a string.

required

video

string

Full path of the video to extract frames from. Make sure that this video is already analyzed.

required

outlieralgorithm

string

Algorithm used to detect outliers. Defaults to fitting.

required

comparisonbodyparts

string

Body parts used for comparison. Defaults to all.

required

epsilon

float

Meaning depends on outlier algorithm. Defaults to 20.

required

p_bound

float

Likelihood threshold for uncertain algorithm. Defaults to 0.01.

required

ARdegree

int

Autoregressive degree for fitting algorithm. Defaults to 7.

required

MAdegree

int

Moving average degree for fitting algorithm. Defaults to 1.

required

alpha

float

Significance level for SARIMAX outlier detection. Defaults to 0.01.

required

extractionalgorithm

string

Algorithm for selecting outlier frames. Defaults to uniform.

required

Examples:

For extracting the frames with default settings:

python3 dlc.py extract_outlier_frames \
    /analysis/project/reaching-task/config.yaml \
    /analysis/project/video/reachinvideo1.avi

For extracting the frames with kmeans:

python3 dlc.py extract_outlier_frames \
    /analysis/project/reaching-task/config.yaml \
    /analysis/project/video/reachinvideo1.avi \
    --extractionalgorithm 'kmeans'

For extracting the frames with kmeans and epsilon = 5 pixels:

python3 dlc.py extract_outlier_frames \
    /analysis/project/reaching-task/config.yaml \
    /analysis/project/video/reachinvideo1.avi \
    --epsilon 5 --extractionalgorithm kmeans
Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.argument("videos")
@click.option(
    "-num",
    "--num_shuffles",
    "shuffle",
    default=1,
    help="The shuffle index of training dataset. The extracted frames will be stored in the "
    "labeled-dataset for the corresponding shuffle of training dataset. Default is set to 1",
)
@click.option(
    "-outlier",
    "--outlier_algo",
    "outlieralgorithm",
    default="fitting",
    help="String specifying the algorithm used to detect the outliers.\
        Currently, deeplabcut supports only sarimax (this will be updated). \
        This method fits a Seasonal AutoRegressive Integrated Moving Average with eXogenous regressors model \
        to data and computes confidence interval. \
        Based on the fraction of data points outside the confidence interval \
        and the average distance (compared to delta) \
        the user can identify potential outlier frames.\
        The default is set to ``fitting``. Other choices: `fitting`, `jump`, `uncertain`",
)
@click.option(
    "-compare",
    "--comparisonbodyparts",
    "comparisonbodyparts",
    default="all",
    help="This select the body parts for which the comparisons with the outliers are carried out. Either ``all``, \
          then all body parts from config.yaml are used orr a list of strings that are a subset of the full list.\
           E.g. [`hand`,`Joystick`]"
    " for the demo Reaching-Mackenzie-2018-08-30/config.yaml to select only these two body parts.",
)
@click.option(
    "-e",
    "--epsilon",
    "epsilon",
    default=20,
    help="Meaning depends on outlieralgoritm. The default is set to 20 pixels.For outlieralgorithm `fitting`: \
        Float bound according to which frames are picked when the (average)\
        body part estimate deviates from model fit. \
        For outlier algorithm `jump`:"
    "Float bound specifying the distance by which body points jump from one frame to next (Euclidean distance)",
)
@click.option(
    "-p",
    "--p_bound",
    "p_bound",
    default=0.01,
    help="For outlieralgorithm `uncertain` this parameter defines the likelihood below, "
    "below which a body part will be flagged as a putative outlier.",
)
@click.option(
    "-ard",
    "--ar_degree",
    "ARdegree",
    default=7,
    help="For outlieralgorithm `fitting`: Autoregressive degree of Sarimax model degree. \
          See https://www.statsmodels.org/dev/generated/statsmodels.tsa.statespace.sarimax.SARIMAX.html",
)
@click.option(
    "-mad",
    "--ma_degree",
    "MAdegree",
    default=1,
    help="Int value. For outlieralgorithm `fitting`: Moving Average degree of Sarimax model degree.\
           See https://www.statsmodels.org/dev/generated/statsmodels.tsa.statespace.sarimax.SARIMAX.html",
)
@click.option(
    "-a",
    "--alpha",
    "alpha",
    default=0.01,
    help="Significance level for detecting outliers based on confidence interval of fitted SARIMAX model.",
)
@click.option(
    "-extract",
    "--extraction_algo",
    "extractionalgorithm",
    default="uniform",
    help="String specifying the algorithm to use for selecting the frames from the identified outliers.\
        Currently, deeplabcut supports either ``kmeans`` or ``uniform``\
        based selection (same logic as for extract_frames).\
        The default is set to``uniform``,\
        if provided it must be either ``uniform`` or ``kmeans``.",
)
@click.pass_context
def extract_outlier_frames(_, *args, **kwargs):
    """Extracts the outlier frames in case, the predictions are not correct for a
    certain video from the cropped video running from start to stop as defined in
    config.yaml.

    Delegates to ``deeplabcut.extract_outlier_frames``.

    Another crucial parameter in config.yaml is how many frames to extract
    'numframes2extract'.

    Args:
        config (string): Full path of the config.yaml file as a string.
        video (string): Full path of the video to extract frames from. Make sure that
            this video is already analyzed.
        outlieralgorithm (string, optional): Algorithm used to detect outliers.
            Defaults to ``fitting``.
        comparisonbodyparts (string, optional): Body parts used for comparison.
            Defaults to ``all``.
        epsilon (float, optional): Meaning depends on outlier algorithm. Defaults to 20.
        p_bound (float, optional): Likelihood threshold for ``uncertain`` algorithm.
            Defaults to 0.01.
        ARdegree (int, optional): Autoregressive degree for ``fitting`` algorithm.
            Defaults to 7.
        MAdegree (int, optional): Moving average degree for ``fitting`` algorithm.
            Defaults to 1.
        alpha (float, optional): Significance level for SARIMAX outlier detection.
            Defaults to 0.01.
        extractionalgorithm (string, optional): Algorithm for selecting outlier frames.
            Defaults to ``uniform``.

    Examples:
        For extracting the frames with default settings:

        ```bash
        python3 dlc.py extract_outlier_frames \\
            /analysis/project/reaching-task/config.yaml \\
            /analysis/project/video/reachinvideo1.avi
        ```

        For extracting the frames with kmeans:

        ```bash
        python3 dlc.py extract_outlier_frames \\
            /analysis/project/reaching-task/config.yaml \\
            /analysis/project/video/reachinvideo1.avi \\
            --extractionalgorithm 'kmeans'
        ```

        For extracting the frames with kmeans and epsilon = 5 pixels:

        ```bash
        python3 dlc.py extract_outlier_frames \\
            /analysis/project/reaching-task/config.yaml \\
            /analysis/project/video/reachinvideo1.avi \\
            --epsilon 5 --extractionalgorithm kmeans
        ```
    """
    from deeplabcut.refine_training_dataset import outlier_frames

    outlier_frames.extract_outlier_frames(*args, **kwargs)

label_frames

label_frames(_, config)

Manually label/annotate the extracted frames.

Delegates to deeplabcut.label_frames.

Update the list of body parts you want to localize in the config.yaml file first.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file.

required

Examples:

To launch the frame labeling GUI:

python3 dlc.py label_frames /analysis/project/reaching-task/config.yaml

Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.pass_context
def label_frames(_, config):
    """Manually label/annotate the extracted frames.

    Delegates to ``deeplabcut.label_frames``.

    Update the list of body parts you want to localize in the config.yaml file first.

    Args:
        config (string): Full path of the config.yaml file.

    Examples:
        To launch the frame labeling GUI:
        ```bash
        python3 dlc.py label_frames /analysis/project/reaching-task/config.yaml
        ```
    """
    from deeplabcut.gui.tabs.label_frames import label_frames as _label_frames

    _label_frames(config)

plot_trajectories

plot_trajectories(_, *args, **kwargs)

Plots the trajectories of various bodyparts across the video.

Delegates to deeplabcut.plot_trajectories.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file.

required

videos

list

Full path(s) to video(s).

required

shuffle

int

Shuffle index of the training dataset. Defaults to 1.

required

video_extensions

string

Video extension when the input is a directory.

required

showfigures

bool

Also display plots interactively. Defaults to False.

required

Examples:

For plotting trajectories:

python3 dlc.py plot_trajectories
    /analysis/project/reaching-task/config.yaml \
    /analysis/project/videos/reachingvideo1.avi

Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.argument("videos", nargs=-1)
@click.option(
    "-num",
    "--num_shuffles",
    "shuffle",
    default=1,
    help="Number of shuffles of training dataset. Default is set to 1.",
)
@click.option(
    "-v",
    "--video_type",
    "video_extensions",
    default=".avi",
    help="Checks for the extension of the video in case the input is a directory.\
          Only videos with this extension are analyzed. The default is ``.avi``",
)
@click.option(
    "-s",
    "--show",
    "showfigures",
    is_flag=True,
    default=False,
    help="If true then plots are also displayed simultaneously.",
)
@click.pass_context
def plot_trajectories(_, *args, **kwargs):
    """Plots the trajectories of various bodyparts across the video.

    Delegates to ``deeplabcut.plot_trajectories``.

    Args:
        config (string): Full path of the config.yaml file.
        videos (list): Full path(s) to video(s).
        shuffle (int, optional): Shuffle index of the training dataset. Defaults to 1.
        video_extensions (string, optional): Video extension when the input is a directory.
        Defaults to ``.avi``.
        showfigures (bool, optional): Also display plots interactively. Defaults to False.

    Examples:
        For plotting trajectories:
        ```bash
        python3 dlc.py plot_trajectories
            /analysis/project/reaching-task/config.yaml \\
            /analysis/project/videos/reachingvideo1.avi
        ```
    """
    from deeplabcut.utils import plotting

    plotting.plot_trajectories(*args, **kwargs)

refine_labels

refine_labels(_, config)

Refines the labels of the outlier frames extracted from the analyzed videos.

Delegates to deeplabcut.refine_labels.

Helps in augmenting the training dataset. Use the function analyze_videos to analyze a video and extract the outlier frames using extract_outlier_frames before refining the labels.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file.

required

Examples:

To refine the labels:

python3 dlc.py refine_labels /analysis/project/reaching-task/config.yaml

Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.pass_context
def refine_labels(_, config):
    """Refines the labels of the outlier frames extracted from the analyzed videos.

    Delegates to ``deeplabcut.refine_labels``.

    Helps in augmenting the training dataset. Use the function ``analyze_videos`` to
    analyze a video and extract the outlier frames using ``extract_outlier_frames``
    before refining the labels.

    Args:
        config (string): Full path of the config.yaml file.

    Examples:
        To refine the labels:
        ```bash
        python3 dlc.py refine_labels /analysis/project/reaching-task/config.yaml
        ```
    """
    from deeplabcut.refine_training_dataset import outlier_frames

    outlier_frames.refine_labels(config)

train_network

train_network(_, *args, **kwargs)

Train a trained Feature detector with a specific training data set.

Delegates to deeplabcut.train_network.

Parameters:

Name Type Description Default

config

string

Full path of the config.yaml file in the train directory of a project.

required

shuffle

int

Shuffle index of the training dataset. Defaults to 1.

required

Examples:

To train the network with the default settings:

python3 dlc.py step7_train /home/project/reaching/config.yaml
Source code in deeplabcut/cli.py
@main.command(context_settings=CONTEXT_SETTINGS)
@click.argument("config")
@click.option(
    "-num",
    "--num_shuffles",
    "shuffle",
    default=1,
    help="Shuffle index of the training dataset. Default is set to 1.",
)
@click.pass_context
def train_network(_, *args, **kwargs):
    """Train a trained Feature detector with a specific training data set.

    Delegates to ``deeplabcut.train_network``.

    Args:
        config (string): Full path of the config.yaml file in the train directory of a
            project.
        shuffle (int, optional): Shuffle index of the training dataset. Defaults to 1.

    Examples:
        To train the network with the default settings:

    ```bash
    python3 dlc.py step7_train /home/project/reaching/config.yaml
    ```
    """
    from deeplabcut.pose_estimation_tensorflow import training

    training.train_network(*args, **kwargs)