Overview
A QWAimages object is a tibble subclass — one row per
analysed image — that collects everything the rest of the package needs
to know about your raw ROXAS data: where the files live, how the images
are organised hierarchically, image EXIF properties, and the ROXAS (AI)
settings used during analysis. It is the required input for
collect_raw_data() and the $images component
inside a QWAmetadata object.
The object carries a single attribute, roxas_version
("roxas" or "roxas_ai"), which records which
software produced the data and determines the expected column set.
Building a QWAimages object
In normal use, you do not call QWAimages() directly.
Instead, you use build_QWAimages(), which combines the
output of extract_data_structure() (the hierarchical
labels) with collect_settings_data() (the per-image ROXAS
settings and EXIF metadata). See the main rxs2tria vignette
for a step-by-step walkthrough.
files <- get_roxas_files("path/to/ROXAS_data", roxas_version = "roxas")
df_structure <- extract_data_structure(files, pattern = "...")
df_settings <- collect_settings_data(df_structure)
rxs_images <- build_QWAimages(df_structure, df_settings)build_QWAimages() checks the label hierarchy (aborting
if it is invalid), aligns the columns and types to the JSON schema for
the software version (adding missing required columns as
NA, dropping unrecognised columns, warning on coercions)
and validates the result against the schema (warnings only).
If you already have a data frame with the right columns — for example
after reading from a non-standard source — you can pass it directly to
QWAimages(). It infers or validates
roxas_version from the $software column and
does the same alignment, but only warns on an invalid hierarchy:
rxs_images <- QWAimages(my_df, roxas_version = "roxas")What the object contains
rxs_images # same as print(rxs_images): prints the tibble
summary(rxs_images) # compact overviewsummary() reports the software version, the count of
images, slides, woodpieces, and trees, the sites and species present,
and the range of outmost_year values.
The columns fall into the following groups:
Hierarchical labels — uniquely identify each image
within the sampling design and link images to the metadata tables in
QWAmetadata:
| Column | Description |
|---|---|
site_label |
Site identifier |
tree_label |
Tree identifier (includes site) |
woodpiece_label |
Woodpiece identifier (includes tree) |
slide_label |
Slide identifier (includes woodpiece) |
image_label |
Image identifier (includes slide); used as the join key in
QWAdata
|
species_code |
Species code |
File paths — used by collect_raw_data()
and update_QWAdata() to locate the ROXAS output files:
| Column | Description |
|---|---|
fname_image |
Path to the image file |
fname_cells |
Path to the cells output file |
fname_rings |
Path to the rings output file |
fname_settings |
Path to the settings / metadata file |
File paths are part of submission files only; the
$images of TRIA dataset files have no fname_*
columns.
Image metadata — properties extracted from the image EXIF data or the ROXAS AI metadata file:
| Column | Description |
|---|---|
img_created_at |
Image capture timestamp |
img_width, img_height
|
Image dimensions in pixels |
spatial_resolution |
Pixels per µm; required for the incomplete-innermost-ring check in
complete_QWAdata()
|
software |
Software that produced the data ("roxas" or
"roxas_ai"); must match the roxas_version
attribute |
ROXAS settings — parameters from the ROXAS settings
or ROXAS AI metadata file (e.g. magnification, threshold values). The
exact columns differ between roxas_version values.
Dating — outmost_year is the calendar
year of the outermost complete ring in the image, used to validate that
ring years do not exceed it.
App inputs — only_ew and
img_comment (colType meta_input,
filled in the metadata app) and comment_handled
(colType qc_input, set in the flags app).
Optional columns (those not always present in ROXAS output) are
NA until populated. complete_QWAimages() adds
all missing optional columns except qc_input columns
(comment_handled), initialised to NA.
The roxas_version attribute and the
$software column
roxas_version is stored both as the object attribute
(the authoritative source) and as the $software column (a
per-row record). The two must agree: QWAimages() sets
$software to the resolved roxas_version (with
a warning if values changed), and all functions taking a
QWAimages object abort if they disagree:
# Error if the attribute and the $software column disagree, e.g. after
# editing $software by hand:
# x <QWAimages>: software must be "roxas" (the roxas_version attribute) in all rows.
# i Rebuild the object with QWAimages().The $software column is used to re-derive
roxas_version when reading from file (since attributes are
not persisted in CSV).
Checking a QWAimages object
check_QWAimages(rxs_images)check_QWAimages() returns TRUE invisibly if
no issue was found, FALSE otherwise. With
strict = TRUE, it aborts on the first issue instead of
warning. It is also run by check_QWAmetadata().
-
Errors: invalid object, i.e. structure labels
missing or
NA, duplicateimage_labels, or$softwarenot matching theroxas_versionattribute. -
Warnings: values violating the schema of the stage
(
submission = TRUEfor submission files,FALSEfor TRIA dataset files; set bycheck_QWAmetadata()); labels not starting with their parent label, or a label in more than one parent;outmost_yearin the future; missingspatial_resolution. -
Information: missing optional columns (except
qc_inputones; add them withcomplete_QWAimages()) and empty values.
Adding optional columns
rxs_images_full <- complete_QWAimages(rxs_images)Returns a new QWAimages object with all optional columns
except qc_input ones added and initialised to
NA. Existing values are preserved.
complete_QWAmetadata() does this for
$images.
Persisting to disk
write_QWAimages(rxs_images, "output/my_dataset_QWAimages.csv.gz")
rxs_images <- read_QWAimages("output/my_dataset_QWAimages.csv.gz")write_QWAimages() saves the tibble as a (optionally
compressed) CSV. The roxas_version attribute is
not written to the file — it is re-derived from the
$software column when the file is read back by
read_QWAimages(). This means the $software
column must be intact and consistent for round-tripping to work
correctly.
The compress argument adds a .gz extension
if not already present. Alternatively, naming the file with a
.csv.gz extension is sufficient — vroom
compresses automatically.
Empty values are written as empty fields. With
drop_empty = TRUE (default), optional
meta_input/qc_input columns
(only_ew, img_comment,
comment_handled) that are empty in all rows are not
written. read_QWAimages() does not re-create them; use
complete_QWAimages().