init_branch_properties#
- crispy.pruning.pruning.init_branch_properties(labelisofil, ndim, img=None, use_skylength=True)[source]#
Initialize branch properties for 2D or 3D skeletons.
Computes lengths and intensities of branches in skeletons, supporting both 2D and 3D skeleton structures. For 2D skeletons, the lengths are initialized using init_lengths_2D, while for 3D skeletons, init_lengths_3D is used.
- Parameters:
labelisofil (list of ndarray) – A list of labeled skeleton arrays, where branches are labeled with unique integers, and intersections have been removed.
ndim (int) – The number of dimensions of the skeletons. Must be either 2 or 3.
img (ndarray, optional) – Intensity image associated with the skeletons. If provided, the average intensity along each branch is calculated. Defaults to None.
use_skylength (bool, optional) – If True, calculates the sky-projected length for each branch (ignoring the velocity axis). If False, calculates the full 3D length in PPV space for 3D skeletons. Defaults to True.
- Returns:
branch_properties – A dictionary containing the following keys: - length: List of branch lengths. - intensity: List of average intensities for each branch. - pixels: List of pixel coordinates for each branch.
- Return type:
Notes
The function dispatches to different implementations depending on the dimensionality (ndim).
This code is based on the 2D version seen in FilFinder (v1.7.2) by Eric Koch, which as been depreciated
Examples
Initialize branch properties for a 2D skeleton:
>>> import numpy as np >>> from crispy import grid_ridge >>> skel = np.zeros((5, 5), dtype=bool) >>> skel[2, 1:4] = True >>> labelisofil = [skel.astype(int)] >>> props = grid_ridge.init_branch_properties(labelisofil, ndim=2) >>> print(props["length"]) [[2.0]]