Skip to contents

Return a tidy table of ROIs, optionally filtered by layer and/or label.

Usage

sg_roi_rois(project, layer = NULL, label = NULL, call = rlang::caller_env())

Arguments

project

An sg_roi_project.

layer

Optional single layer name to filter to.

label

Optional character vector of labels to filter to.

call

The calling environment, for error reporting.

Value

A tibble::tibble with one row per ROI and, in this exact order, the columns:

roi_id

Unique identifier (character).

layer

Layer name (character).

label

Class label (character).

geom_type

Geometry type, e.g. "POLYGON" (character).

level

Reference pyramid level (integer).

area_px

Area in level-0 pixels (double); NA for points/lines.

centroid_x,centroid_y

Centroid at level 0 (double).

n_vertices

Vertex count (integer).

created,modified

Timestamps (POSIXct).

author

Author (character).

source

Provenance source (character).

geometry

The sf geometry column (sfc), at level 0.

Returns a 0-row tibble with these columns if no ROIs match.

Details

Coordinates in the geometry column, together with area_px and the centroid, are expressed at pyramid level 0; the level column records the level at which each ROI was originally defined.

Examples

lyr <- sg_roi_layer_add(sg_roi_layer("tissue"),
                        sg_roi_rect(2, 2, 8, 8, label = "tissue"))
proj <- sg_roi_project(sg_roi_frame(c(20, 20)), lyr)
sg_roi_rois(proj)
#> # A tibble: 1 × 14
#>   roi_id    layer label geom_type level area_px centroid_x centroid_y n_vertices
#>   <chr>     <chr> <chr> <chr>     <int>   <dbl>      <dbl>      <dbl>      <int>
#> 1 roi_0000… tiss… tiss… POLYGON       0      36          5          5          5
#> # ℹ 5 more variables: created <dttm>, modified <dttm>, author <chr>,
#> #   source <chr>, geometry <POLYGON>