Export annotations as a qupflowR handoff directory
Source:R/interop-handoff.R
at_export_qupflowr.RdWrite a new, self-contained handoff directory for a partner package such as
qupflowR. It contains only neutral, relative files: image.json,
annotations_qupath.geojson (QuPath 0.4+ dialect), optionally
annotations.geojson, one integer mask per layer under masks/ with a
.legend.json sidecar, optional tables/rois.csv, an optional
annotatR-internal objects/project.rds, hsi_manifest.json for spectral
images, manifest.json (at_interop_manifest()) and integrity.json, the
SHA-256 inventory of every other file. The handoff digest is the SHA-256 of
the canonical integrity.json. Absolute paths are never used as identity.
Usage
at_export_qupflowr(
x,
destination,
formats = c("qupath_geojson", "mask_tiff", "manifest"),
overwrite = FALSE,
level = 0L,
mask_type = c("labelled", "multiclass", "binary"),
scope = c("all", "current", "complete"),
call = rlang::caller_env()
)Arguments
- x
An annot_project or annot_session (materialised entries are exported under
entries/entry-NNNN/).- destination
Path of the handoff directory to create.
- formats
Any of
"qupath_geojson","geojson","mask_tiff","mask_npy","csv","rds","manifest".manifest.jsonandintegrity.jsonare always written.- overwrite
Logical; replace an existing handoff directory.
- level
Integer pyramid level for coordinates and masks. Default
0.- mask_type
Mask type for mask files:
"labelled"(default; one value per ROI, joinable byroi_idthrough the legend),"multiclass"or"binary".- scope
For sessions:
"all"materialised entries (default),"current"or"complete".- call
The calling environment, for error reporting.
Value
An at_handoff_receipt (invisibly): a list with destination,
handoff_digest, files (a tibble of path, size_bytes, sha256,
format, role, entry_id), manifest, skipped entries and
overwritten.
Details
Files are written into a hidden sibling staging directory and moved into
place only when complete, so a failed export never leaves a directory that
looks valid. An existing destination is replaced only with
overwrite = TRUE, and only when it is itself a handoff directory.
Examples
dest <- file.path(tempdir(), "handoff-example")
rc <- at_export_qupflowr(at_example_project(), dest, overwrite = TRUE)
#> Registered S3 method overwritten by 'stars':
#> method from
#> st_interpolate_aw.stars sf
rc$handoff_digest
#> [1] "3fc9b28e1c15e6ac4b126e54fc93000f0dfc270dad434ba027660ad9d856cb53"
rc$files[, c("path", "format")]
#> # A tibble: 5 × 2
#> path format
#> <chr> <chr>
#> 1 annotations_qupath.geojson qupath_geojson
#> 2 image.json image_json
#> 3 manifest.json manifest
#> 4 masks/regions_labelled.tif mask_tiff
#> 5 masks/regions_labelled.tif.legend.json legend_json