writeNormalizedPopulationData.Rd
This function simplifies the steps of saving a population (image) analysis into an efficient hdf5 file, using the h5 library or to a directory. The population image data is stored as a matrix. Along with the matrix will be a data frame with population demographics. The number of matrix columns will be defined by a mask that the user should also supply. Finally, a boolean vector should be passed in that matches the images to the demographics. This function cannot check if the matching between demographics and images is correct and, as such, the user should take care in creating the inputs. WARNING: when using h5, the demographics file will currently be cast to a data.matrix so one should not reuse this file as the reference demographics file.
writeNormalizedPopulationData(
demographics,
imageMat,
imageMask,
imageBoolean,
filename
)
data frame that identifies the variables of interest.
a matrix that stores the normalized image data.
mask with number of non-zero entries defining the matrix columns.
a vector of booleans with length equal to the number of rows in the demographics data frame and number of true values equal to the number of rows in the image matrix.
output filename for hdf5 file (if .h5) or directory name.
successOrFailure boolean
# read below will test out writing as well
if (FALSE) { # \dontrun{
ilist <- getANTsRData("population")
mask <- getMask(ilist[[1]])
imat <- imageListToMatrix(ilist, mask)
demog <- data.frame(
id = c("A", "B", "C", NA),
age = c(11, 7, 18, 22), sex = c("M", "M", "F", "F")
)
ibool <- c(TRUE, TRUE, TRUE, FALSE)
tfn <- tempfile(fileext = ".h5")
if (usePkg("hdf5r")) {
demographics <- demog
imageMat <- imat
imageMask <- mask
imageBoolean <- ibool
filename <- tfn
writeNormalizedPopulationData(
demog, imat, mask, ibool,
tfn
)
}
} # }