neuralib.cellpose.core.CellposeSegmentation

class neuralib.cellpose.core.CellposeSegmentation[source]

Bases: object

Cellpose segmentation results

Dimension parameters:

N = Number of segmented cells

W = Image width

H = Image height

__init__(outlines, masks, chan_choose, ismanual, flows, diameter, filename)[source]

Methods

__init__(outlines, masks, chan_choose, ...)

load(file)

Load a cellpose segmentation result

to_roi(output_file)

Covert segmented roi to point roi, and save it as .roi for imageJ.

Attributes

chan_choose

channels that you chose in GUI (0=gray/none, 1=red, 2=green, 3=blue)

diameter

cell body diameter

filename

filepath of image

flows

flows[0] is XY flow in RGB

height

image height

is_manual

whether or not mask k was manually drawn or computed by the cellpose algorithm.

masks

each pixel in the image is assigned to an ROI (0 = NO ROI; 1,2,… = ROI labels).

n_segmentation

number of segmented cells

nan_masks

value 0 in CellposeSegmentation.masks to nan

nan_outlines

value 0 in CellposeSegmentation.outlines to nan

outlines

outlines of ROIs (0 = NO outline; 1,2,… = outline labels).

points

Calculate center of each segmented area in XY pixel.

width

image width

__init__(outlines, masks, chan_choose, ismanual, flows, diameter, filename)[source]
classmethod load(file)[source]

Load a cellpose segmentation result

Parameters:

file (str | Path | PathLike[str]) – cellpose segmentation result .npy file

Returns:

CellposeSegmentation

Return type:

Self

property n_segmentation: int

number of segmented cells

property width

image width

property height

image height

property filename: Path

filepath of image

property outlines: ndarray

outlines of ROIs (0 = NO outline; 1,2,… = outline labels). Array[uint16, [H, W]]

property masks: ndarray

each pixel in the image is assigned to an ROI (0 = NO ROI; 1,2,… = ROI labels). Array[uint16, [H, W]]

property chan_choose: list[int]

channels that you chose in GUI (0=gray/none, 1=red, 2=green, 3=blue)

property flows: list[ndarray]

flows[0] is XY flow in RGB

flows[1] is the cell probability in range 0-255 instead of -10.0 to 10.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)

property diameter: float

cell body diameter

property is_manual: ndarray

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

property nan_masks: ndarray

value 0 in CellposeSegmentation.masks to nan

property nan_outlines: ndarray

value 0 in CellposeSegmentation.outlines to nan

property points: ndarray

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

to_roi(output_file)[source]

Covert segmented roi to point roi, and save it as .roi for imageJ.

Parameters:

output_file (str | Path | PathLike[str]) – *.roi output file path