labels2matrix.Rd
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.
labels2matrix(img, mask, targetLabels = NULL, missingVal = NA)
matrix is output
fi <- antsImageRead(getANTsRData("r16"), 2) %>% resampleImage(c(60, 60), 1, 0)
mask <- getMask(fi)
labs <- kmeansSegmentation(fi, 3)$segmentation
labmat <- labels2matrix(labs, mask)