clean_grid_ppv#
- crispy.grid_ridge.clean_grid_ppv(coord, refdata, coord_in_xfirst=False, start_index=1, min_length=6, method='robust')[source]#
Process and grid CRISPy coordinates in PPV space onto a reference image, labeling and cleaning skeleton structures.
Grids CRISPy coordinates onto a position-position-velocity (PPV) reference image, labels distinct ridge structures using DBSCAN, and removes endpoints to prevent overlap between structures. Structures shorter than a specified projected length are filtered out, and vertical segments are truncated based on a velocity threshold.
- Parameters:
coord (ndarray) – Coordinates of the ridge points, shape (n, D), where n is the number of points and D is the dimensionality (typically 3D in PPV space).
refdata (ndarray) – Reference PPV image array defining the grid dimensions.
coord_in_xfirst (bool, optional, default=False) – If True, assumes the input coordinates are ordered with x as the first axis. If False, assumes z is the first axis.
start_index (int, optional, default=1) – The starting index for gridding the skeleton onto the reference image.
min_length (int, optional, default=6) – Minimum projected length (in pixels) for structures to be retained.
method ({"robust", "fast"}, optional, default="robust") – Method for cleaning skeleton endpoints: - “robust”: Handles diagonal connections but is computationally intensive. - “fast”: Faster but may miss diagonally connected structures.
- Returns:
skel_cube – Binary array with the same shape as refdata, where gridded skeleton structures are set to True.
- Return type:
ndarray
Notes
DBSCAN is used to label ridge structures with higher resultion than the image grid
Endpoints are removed to avoid overlap between distinct structures.
Vertical segments in velocity are removed based on a threshold (delVelMax set to 2 pixels).
The current implementation supports only 3D PPV data.
Examples
Grid and clean ridge coordinates in PPV space:
>>> import numpy as np >>> from crispy import grid_ridge >>> coords = np.array([[0, 0, 0], [1, 1, 1], [10, 10, 10]]) >>> ref_image = np.zeros((20, 20, 20)) # Reference PPV image >>> skel_cube = grid_ridge.clean_grid_ppv(coords, ref_image, min_length=5, method="robust") >>> print(skel_cube.shape) (20, 20, 20)