readNormalizedPopulationData: Read normalized population from h5 file or directory

View source: R/writeNormalizedPopulationData.R

readNormalizedPopulationDataR Documentation

Read normalized population from h5 file or directory

Description

This function reads a file created by writeNormalizedPopulationData.

Usage

readNormalizedPopulationData(filename)

Arguments

filename

input filename for hdf5 file.

Value

list containing demographics, imageMat, imageMask and imageBoolean

Author(s)

Avants BB

Examples

tfn <- system.file("extdata", "normpop.h5", package = "ANTsR")
if (file.exists(tfn)) {
  dlist <- readNormalizedPopulationData(tfn)
}
## Not run: 
ilist <- getANTsRData("population")
mask <- getMask(ilist[[1]])
imat <- imageListToMatrix(ilist, mask)
demog <- data.frame(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")) writeNormalizedPopulationData(demog, imat, mask, ibool, tfn)
if (usePkg("hdf5r")) {
  dlist <- readNormalizedPopulationData(tfn)
  all.equal(dlist$demographics, demog)
  all.equal(dlist$imageMat, imat)
  all.equal(as.array(dlist$imageMask), as.array(mask))
  all.equal(dlist$imageBool, ibool)
}

## End(Not run)

stnava/ANTsR documentation built on April 16, 2024, 12:17 a.m.