remove_bad_ppv_branches#

crispy.pruning.pruning.remove_bad_ppv_branches(labBodyPtAry, num_lab, refStructure=None, max_pp_length=9.0, v2pp_ratio=1.5, method='full')[source]#

Remove unphysical branches from a labeled 3D skeleton in PPV space.

This function identifies and removes branches that are likely unphysical, such as those with small projected lengths in the position-position (PP) plane or with high velocity-to-length ratios. Optionally, a faster approximation method can be used for branch filtering.

Parameters:
  • labBodyPtAry (ndarray) – A 3D array of the skeleton with body points removed, where branches are labeled with unique integers.

  • num_lab (int) – Number of labeled branches in the array.

  • refStructure (ndarray, optional, default=None) – The reference structure array (full skeleton). If None, it is derived from labBodyPtAry.

  • max_pp_length (float, optional, default=9.0) – Maximum allowed length of a branch in the PP plane. Branches shorter than this threshold are evaluated for removal.

  • v2pp_ratio (float, optional, default=1.5) – Minimum allowed velocity-to-length ratio. Branches exceeding this ratio are removed.

  • method ({"full", "quick"}, optional, default="full") – Method for branch filtering: - “full”: Performs a detailed analysis using branch traversal and length calculations. - “quick”: Uses a faster, approximate method for filtering based on pixel counts.

Returns:

filtered_structure – A binary array of the reference structure with unphysical branches removed.

Return type:

ndarray

Notes

  • The “full” method uses walk_through_segment_3D to accurately calculate branch lengths and velocity ratios.

  • The “quick” method approximates branch lengths by counting pixels, which may be less accurate for longer branches.

  • Branch removal may fail if labBodyPtAry and refStructure have mismatched shapes.

Raises:

ValueError – If the shapes of labBodyPtAry and refStructure do not match.