phenotypic.refine.MinResidualErrorReducer#
- class phenotypic.refine.MinResidualErrorReducer[source]#
Bases:
GridObjectRefinerReduce multi-detections per grid cell by keeping objects closest to a linear-regression prediction of expected positions.
- Intuition:
In grid assays, some cells contain multiple detections due to halos, debris, or over-segmentation. By modeling the expected colony position in each row/column with linear regression, we can retain the object with the smallest residual error (closest to the predicted location) and remove the rest. This iterates across the grid until each cell is simplified.
- Why this is useful for agar plates:
Pinned arrays assume consistent spatial layout. Selecting the object nearest the learned grid trend eliminates off-grid artifacts while preserving the most plausible colony per cell.
- Use cases:
Over-segmentation yields several blobs per grid position.
Condensation or glare introduces extra detections near a colony.
- Caveats:
If the grid fit is inaccurate (bad registration, warped plates), the closest-to-trend object may not be the true colony.
Relatively slow due to repeated measurement and iteration over cells.
- (No public attributes)
Examples
Reduce multi-detections per grid cell using residual error
>>> from phenotypic.refine import MinResidualErrorReducer >>> op = MinResidualErrorReducer() >>> 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.