bin2cell.stardist

bin2cell.stardist(image_path, labels_npz_path, stardist_model='2D_versatile_he', block_size=4096, min_overlap=128, context=128, model=None, model_axes=None, **kwargs)

Segment an image with StarDist. Supports both the fluorescence and H&E models. The identified object labels will be converted to a sparse matrix and written to drive in .npz.

Input

image_pathfilepath

Path to image to be segmented.

labels_npz_pathfilepath

Path to write object labels output. Can be easily loaded via scipy.sparse.load_npz().

stardist_modelstr, optional (default: "2D_versatile_he")

Use "2D_versatile_he" for segmenting H&E images or "2D_versatile_fluo" for segmenting single-channel images (GEX-derived or IF)

block_sizeint, optional (default: 4096)

StarDist predict_instances_big() input. Length of square edge of the image to process as a single tile.

min_overlapint, optional (default: 128)

StarDist predict_instances_big() input. Minimum overlap between adjacent tiles, in each dimension.

contextint, optional (default: 128)

StarDist predict_instances_big() input. Amount of image context on all sides of a block, which is discarded.

modelStarDist2D or None, optional (default: None)

A custom loaded StarDist2D to use for the segmentation. Will ignore stardist_model if provided.

model_axesstr or None, optional (default: None)

If using a custom model, specify its axes, matching information from the input image. For context, for "2D_versatile_he" the axes are YXC, for "2D_versatile_fluo" the axes are YX.

kwargs

Any additional arguments to pass to StarDist. Practically most likely to be prob_thresh for controlling the stringency of calling objects.