Segments cells using the Cellpose deep learning model via
reticulate. Requires a working Python installation with
cellpose 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","tissuenet","livecell", or"custom".- channels
A named list with elements
cytoplasmandnucleus, each an integer channel index (0-based, following Cellpose convention). 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
# \donttest{
pixels <- array(runif(300), dim = c(10, 10, 3))
img <- new_sg_image(pixels, channels = c("R", "G", "B"))
# Requires Python + cellpose:
# mask <- sg_segment_cellpose(img, model = "cyto3")
# }