phenotypic.refine.GridSectionLargest#
- class phenotypic.refine.GridSectionLargest(*args, **kwargs)[source]
Bases:
ObjectRefinerRetain only the largest object within each grid section by area.
Measures the pixel area of every detected object, groups them by grid cell, and keeps only the largest per cell. Smaller fragments, debris, and secondary detections within each grid position are removed.
- Returns:
Input image with
objmapreduced to the single largest object per grid section.- Return type:
Image
- Best For:
Grid plates where the true colony is the largest detection in each cell and smaller objects are noise or debris.
Quick post-detection cleanup on 96-well or 384-well formats.
Simplifying multi-detection grid cells to one object per position.
- Consider Also:
GridAlignmentRefinerfor full grid-aware dominant-object selection with configurable strategies.CenterDeviationReducerwhen the most centered object is more reliable than the largest.ReduceMultipleGridObjectsfor regression-based selection using expected grid positions.
See also
How To: Refine Noisy Detection Boundaries for grid-based refinement workflows. Refinement Strategies for an overview of grid refinement approaches.
Methods
__init__Applies the operation to an image, either in-place or on a copy.
Return (and optionally display) the root widget.
- __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.