images2matrix: Transform set of images to matrix

Description Usage Arguments Value Examples

View source: R/images2matrix.R

Description

Creates a matrix, where the voxels are on the rows and images are on the columns

Usage

1
images2matrix(imgs, mask = NULL)

Arguments

imgs

Vector of files or list of images (niftiImage, array, or nifti)

mask

Binary image to subset the voxels

Value

Matrix of V by p, where V is the product of the dimensions of one image or the number of voxels in the mask, and p is the number of images

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
set.seed(5)
dims = rep(10, 3)
arr = array(rpois(prod(dims), lambda = 2), dim = dims)
nim = oro.nifti::nifti(arr)
imgs = list(nim, arr)
mask = nim > 2
mat1 = images2matrix(imgs)
mat2 = images2matrix(list(nim, nim))
if (packageVersion("oro.nifti") >= package_version("0.10.2")) {
testthat::expect_equal(mat1, mat2)
} else {
testthat::expect_error(testthat::expect_equal(mat1, mat2))
}
mat1 = images2matrix(imgs, mask = mask)
mat2 = images2matrix(list(nim, nim), mask)

neuroconductor-releases/neurobase documentation built on Nov. 12, 2020, 7:47 p.m.