neuralib.segmentation.cellpose.run_api

class neuralib.segmentation.cellpose.run_api.CellPoseAPIOption[source]
DESCRIPTION: str = 'run cell pose for directly call the api'

parser description.

RESTORE_TYPE: ClassVar[str] = 'denoise_cyto3'
RESTORE_RATIO: ClassVar[float] = 1.0
run()[source]

called when all argument attributes are set

eval()[source]

eval the model in single file or batch files, and save the results

final class neuralib.segmentation.cellpose.run_api.CellPoseEvalResult[source]

Cellpose results

Dimension parameters:

N = Number of segmented cell

W = Image width

H = Image height

filename: str

image file name

image: ndarray | list[ndarray]

image array

diameter: float

neuronal diameter

chan_choose: list[int]

[chan_seg, chan_nuclear]

masks: ndarray

each pixel in the image is assigned to an ROI (H, W) list of 2D arrays, labelled image, where 0=no masks; 1,2,…=mask labels

flows: list[ndarray]

flows[0] is XY flow in RGB, flows[1] is the cell probability in range 0-255 instead of 0.0 to 1.0, flows[2] is Z flow in range 0-255 (if it exists, otherwise zeros), flows[3] is [dY, dX, cellprob] (or [dZ, dY, dX, cellprob] for 3D), flows[4] is pixel destinations (for internal use)

styles: list[ndarray]

list of 1D arrays of length 256, style vector summarizing each image, also used to estimate size of objects in image

colors: ndarray | None

colors for ROIs (N, 3)

manual_changes: list[Any] | None
est_diam: float | None

estimated diameter (if run on command line)

model_path: int
flow_threshold: float | None
cellprob_threshold: float
normalize_params: NormParams | None
img_restore: list[ndarray] | None
restore: str | None
ratio: float
__init__(filename, image, diameter, chan_choose, masks, flows=NOTHING, styles=NOTHING, *, colors=None, manual_changes=None, est_diam=None, model_path=0, flow_threshold=None, cellprob_threshold=0, normalize_params=None, img_restore=None, restore=None, ratio=1.0, outlines=array([], dtype=float64), ismanual=array([], dtype=float64))

Method generated by attrs for class CellPoseEvalResult.

Parameters:
  • filename (str)

  • image (ndarray | list[ndarray])

  • diameter (float)

  • chan_choose (list[int])

  • masks (ndarray)

  • flows (list[ndarray])

  • styles (list[ndarray])

  • colors (ndarray | None)

  • manual_changes (list[Any] | None)

  • est_diam (float | None)

  • model_path (int)

  • flow_threshold (float | None)

  • cellprob_threshold (float)

  • normalize_params (NormParams | None)

  • img_restore (list[ndarray] | None)

  • restore (str | None)

  • ratio (float)

  • outlines (ndarray)

  • ismanual (ndarray)

Return type:

None

outlines: ndarray

outlines of ROIs. Array[uint16, [H, W]]

ismanual: ndarray

whether or not mask k was manually drawn or computed by the cellpose algorithm. Array[bool, N]

classmethod load(seg_file)[source]
Parameters:

seg_file (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader)

Return type:

Self

save_seg_file(image_file)[source]

Save as seg.npy file`

Parameters:

image_file (str)

Return type:

None

save_roi(output_file)[source]

Save as imageJ .roi file. CHECKOUT native BUG: https://github.com/MouseLand/cellpose/issues/969

Parameters:

output_file (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader)

Return type:

None

nan_masks()[source]

value 0 in masks to nan

Return type:

ndarray

nan_outlines()[source]

value 0 in outlines to nan

Return type:

ndarray

property points: ndarray

Calculate center of each segmented area in pixel. Array[int, N]