clearex.segmentation.tubes
Functions
|
Segment fine, tubular structures using vesselness filtering. |
- clearex.segmentation.tubes.segment_tubular_structures(img, sigmas=(1, 2, 3, 4), use_sato=True, bright_ridges=True, min_obj_voxels=200, clean_ball_radius=1)
Segment fine, tubular structures using vesselness filtering.
Detects ridge-like structures (e.g., neurites, axons, blood vessels, filaments) using Sato or Frangi vesselness filters followed by thresholding and morphological cleanup.
- Parameters:
img (NDArray[np.floating]) – 3D input image array. Will be normalized to [0, 1] internally.
sigmas (tuple[float, ...], optional) – Scales (in pixels) for multi-scale vesselness detection. Should be tuned to match the expected radii of tubular structures in your data. Default is (1, 2, 3, 4).
use_sato (bool, optional) – If True, use Sato vesselness filter. If False, use Frangi filter. Sato is generally more robust for neurites/axons, while Frangi suppresses blob/plate responses more strongly. Default is True.
bright_ridges (bool, optional) – If True, detect bright tubular structures on dark background. If False, detect dark structures on bright background. Default is True.
min_obj_voxels (int, optional) – Minimum object size in voxels. Objects smaller than this are removed. Default is 200.
clean_ball_radius (int, optional) – Radius of the ball structuring element used for morphological closing to connect small gaps. Default is 1.
- Returns:
binary_mask (NDArray[np.bool_]) – Binary segmentation mask of detected tubular structures.
vesselness_response (NDArray[np.float32]) – Normalized vesselness response image in range [0, 1].
- Return type:
tuple[numpy.ndarray[Any, numpy.dtype[numpy.bool_]], numpy.ndarray[Any, numpy.dtype[numpy.float32]]]
Notes
- The pipeline consists of:
Intensity normalization to [0, 1] using 1st/99th percentiles
Non-local means denoising to preserve ridge structures
White top-hat transform for background subtraction
Multi-scale Sato or Frangi vesselness filtering
Adaptive thresholding (max of Otsu and 75th percentile)
Morphological closing and small object removal
Examples
>>> mask, response = segment_tubular_structures(volume, sigmas=(1, 2, 3)) >>> viewer.add_labels(mask.astype(int), name='filaments')