Skeleton#
- class crispy.pruning.Skeleton.Skeleton(skeleton_raw, header=None, img=None, min_size=3)[source]#
Bases:
objectRepresents a skeletonized structure with tools for pruning, analyzing, and processing filament data.
- classify_structure()[source]#
Classify the skeleton into labeled branches, intersection points, and endpoints.
This method processes the skeleton to identify its components and assigns unique labels to individual branches while detecting intersections and endpoints.
- init_branch_properties(img=None, use_skylength=True)[source]#
Initialize the properties of branches in the skeleton.
- Parameters:
img (ndarray, optional) – A reference image used to calculate intensity-based properties. Defaults to None.
use_skylength (bool, optional) – Whether to use sky-projected length for branch calculations. Defaults to True.
- longest_path()[source]#
Identify the longest path within the graph representation of the skeleton.
This method calculates the maximum-length path through the skeleton’s graph.
- main_length()[source]#
Compute the main lengths of the pruned skeleton and generate labeled spines.
This method calculates the overall length of the skeleton and identifies the main branches.
- pre_graph()[source]#
Prepare the graph representation of the skeleton, defining nodes and edges.
This method generates the graph structure based on labeled branches, intersection points, and endpoints in the skeleton.
- prune_from_scratch(use_skylength=True, remove_bad_ppv=True)[source]#
Executes the full pruning process on the skeleton, including classification, branch property initialization, graph pruning, and length determination.
- Parameters:
use_skylength (bool, optional) – Whether to use sky-projected length for pruning and branch properties. Defaults to True.
remove_bad_ppv (bool, optional) – If True, removes branches with unphysical aspect ratios in position-position-velocity (PPV) space. This is only applicable for 3D skeletons. Defaults to True.
Notes
This method performs the following sequential steps: 1. Removes bad branches if remove_bad_ppv is True (3D only). 2. Classifies the skeleton structure into branches and intersections. 3. Initializes branch properties based on intensity or geometry. 4. Prepares the graph representation of the skeleton. 5. Finds the longest path within the skeleton graph. 6. Prunes the graph based on specified criteria. 7. Computes the main length of the pruned skeleton.
Timing information for the pruning process is printed upon completion.
- prune_graph(length_thresh=0.5)[source]#
Prune the skeleton graph based on a specified length threshold.
- Parameters:
length_thresh (float, optional) – The minimum branch length to retain in the pruned graph. Defaults to 0.5.
- remove_bad_branches(v2pp_ratio=1.0)[source]#
Removes branches with unphysical aspect ratios in position-position-velocity (PPV) space.
- Parameters:
v2pp_ratio (float, optional) – The maximum allowable ratio of velocity to positional gradients. Branches exceeding this ratio are considered “bad” and are removed. Defaults to 1.0.
Notes
This method identifies and removes branches that have unphysical velocity gradients in the PPV space. The skeleton is re-skeletonized after removal to ensure consistency.
Timing information for the branch removal process is printed upon completion.
- save_pruned_skel(outpath, overwrite=True)[source]#
Saves the pruned skeleton data to a FITS file.
- Parameters:
Notes
If the length_thresh attribute has not been set prior to calling this method, it will automatically compute the main length of the pruned skeleton before saving. The pruned skeleton data is saved in a labeled format, which can be extended for future analysis or visualization purposes.