harpy.im.instanseg_callable

harpy.im.instanseg_callable#

harpy.im.instanseg_callable(img, device='cpu', instanseg_model='instanseg.pt', output=None, dtype=<class 'numpy.uint32'>, pixel_size=0.5, **kwargs)#

Perform segmentation using instanseg.

Parameters:
  • img (ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]) – The input image as a numpy array on which instance segmentation will be performed (z,y,x,c).

  • device (str | None (default: 'cpu')) – The device to run the model on. Can be “cpu”, “cuda”, or another supported device. Default is “cpu”.

  • instanseg_model (InstanSeg | Path | str (default: 'instanseg.pt')) – The InstanSeg model used for segmentation. This can either be a pre-loaded model, or a file path to the model (typically a .pt file).

  • pixel_size (float (default: 0.5)) – pixel size in μm.

  • output (Optional[Literal['all_outputs', 'nuclei', 'cells']] (default: None)) – Specifies the type of segmentation to perform. Options are: “cells”: segment entire cells; “nuclei”: segment only nuclei; “all_outputs”: segment both cells and nuclei. If None, output is set to “all_outputs”.

  • dtype (type (default: <class 'numpy.uint32'>)) – The data type for the output mask. Default is set by _SEG_DTYPE.

Return type:

ndarray[tuple[Any, ...], dtype[TypeVar(_ScalarT, bound= generic)]]

Returns:

: A numpy array containing the segmented regions as labeled masks (z,y,x,c).