phenotypic.sdk_.napari_.LabelEditorWidget#

class phenotypic.sdk_.napari_.LabelEditorWidget[source]#

Bases: object

Open a napari viewer to edit an image’s object labels and save them back.

The viewer shows rgb (when present), gray, and detect_mat as image layers plus one editable labels layer seeded from the called accessor (objmap or objmask). A dock panel provides “Save to Image” and “Discard & Close” buttons. run blocks until the viewer is closed.

Methods

__init__

run

Open the editor and block until 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 Image whose layers are displayed and whose objmap/objmask is 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 None a new napari.Viewer(title="Label Editor") is created.

Returns:

The array written back to the image on save, or None if the user discarded or closed the viewer without saving.

Raises:

ImportError – If napari is not installed.

Return type:

np.ndarray | None