zscore_img {neurobase} | R Documentation |
Get Z-score over a margin of an img
Description
Standardizes an image either by the axial, sagittal, or coronal slice or whole image
Usage
zscore_img(
img,
mask = NULL,
margin = NULL,
centrality = c("mean", "median", "trimmed_mean"),
variability = c("sd", "iqrdiff", "mad", "maddiff", "iqr", "trimmed_sd"),
trim = 0.2,
remove.na = TRUE,
remove.nan = TRUE,
remove.inf = TRUE,
remove.val = 0,
remask = TRUE
)
Arguments
img |
character path of image or an object of class nifti |
mask |
character path of mask or an object of class nifti |
margin |
Margin of image to z-score over ( |
centrality |
(character) Measure to center the data, either mean or median |
variability |
(character) Measure to scale the data |
trim |
if centrality is |
remove.na |
(logical) change NAs to remove.val |
remove.nan |
(logical) change NaN to remove.val |
remove.inf |
(logical) change Inf to remove.val |
remove.val |
(logical) value to put the NA/NaN/Inf |
remask |
(logical) Should the image be remasked after normalizing? |
Value
Array of object of class nifti
See Also
Examples
dim = c(100, 30, 5)
img = array(rnorm(prod(dim), mean=4, sd=4),
dim=dim)
truth2 = img
for (i in 1:dim(img)[2]) {
truth2[,i,] = (truth2[,i,]- mean(truth2[,i,]))/sd(truth2[,i,])
}
truth1 = img
for (i in 1:dim(img)[1]) {
truth1[i,,] = (truth1[i,,]- mean(truth1[i,,]))/sd(truth1[i,,])
}
truth3 = img
for (i in 1:dim(img)[3]) {
truth3[,,i] = (truth3[,,i]- mean(truth3[,,i]))/sd(truth3[,,i])
}
try3 = zscore_img(img, margin=3)
stopifnot(all.equal(try3, truth3))
try2 = zscore_img(img, margin=2)
stopifnot(all.equal(try2, truth2))
try1 = zscore_img(img, margin=1)
stopifnot(all.equal(try1, truth1))
z = zscore_img(img, margin=NULL)
ztrim = zscore_img(img, margin=NULL,
centrality = "trimmed_mean", variability = "trimmed_sd")
z = zscore_img(img, centrality = "median", variability = "iqr")
z = zscore_img(img, centrality = "median", variability = "iqrdiff")
z = zscore_img(img, centrality = "median", variability = "maddiff")
[Package neurobase version 1.32.4 Index]