Skip to contents

Report ROIs in a constrained layer that fall outside their container region. A layer declares the constraint through its metadata, e.g. sg_roi_layer("state", within = list(layer = "anatomy", label = "wound")); then every ROI in state must be spatially covered by the union of the anatomy layer's wound ROIs. This enforces the annotation rule that a class is painted only inside its region of interest. The report mirrors the shape of sg_roi_check_geometry().

Usage

sg_roi_check_containment(project, tol = 0, call = rlang::caller_env())

Arguments

project

An sg_roi_project.

tol

Non-negative slack, in level-0 pixels, by which the container is grown before testing, to tolerate sub-pixel tracing overhang. Default 0.

call

The calling environment, for error reporting.

Value

A tibble::tibble with columns roi_id, layer, issue, severity ("warning" for an ROI outside its container, "error" for a missing/empty container), and fixable (always FALSE). A 0-row tibble when every constrained ROI is contained, or when no layer declares a within constraint.

Examples

anatomy <- sg_roi_layer_add(sg_roi_layer("anatomy", labels = "wound"),
                        sg_roi_rect(2, 2, 8, 8, label = "wound"))
state <- sg_roi_layer("state", labels = "injury",
                  within = list(layer = "anatomy", label = "wound"))
state <- sg_roi_layer_add(state, sg_roi_rect(0, 0, 4, 4, label = "injury"))
sg_roi_check_containment(sg_roi_project(sg_roi_frame(c(100, 100)), list(anatomy, state)))
#> # A tibble: 1 × 5
#>   roi_id        layer issue                                     severity fixable
#>   <chr>         <chr> <chr>                                     <chr>    <lgl>  
#> 1 roi_000000009 state ROI is not contained in layer 'anatomy' … warning  FALSE