deepof.data.Project

class deepof.data.Project(animal_ids: List | None = None, arena: str = 'polygonal-autodetect', bodypart_graph: str | dict = 'deepof_14', enable_iterative_imputation: bool = True, exclude_bodyparts: List = ('',), exp_conditions: dict | None = None, interpolate_outliers: bool = True, interpolation_limit: int = 5, interpolation_std: int = 3, likelihood_tol: float = 0.75, model: str = 'mouse_topview', project_name: str = 'deepof_project', project_path: str = '.', video_path: str | None = None, table_path: str | None = None, rename_bodyparts: list | None = None, sam_checkpoint_path: str | None = None, smooth_alpha: float = 1, table_format: str = 'autodetect', video_format: str = '.mp4', video_scale: int = 1)

Class for loading and preprocessing motion tracking data of individual and multiple animals.

All main computations are handled from here.

__init__(animal_ids: List | None = None, arena: str = 'polygonal-autodetect', bodypart_graph: str | dict = 'deepof_14', enable_iterative_imputation: bool = True, exclude_bodyparts: List = ('',), exp_conditions: dict | None = None, interpolate_outliers: bool = True, interpolation_limit: int = 5, interpolation_std: int = 3, likelihood_tol: float = 0.75, model: str = 'mouse_topview', project_name: str = 'deepof_project', project_path: str = '.', video_path: str | None = None, table_path: str | None = None, rename_bodyparts: list | None = None, sam_checkpoint_path: str | None = None, smooth_alpha: float = 1, table_format: str = 'autodetect', video_format: str = '.mp4', video_scale: int = 1)

Initialize a Project object.

Parameters:
  • animal_ids (list) – list of animal ids.

  • arena (str) – arena type. Can be one of “circular-autodetect”, “circular-manual”, “polygonal-autodetect”, or “polygonal-manual”.

  • bodypart_graph (str) – body part scheme to use for the analysis. Defaults to None, in which case the program will attempt to select it automatically based on the available body parts.

  • enable_iterative_imputation (bool) – whether to use iterative imputation for occluded body parts.

  • exclude_bodyparts (list) – list of bodyparts to exclude from analysis.

  • exp_conditions (dict) – dictionary with experiment IDs as keys and experimental conditions as values.

  • interpolate_outliers (bool) – whether to interpolate missing data.

  • interpolation_limit (int) – maximum number of missing frames to interpolate.

  • interpolation_std (int) – maximum number of standard deviations to interpolate.

  • likelihood_tol (float) – likelihood threshold for outlier detection.

  • model (str) – model to use for pose estimation. Defaults to ‘mouse_topview’ (as described in the documentation).

  • project_name (str) – name of the current project.

  • project_path (str) – path to the folder containing the motion tracking output data.

  • video_path (str) – path where to find the videos to use. If not specified, deepof, assumes they are in your project path.

  • table_path (str) – path where to find the tracks to use. If not specified, deepof, assumes they are in your project path.

  • rename_bodyparts (list) – list of names to use for the body parts in the provided tracking files. The order should match that of the columns in your DLC tables or the node dimensions on your (S)LEAP .npy files.

  • sam_checkpoint_path (str) – path to the checkpoint file for the SAM model. If not specified, the model will be saved in the installation folder.

  • smooth_alpha (float) – smoothing intensity. The higher the value, the more smoothing.

  • table_format (str) – format of the table. Defaults to ‘autodetect’, but can be set to “csv” or “h5” for DLC output, and “npy”, “slp” or “analysis.h5” for (S)LEAP.

  • video_format (str) – video format. Defaults to ‘.mp4’.

  • video_scale (int) – diameter of the arena in mm (if the arena is round) or length of the first specified arena side (if the arena is polygonal).

Methods

__init__([animal_ids, arena, ...])

Initialize a Project object.

create([verbose, force, debug, test, _to_extend])

Generate a deepof.Coordinates dataset using all the options specified during initialization.

extend(project_to_extend[, verbose, debug, test])

Generate a deepof.Coordinates dataset using all the options specified during initialization.

get_angles(tab_dict[, verbose])

Compute all the angles between adjacent bodypart trios per video and per frame in the data.

get_areas(tab_dict[, verbose])

Compute all relevant areas (head, torso, back) per video and per frame in the data.

get_arena(tables[, verbose, debug, test])

Return the arena as recognised from the videos.

get_distances(tab_dict[, verbose])

Compute the distances between all selected body parts over time.

load_tables([verbose])

Load videos and tables into dictionaries.

set_up_project_directory([debug])

Create a project directory where to save all produced results.

Attributes

angles

Bool.

distances

List.

ego

String, name of a body part.

__init__(animal_ids: List | None = None, arena: str = 'polygonal-autodetect', bodypart_graph: str | dict = 'deepof_14', enable_iterative_imputation: bool = True, exclude_bodyparts: List = ('',), exp_conditions: dict | None = None, interpolate_outliers: bool = True, interpolation_limit: int = 5, interpolation_std: int = 3, likelihood_tol: float = 0.75, model: str = 'mouse_topview', project_name: str = 'deepof_project', project_path: str = '.', video_path: str | None = None, table_path: str | None = None, rename_bodyparts: list | None = None, sam_checkpoint_path: str | None = None, smooth_alpha: float = 1, table_format: str = 'autodetect', video_format: str = '.mp4', video_scale: int = 1)

Initialize a Project object.

Parameters:
  • animal_ids (list) – list of animal ids.

  • arena (str) – arena type. Can be one of “circular-autodetect”, “circular-manual”, “polygonal-autodetect”, or “polygonal-manual”.

  • bodypart_graph (str) – body part scheme to use for the analysis. Defaults to None, in which case the program will attempt to select it automatically based on the available body parts.

  • enable_iterative_imputation (bool) – whether to use iterative imputation for occluded body parts.

  • exclude_bodyparts (list) – list of bodyparts to exclude from analysis.

  • exp_conditions (dict) – dictionary with experiment IDs as keys and experimental conditions as values.

  • interpolate_outliers (bool) – whether to interpolate missing data.

  • interpolation_limit (int) – maximum number of missing frames to interpolate.

  • interpolation_std (int) – maximum number of standard deviations to interpolate.

  • likelihood_tol (float) – likelihood threshold for outlier detection.

  • model (str) – model to use for pose estimation. Defaults to ‘mouse_topview’ (as described in the documentation).

  • project_name (str) – name of the current project.

  • project_path (str) – path to the folder containing the motion tracking output data.

  • video_path (str) – path where to find the videos to use. If not specified, deepof, assumes they are in your project path.

  • table_path (str) – path where to find the tracks to use. If not specified, deepof, assumes they are in your project path.

  • rename_bodyparts (list) – list of names to use for the body parts in the provided tracking files. The order should match that of the columns in your DLC tables or the node dimensions on your (S)LEAP .npy files.

  • sam_checkpoint_path (str) – path to the checkpoint file for the SAM model. If not specified, the model will be saved in the installation folder.

  • smooth_alpha (float) – smoothing intensity. The higher the value, the more smoothing.

  • table_format (str) – format of the table. Defaults to ‘autodetect’, but can be set to “csv” or “h5” for DLC output, and “npy”, “slp” or “analysis.h5” for (S)LEAP.

  • video_format (str) – video format. Defaults to ‘.mp4’.

  • video_scale (int) – diameter of the arena in mm (if the arena is round) or length of the first specified arena side (if the arena is polygonal).