Learn R Programming

ANTsR (version 1.0)

imageListToMatrix: Read Images into a Matrix

Description

Read images into rows of a matrix.

Usage

imageListToMatrix(imageList, mask)

Arguments

imageList

A character vector containing a list of image files to read, in order - these are image objects, not file names.

mask

An antsImage containing a binary mask, voxels in the mask are placed in the matrix. If not provided, estimated from first image in list.

Value

A matrix containing the masked data, the result of calling as.numeric(image, mask) on each input image.

See Also

matrixToImages, getMask

Examples

Run this code
# NOT RUN {
img <- antsImageRead(getANTsRData('r16'), 2)
 imglist <- list()
 nvox <- dim(img)[1] * dim(img)[2]
 nsubj <- 50
 for(ii in 1:nsubj){
   imglist[ii] <- img + rnorm(nvox, sd=mean(img[img!=0]))
 }
 mask <- getMask(img)
 imgmat <- imageListToMatrix(imglist, mask)
# }

Run the code above in your browser using DataLab