Skip to main content

preprocessing.alignment

logger_config​

logger​

calculate_geometric_distance​

def calculate_geometric_distance(positions, keypoint1_idx, keypoint2_idx)

Calculate the geometric distance between two keypoints. Parameters​

positions : np.ndarray Array of positions with shape (time, space, keypoints, individuals) or (time, space, keypoints) keypoint1_idx : int Index of the first keypoint keypoint2_idx : int Index of the second keypoint Returns​

np.ndarray Array of distances with shape (time, individuals) or (time,)

egocentrically_align_and_center​

def egocentrically_align_and_center(
config: dict,
centered_reference_keypoint: str = "snout",
orientation_reference_keypoint: str = "tailbase",
read_from_variable: str = "position_processed",
save_to_variable: str = "position_egocentric_aligned",
save_logs: bool = True) -> None

Aligns the time series by first centralizing all positions around the first keypoint and then applying rotation to align with the line connecting the two keypoints.

Parameters

  • config (dict): Configuration dictionary
  • centered_reference_keypoint (str): Name of the keypoint to use as centered reference.
  • orientation_reference_keypoint (str): Name of the keypoint to use as orientation reference.
  • read_from_variable (str): Variable to read from the dataset.
  • save_to_variable (str): Variable to save the aligned data to.
  • save_logs (bool, optional): Whether to save logs.

Returns

  • None

egocentrically_align_dataset​

def egocentrically_align_dataset(ds: xr.Dataset,
centered_reference_keypoint: str,
orientation_reference_keypoint: str,
read_from_variable: str,
save_to_variable: str) -> None

Center and rotate one session's dataset on two reference keypoints, in place. Also stores the per-individual body scale as individual_scale.

Parameters

  • ds (xr.Dataset): Session dataset.
  • centered_reference_keypoint (str): Name of the keypoint to use as centered reference.
  • orientation_reference_keypoint (str): Name of the keypoint to use as orientation reference.
  • read_from_variable (str): Variable to read from the dataset.
  • save_to_variable (str): Variable to save the aligned data to.

Returns

  • None