phenotypic.detect.ManualPointDetector#

class phenotypic.detect.ManualPointDetector(centers: np.ndarray | list | None = None, shape: Literal['square', 'diamond', 'disk'] = 'disk', width: int = 15)[source]

Bases: ObjectDetector, FootprintMixin

Detect objects by stamping footprint masks at user-specified coordinates.

Place a morphological footprint at each explicitly provided (y, x) centre coordinate to produce objmask and objmap. Unlike ManualGridDetector, which extrapolates a regular grid from one or two anchor points, this class requires an explicit list of every colony centre. This makes it suitable for plates without regular geometry, sparse or irregular layouts, and manual annotation workflows where each object position is known individually.

Parameters:
  • centers (np.ndarray | list | None) – An N x 2 array-like of (y, x) pixel coordinates specifying each colony centre. Accepts any sequence that np.asarray can convert (list of tuples, nested list, or NumPy array). When None or empty, apply() zeros out objmask and objmap and returns immediately.

  • shape (Literal['square', 'diamond', 'disk']) – Morphological footprint shape stamped at each coordinate. "disk" (default) preserves round colony geometry. "square" covers rectangular regions. "diamond" offers a compromise between the two.

  • width (int) – Diameter of the footprint in pixels (default 15). Larger values cover more area per colony; smaller values produce tighter, more precise masks. Typical range: 5–50, depending on image resolution and colony size.

Returns:

Input image with objmask set to the union of all stamped footprints and objmap set to uniquely labelled regions (1-indexed, in the order centres were supplied).

Return type:

Image

Best For:
  • Manual annotation and ground-truth mask generation for benchmarking detection algorithms.

  • Non-grid plates (e.g., streak plates, random inoculations, environmental samples) where colony positions are irregular.

  • Validating other detection algorithms by comparing their output against user-curated centre coordinates.

  • Quick prototyping on small numbers of colonies without needing automatic detection.

Consider Also:
  • ManualGridDetector when colonies lie on a regular grid and only one or two anchor coordinates are needed.

  • RoundPeaksDetector when colony centres can be inferred automatically from intensity profiles.

See also

Tutorial 2: Detecting Colonies

Step-by-step tutorial for basic colony detection.

How To: Choose a Detection Algorithm

Guide for selecting the right detector for your plate images.

Detection Strategies Compared

In-depth comparison of all detection strategies.

Methods

__init__

apply

Detect colonies using sinusoidal cross-correlation grid estimation.

napari

Interactively pick colony center coordinates using a napari viewer.

widget

Return (and optionally display) the root widget.

napari(image: Image) ManualPointDetector[source]

Interactively pick colony center coordinates using a napari viewer.

Opens a blocking napari viewer displaying the plate image layers. Click points to mark colony centers, then click Confirm in the dock widget. The picked coordinates are stored in centers.

Parameters:

image (Image) – The Image to display for coordinate selection.

Returns:

Self, for method chaining.

Return type:

ManualPointDetector

__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)

Detect colonies using sinusoidal cross-correlation grid estimation.

This method performs the core detection workflow: 1. Extract grid dimensions (if GridImage) 2. Threshold the detection matrix with adaptive kernel sizing 3. Remove noise if requested 4. Label connected components 5. Determine or estimate grid edges (via sinusoidal cross-correlation) 6. Assign dominant colonies to grid cells 7. Create final object map

Parameters:

image – Image object to process. Can be a regular Image or GridImage.

Returns:

The processed image with updated objmask and objmap.

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.