phenotypic.refine.BorderObjectRemover#
- class phenotypic.refine.BorderObjectRemover(border_size: int | float | None = 1)[source]
Bases:
ObjectRefinerRemove colonies that touch the image border within a configurable margin.
Zeroes any labeled objects in
objmapwhose pixels fall within a border band, ensuring only fully contained colonies are analyzed. Partial edge colonies bias size and shape measurements.- Parameters:
border_size (Optional[Union[int, float]]) – Width of the exclusion border.
Noneuses 1% of the smaller dimension. Float in (0, 1) is a fraction of the image size. Int or float >= 1 is absolute pixels. Default: 1.- Returns:
Input image with
objmaskandobjmapupdated to exclude border-touching objects.- Return type:
Image
- Raises:
TypeError – If
border_sizetype is invalid.
- Best For:
Plates where the plate rim or image crop truncates edge colonies.
Grid assays where border wells are partially visible.
Automated crops that shift between frames.
- Consider Also:
SmallObjectRemoverfor removing noise fragments that are not necessarily at the border.GridOversizedObjectRemoverfor removing abnormally large objects that span multiple grid sections.
See also
How To: Refine Noisy Detection Boundaries for a walkthrough of refinement operations. Refinement Strategies for choosing the right refinement sequence.
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__(border_size: int | float | None = 1)[source]
Initialize the remover.
- Parameters:
border_size (int | float | None) –
Width of the exclusion border around the image.
None: Use a default margin equal to 1% of the smaller image dimension.floatin (0, 1): Interpret as a fraction of the minimum image dimension, producing a resolution-adaptive margin.intorfloat≥ 1: Interpret as an absolute number of pixels.
Notes
Larger margins remove more edge-touching colonies and are useful when crops are loose or the plate rim intrudes. Smaller margins preserve edge colonies but risk including partial objects.
- __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.