Segments cells using the Cellpose deep learning model via
reticulate. Requires a working Python installation with
Cellpose 3.x installed. Use sg_setup_python() to configure the
environment.
Arguments
- image
An
sg_imageobject.- model
Character string specifying the Cellpose model. One of
"cyto3"(default),"cyto2","nuclei", or"custom". Legacy"tissuenet"and"livecell"aliases are rejected because Cellpose 3 cannot load them without substituting a model.- channels
A named list with elements
cytoplasmandnucleus, each an integer channel selector (following Cellpose convention). Zero selects grayscale/no nuclear channel; positive values select one-based image channels. Grayscale selection ignores the nuclear selector and supplies a zero second channel. Default islist(cytoplasm = 0L, nucleus = 1L).- diameter
Numeric or
NULL. Estimated cell diameter in pixels. IfNULL, Cellpose estimates the diameter automatically.- flow_threshold
Numeric; flow error threshold for mask filtering. Default is
0.4.- cellprob_threshold
Numeric; cell probability threshold. Default is
0.0.- custom_model_path
Character string or
NULL. Path to a custom-trained Cellpose model. Required whenmodel = "custom".- batch_size
Integer; number of images to process in parallel on the GPU. Default is
8L.- tile
Logical; if
TRUE(default), large images are processed in tiles to reduce memory usage.
Examples
pixels <- array(runif(300), dim = c(10, 10, 3))
img <- new_sg_image(pixels, channels = c("R", "G", "B"))
if (FALSE) { # \dontrun{
# Requires Python with Cellpose (see sg_setup_python())
mask <- sg_segment_cellpose(img, model = "cyto3")
} # }