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. at_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 at_check_geometry().

Usage

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

Arguments

project

An annot_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 <- at_layer_add(at_layer("anatomy", labels = "wound"),
                        at_roi_rect(2, 2, 8, 8, label = "wound"))
state <- at_layer("state", labels = "injury",
                  within = list(layer = "anatomy", label = "wound"))
state <- at_layer_add(state, at_roi_rect(0, 0, 4, 4, label = "injury"))
at_check_containment(at_project(at_example_image("cube"), list(anatomy, state)))
#> # A tibble: 1 × 5
#>   roi_id        layer issue                                     severity fixable
#>   <chr>         <chr> <chr>                                     <chr>    <lgl>  
#> 1 roi_000000002 state ROI is not contained in layer 'anatomy' … warning  FALSE