phenotypic.refine.CenterDeviationReducer#
- class phenotypic.refine.CenterDeviationReducer[source]#
Bases:
ObjectRefinerKeep the object closest to center and remove off-center detections.
- Intuition:
For isolated-colony images (e.g., single-spot captures or per-grid-cell crops), the true colony is typically near the center. Spurious blobs from glare, dust, or agar texture may appear off-center. This operation keeps only the object whose centroid is closest to the image center, removing all others.
- Why this is useful for agar plates:
When imaging a grid of pinned colonies, per-cell crops may contain extra detections (ringing, condensation, halo). Selecting the most centered object stabilizes downstream phenotyping by focusing on the intended colony in each crop.
- Use cases:
Single-colony crops from a grid plate where occasional debris is picked up near edges.
Automated pipelines that assume one colony per field-of-view.
- Caveats:
If the true colony is notably off-center (misalignment, drift), this method can remove it and keep a distractor.
Not suitable for multi-colony fields; it will drop all but one object.
- (No public attributes)
Examples
>>> from phenotypic.refine import CenterDeviationReducer >>> op = CenterDeviationReducer() >>> image = op.apply(image, inplace=True)
Methods
__init__Applies the operation to an image, either in-place or on a copy.
Drop references to the UI widgets.
Push internal state into widgets.
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.
- widget(image: Image | None = None, show: bool = False) Widget#
Return (and optionally display) the root widget.
- Parameters:
- Returns:
The root widget.
- Return type:
ipywidgets.Widget
- Raises:
ImportError – If ipywidgets or IPython are not installed.