ValidBboxesInputs#
- class movement.validators.datasets.ValidBboxesInputs(*, position_array, confidence_array=None, individual_names=None, fps=None, source_software=None, shape_array, frame_array=None)[source]#
Bases:
_BaseDatasetInputsClass for validating input data for a
movement bboxesdataset.The validator considers 2D bounding boxes only. It ensures that within the
movement bboxesdataset:The required
position_arrayandshape_arrayare numpy arrays of shape (n_frames, n_space, n_individuals) with thespacedimension containing 2 spatial coordinates. Theposition_arraycontains the tracks of the bounding box centroids, while theshape_arraycontains the width and height of the bounding boxes.The optional
confidence_array, if provided, is a numpy array containing confidence scores for the bounding boxes, with its shape matching that of theposition_array, excluding thespacedimension; otherwise, it defaults to an array of NaNs.The optional
individual_names, if provided, is a list of unique names for the individuals, with length matching the number of individuals in the dataset; otherwise, default names are assigned.The optional
frame_array, if provided, is a column vector with the frame numbers; otherwise, it defaults to an array of 0-based integers.The optional
fpsis a positive float; otherwise, it defaults to None.The optional
source_softwareis a string; otherwise, it defaults to None.
- Raises:
ValueError – If the dataset does not meet the
movement bboxesdataset requirements.
Methods
Convert validated bboxes inputs to a
movement bboxesdataset.validate(ds)Validate that the dataset has the required variables and dimensions.
- classmethod validate(ds)#
Validate that the dataset has the required variables and dimensions.
- Parameters:
ds (
Dataset) – Dataset to validate.- Raises:
TypeError – If the input is not an xarray Dataset.
ValueError – If the dataset is missing required data variables or dimensions for a valid
movementdataset.
- Return type:
- to_dataset()[source]#
Convert validated bboxes inputs to a
movement bboxesdataset.- Returns:
movementdataset containing the bounding boxes tracks, shapes, confidence scores and associated metadata.- Return type:
- DIM_NAMES: ClassVar[tuple[str, ...]] = ('time', 'space', 'individuals')#
Required dimension names for the dataset. The order of dimension names must match the order of dimensions in the
position_array.
- VAR_NAMES: ClassVar[tuple[str, ...]] = ('position', 'shape', 'confidence')#
Required variable names for the dataset.
- confidence_array: ndarray | None#
Array containing point-wise confidence scores for the position data. The shape of this array is the same as that of
position_array, but without thespacedimension. If None (default), the confidence scores will be set to an array of NaNs.
- fps: float | None#
Frames per second of the video. If None (default), time coordinates will be expressed in frames. If a non-positive value is provided, fps will be set to None and a warning will be issued.
- frame_array: ndarray | None#
Array containing the frame numbers for which bounding boxes are defined. The frame_array should be a column vector of shape (n_frames, 1) and should be monotonically increasing. If None (default), frame numbers will be assigned based on the first dimension of the position_array, starting from 0.
- individual_names: list[str] | None#
List of unique names for the individuals in the video. The length of this list should match the size of the ‘individuals’ dimension in the
position_array. If None (default), the names will be in the format ofid_<N>, where <N> is an integer from 0 to the size of the ‘individuals’ dimension minus 1.