phenotypic.refine.LowCircularityRemover#
- class phenotypic.refine.LowCircularityRemover(cutoff: float = 0.785)[source]
Bases:
ObjectRefinerRemove objects whose Polsby-Popper circularity falls below a cutoff.
Computes circularity as
4 * pi * area / perimeter^2for each labeled object and discards those below the threshold. Keeps well-formed, roughly circular colonies while filtering out elongated artifacts, merged blobs, and segmentation debris.- Parameters:
cutoff (float) – Minimum Polsby-Popper circularity in
[0, 1]required to retain an object. Typical range: 0.5–0.9. Higher values keep only near-circular shapes; lower values tolerate irregular morphologies. Default: 0.785.- Returns:
Input image with
objmapandobjmaskupdated to exclude objects below the circularity cutoff.- Return type:
Image
- Raises:
ValueError – If
cutoffis outside[0, 1].
- Best For:
Post-threshold cleanup to exclude elongated scratches or merged colonies before phenotyping.
Enforcing morphology consistency in high-throughput grid assays.
Plates with round yeast or bacterial colonies where irregular detections indicate artifacts.
- Consider Also:
SmallObjectRemoverwhen artifacts are distinguished by size rather than shape.BorderObjectRemoverwhen irregular detections cluster near plate edges.MaskOpenerfor smoothing jagged boundaries before circularity filtering.
See also
How To: Refine Noisy Detection Boundaries for shape-based cleanup workflows. Refinement Strategies for a comparison of morphological refinement methods.
Methods
Initialize the remover.
Applies the operation to an image, either in-place or on a copy.
Return (and optionally display) the root widget.
- __init__(cutoff: float = 0.785)[source]
Initialize the remover.
- Parameters:
cutoff (float) – Minimum allowed circularity in [0, 1]. Increasing the cutoff favors compact, round objects (often cleaner masks), whereas lowering it retains irregular colonies but may keep more debris or merged objects.
- Raises:
ValueError – If
cutoffis outside [0, 1].
- __del__()
Automatically stop tracemalloc when the object is deleted.
- __getstate__()
Prepare the object for pickling by disposing of any widgets.
This ensures that UI components (which may contain unpickleable objects like input functions or thread locks) are cleaned up before serialization.
Note
This method modifies the object state by calling dispose_widgets(). Any active widgets will be detached from the object.
- apply(image, inplace=False)
Applies the operation to an image, either in-place or on a copy.
- Parameters:
image (Image) – The arr image to apply the operation on.
inplace (bool) – If True, modifies the image in place; otherwise, operates on a copy of the image.
- Returns:
The modified image after applying the operation.
- Return type:
Image
- widget(image: Image | None = None, show: bool = False) Widget
Return (and optionally display) the root widget.
- Parameters:
image (Image | None) – Optional image to visualize. If provided, visualization controls will be added to the widget.
show (bool) – Whether to display the widget immediately. Defaults to False.
- Returns:
The root widget.
- Return type:
ipywidgets.Widget
- Raises:
ImportError – If ipywidgets or IPython are not installed.