Merge a data frame with the catalog metadata by a key column.
Examples
# Build a tiny study tree with empty placeholder files
root <- tempfile("study_")
for (s in c("01", "02")) {
d <- file.path(root, paste0("sub-", s))
dir.create(d, recursive = TRUE)
invisible(file.create(file.path(d, c("cope1.nii.gz", "varcope1.nii.gz"))))
}
catalog <- image_catalog(root, "sub-*/*.nii.gz",
path_regex = "sub-(?<subject>[^/]+)")
demographics <- data.frame(subject = c("01", "02"), age = c(25, 30))
catalog <- join_meta(catalog, demographics, by = "subject")
catalog$metadata[, c("basename", "subject", "age")]
#> basename subject age
#> 1 cope1.nii.gz 01 25
#> 2 varcope1.nii.gz 01 25
#> 3 cope1.nii.gz 02 30
#> 4 varcope1.nii.gz 02 30
unlink(root, recursive = TRUE)