Validates the protocol, the parameters and the inputs, delegates to the
corresponding direct function (sg_segment_threshold(),
sg_segment_watershed(), sg_segment_propagate(), sg_cleanup_labels(),
sg_segment_stardist(), sg_segment_cellpose(), sg_segment_mesmer())
with an explicit, recorded argument mapping, and returns the mask or a
run envelope.
Usage
sg_protocol_run(image, protocol, ..., output = c("mask", "run"))Arguments
- image
The primary input: an
sg_image, or ansg_maskfor mask-input protocols such aspostprocess.label-cleanup.v1.- protocol
Protocol id,
sg_protocol, named list, JSON text or.jsonfile path.- ...
Parameter overrides (for example
min_area = 20L) and additional declared inputs (for exampleseeds = nuclei_maskforpropagate.voronoi.v1,model = trained_model). Unknown names are errors.- output
"mask"(default) returns thesg_mask;"run"returns ansg_runwithmask,measurementsand a schema-validrecord.
Details
Core protocols run without Python. Optional DNN protocols check their
backend first; when it is missing, output = "mask" signals an
sg_capability_error and output = "run" returns a run with
status = "unavailable". There is never a silent fallback to another
method. DNN predictions are returned as staged masks.
Examples
img <- sg_example_image("fluorescence_nuclei")
mask <- sg_protocol_run(img, "threshold.otsu.v1", min_area = 5L)
#> ℹ Threshold applied using "otsu" method.
#> ✔ Segmented 8 objects via threshold (otsu).
run <- sg_protocol_run(img, "threshold.otsu.v1", min_area = 5L,
output = "run")
#> ℹ Threshold applied using "otsu" method.
#> ✔ Segmented 8 objects via threshold (otsu).
run$record$delegate$arguments
#> $channel
#> [1] 1
#>
#> $image
#> [1] "<input:image>"
#>
#> $max_area
#> [1] 5000
#>
#> $method
#> [1] "otsu"
#>
#> $min_area
#> [1] 5
#>
#> $morphology
#> $morphology$fill_holes
#> [1] TRUE
#>
#> $morphology$open
#> [1] 5
#>
#>
identical(mask$labels, run$mask$labels)
#> [1] TRUE