labels2matrix: Convert label image to a matrix

Description Usage Arguments Value Author(s) Examples

View source: R/labels2matrix.R

Description

Convert a labeled image to an n x m binary matrix where n = number of voxels and m = number of labels. Only includes values inside the provided mask while including background ( img == 0 ) for consistency with timeseries2matrix and other image to matrix operations.

Usage

1
labels2matrix(img, mask, targetLabels = NULL, missingVal = NA)

Arguments

img

input label image

mask

defines domain of interest

targetLabels

defines target regions to be returned. if the target label does not exist in the input label image, then the matrix will contain a constant value of missingVal (default NA) in that row.

missingVal

for missing label values.

Value

matrix is output

Author(s)

Avants BB

Examples

1
2
3
4
fi = antsImageRead(getANTsRData("r16") ,2) %>% resampleImage(c(60,60),1,0)
mask = getMask( fi )
labs = kmeansSegmentation( fi, 3 )$segmentation
labmat = labels2matrix( labs, mask )

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