clearex.detect.particles
Functions
|
Detect bright blob-like particles in a normalized 2D image. |
Eliminate insignificant point sources. |
|
|
Refine blob centroids with local intensity weighting. |
|
Normalize an image for particle detection. |
|
Remove close particles. |
|
Sort blobs by their intensity in the given image. |
- clearex.detect.particles.detect_particles(img, fwhm_px=10.0, sigma_min_factor=0.7, sigma_max_factor=1.7, sigma_ratio=1.2, threshold=0.03, overlap=0.5, exclude_border=0)
Detect bright blob-like particles in a normalized 2D image.
- Parameters:
img (numpy.ndarray) – Input image containing bright particles on a dark background. If the source data are dark-on-bright, invert the image before calling this helper.
fwhm_px (float, default=10.0) – Expected particle full width at half maximum, in pixels.
sigma_min_factor (float, default=0.7) – Multiplier applied to the inferred sigma when computing the minimum scale for Difference-of-Gaussians detection.
sigma_max_factor (float, default=1.7) – Multiplier applied to the inferred sigma when computing the maximum scale for Difference-of-Gaussians detection.
sigma_ratio (float, default=1.2) – Geometric ratio between successive scales evaluated by
skimage.feature.blob_dog().threshold (float, default=0.03) – Absolute detection threshold passed to
blob_dog().overlap (float, default=0.5) – Maximum allowed overlap fraction between detected blobs before the weaker blob is suppressed.
exclude_border (int or tuple of int or bool, default=0) – Border exclusion rule forwarded to
blob_dog().
- Returns:
Detected blobs with columns
(row, col, sigma).- Return type:
numpy.ndarray
- clearex.detect.particles.preprocess(img, bg_sigma=20)
Normalize an image for particle detection.
- Parameters:
img (numpy.ndarray) – Input 2D image or 3D image with the channel axis last.
bg_sigma (float, default=20) – Gaussian sigma used to estimate the low-frequency background.
- Returns:
Background-subtracted image rescaled to the
[0, 1]range.- Return type:
numpy.ndarray
- clearex.detect.particles.intensity_weighted_centroids(img, blobs, radius_factor=2.0, local_baseline_percentile=20)
Refine blob centroids with local intensity weighting.
- Parameters:
img (numpy.ndarray) – Input 2D image used to compute local weighted centroids.
blobs (numpy.ndarray) – Blob detections with columns
(row, col, sigma).radius_factor (float, default=2.0) – Multiplier that expands the centroiding window relative to blob scale.
local_baseline_percentile (float, default=20) – Local intensity percentile subtracted before computing weighted coordinates.
- Returns:
Refined blob coordinates with the same
(row, col, sigma)layout as the input detections.- Return type:
numpy.ndarray
- clearex.detect.particles.remove_close_blobs(blobs, image, min_dist)
Remove close particles.
Remove blobs that are too close to each other using an ellipsoidal search volume defined by the blob’s sigma values, discarding the blob with the lower absolute intensity at its centroid.
distance=0: No filtering (all blobs kept) distance=1: Blobs must be at least 1× their sigma apart distance=10 (default): Blobs must be at least 10× their sigma apart
- Parameters:
blobs (np.ndarray) – An Nx4 or Nx6 array of blobs. For isotropic blobs, each row is [z, y, x, sigma]. For anisotropic blobs, each row is [z, y, x, z_sigma, y_sigma, x_sigma].
image (np.ndarray) – The 3D image data from which intensities at blob centers will be extracted.
min_dist (float) – A scaling factor for the sigma values to determine the ellipsoidal search volume. If min_dist is 0 or very small, no filtering is performed.
- Returns:
The filtered array of blobs.
- Return type:
np.ndarray
- clearex.detect.particles.sort_by_point_source_intensity(blobs, image)
Sort blobs by their intensity in the given image.
- Parameters:
blobs (np.ndarray) – An Nx4 or Nx6 array of blobs. For isotropic blobs, each row is [z, y, x, sigma]. For anisotropic blobs, each row is [z, y, x, z_sigma, y_sigma, x_sigma].
image (np.ndarray) – The 3D image data from which intensities at blob centers will be extracted.
- Returns:
The sorted array of blobs.
- Return type:
np.ndarray
- clearex.detect.particles.eliminate_insignificant_point_sources(chunk_iso, particle_location)
Eliminate insignificant point sources.
Evaluate whether the point source is statistically significant relative to the local background. This is done by comparing the point sources’s intensity to the mean and standard deviation of a local region. If the point sources’s intensity is greater than the mean + 2 * std, it is considered significant.
- Parameters:
chunk_iso (np.ndarray) – The 3D image.
particle_location (np.ndarray) – The locations of the blobs. Can be Nx4 (isotropic) or Nx6 (anisotropic).
- Returns:
significant_blobs – The significant blobs.
- Return type:
np.ndarray