writeNormalizedPopulationData: Save normalized population data to a directory or h5 file

Description Usage Arguments Value Author(s) Examples

View source: R/writeNormalizedPopulationData.R

Description

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.

Usage

1
2
3
4
5
6
7
writeNormalizedPopulationData(
  demographics,
  imageMat,
  imageMask,
  imageBoolean,
  filename
)

Arguments

demographics

data frame that identifies the variables of interest.

imageMat

a matrix that stores the normalized image data.

imageMask

mask with number of non-zero entries defining the matrix columns.

imageBoolean

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.

filename

output filename for hdf5 file (if .h5) or directory name.

Value

successOrFailure boolean

Author(s)

Avants BB

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# read below will test out writing as well
## Not run: 
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 )
  }

## End(Not run)

neuroconductor-devel/ANTsR documentation built on April 1, 2021, 1:02 p.m.