phenotypic.sdk_.napari_ package#
Napari-based interactive tools for PhenoTypic.
Developer utilities for visual point picking and coordinate selection using napari viewers. These are dev-time tools, not user-facing GUI components.
- class phenotypic.sdk_.napari_.LabelEditorWidget[source]#
Bases:
objectOpen a napari viewer to edit an image’s object labels and save them back.
The viewer shows
rgb(when present),gray, anddetect_matas image layers plus one editable labels layer seeded from the called accessor (objmaporobjmask). A dock panel provides “Save to Image” and “Discard & Close” buttons.runblocks until the viewer is closed.- run(image, accessor_name: str, *, viewer: napari.Viewer | None = None) np.ndarray | None[source]#
Open the editor and block until closed.
- Parameters:
image – A PhenoTypic
Imagewhose layers are displayed and whoseobjmap/objmaskis edited.accessor_name (str) –
"objmap"or"objmask"— selects which accessor the editable layer is seeded from and saved back to.viewer (napari.Viewer | None) – Optional existing napari viewer to reuse. When
Nonea newnapari.Viewer(title="Label Editor")is created.
- Returns:
The array written back to the image on save, or
Noneif the user discarded or closed the viewer without saving.- Raises:
ImportError – If napari is not installed.
- Return type:
np.ndarray | None
- class phenotypic.sdk_.napari_.PointPickerWidget(max_points: int | None = None)[source]#
Bases:
objectInteractive point picker that opens a napari viewer for coordinate selection.
- Parameters:
max_points (int | None) – Maximum number of points allowed. None means unlimited.
- run(image) numpy.ndarray[source]#
Open a napari viewer for interactive point selection and block until closed.
- Parameters:
image – A PhenoTypic
Imageinstance whose layers will be displayed.- Returns:
An
(N, 2)array of confirmed(y, x)coordinates. Returns an empty(0, 2)array if the viewer is closed without confirming.- Raises:
ImportError – If napari is not installed.
- Return type:
- phenotypic.sdk_.napari_.add_image_layer(viewer, array, *, name: str, visible: bool = True, gamma: float = 1.0)[source]#
Add (or replace) an image layer with non-stretched contrast limits.
Mirrors the contrast convention of the detect-mode preview tool (
DetectMat.preview_modes): integer layers use the full dtype range and single-channel normalized float intensities use a fixed(0.0, 1.0)range. This renders each layer at its true brightness instead of letting napari auto-stretch the display to the data’s own(min, max)— which exaggerates contrast and makes layers look washed out when several are shown together. Three-dimensional arrays are treated as RGB.- Parameters:
viewer – A napari
Viewer(or any object exposinglayersandadd_image).array – The image array — 2-D intensity or 3-D RGB.
name (str) – Layer name. An existing layer with this name is updated in place rather than duplicated.
visible (bool) – Initial layer visibility. Defaults to True.
gamma (float) – Display gamma. Defaults to 1.0 (no gamma adjustment).
- Returns:
The created or updated napari image layer.