from_numpy#

movement.io.load_poses.from_numpy(position_array, confidence_array=None, individual_names=None, keypoint_names=None, fps=None, source_software=None)[source]#

Create a movement poses dataset from NumPy arrays.

Parameters:
  • position_array (np.ndarray) – Array of shape (n_frames, n_individuals, n_keypoints, n_space) containing the poses. It will be converted to a xarray.DataArray object named “position”.

  • confidence_array (np.ndarray, optional) – Array of shape (n_frames, n_individuals, n_keypoints) containing the point-wise confidence scores. It will be converted to a xarray.DataArray object named “confidence”. If None (default), the scores will be set to an array of NaNs.

  • individual_names (list of str, optional) – List of unique names for the individuals in the video. If None (default), the individuals will be named “individual_0”, “individual_1”, etc.

  • keypoint_names (list of str, optional) – List of unique names for the keypoints in the skeleton. If None (default), the keypoints will be named “keypoint_0”, “keypoint_1”, etc.

  • fps (float, optional) – Frames per second of the video. Defaults to None, in which case the time coordinates will be in frame numbers.

  • source_software (str, optional) – Name of the pose estimation software from which the data originate. Defaults to None.

Returns:

movement dataset containing the pose tracks, confidence scores, and associated metadata.

Return type:

xarray.Dataset

Examples

Create random position data for two individuals, Alice and Bob, with three keypoints each: snout, centre, and tail_base. These are tracked in 2D space over 100 frames, at 30 fps. The confidence scores are set to 1 for all points.

>>> import numpy as np
>>> from movement.io import load_poses
>>> ds = load_poses.from_numpy(
...     position_array=np.random.rand((100, 2, 3, 2)),
...     confidence_array=np.ones((100, 2, 3)),
...     individual_names=["Alice", "Bob"],
...     keypoint_names=["snout", "centre", "tail_base"],
...     fps=30,
... )