This function smooth an image within a mask and replaces the values of the original image with the smoothed values.
fslsmooth_in_mask(file, sigma = 10, mask = NULL, ...)
fsl_smooth_in_mask(...)
(character) image to be smoothed
(numeric) sigma (in mm) of Gaussian kernel for smoothing
(character) optional mask given for image
additional arguments passed to fslsmooth
.
Object of class nifti
if (have.fsl()){
system.time({
dims = c(50, 50, 20)
x = array(rnorm(prod(dims)), dim = dims)
img = nifti(x, dim= dims,
datatype = convert.datatype()$FLOAT32, cal.min = min(x),
cal.max = max(x), pixdim = rep(1, 4))
mask = abs(img ) > 1
s.img = fslsmooth_in_mask(img, mask = mask)
})
}
#> fslmaths "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpKzob0N/file85754ab432d.nii.gz" -mas "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpKzob0N/file85757c741c0.nii.gz" -s 10 "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpKzob0N/file85752aada83d"; fslmaths "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpKzob0N/file85757c741c0.nii.gz" -s 10 "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpKzob0N/file85756f0052ae.nii.gz"; fslmaths "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpKzob0N/file85752aada83d" -div "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpKzob0N/file85756f0052ae.nii.gz" -mas "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpKzob0N/file85757c741c0.nii.gz" "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpKzob0N/file85752aada83d";
#> user system elapsed
#> 0.309 0.015 0.365