This function calls fslmaths -s
to smooth an image and either
saves the image or returns an object of class nifti
fsl_smooth(..., outfile = tempfile(fileext = ".nii.gz"), retimg = FALSE)
fslsmooth(
file,
sigma = 10,
mask = NULL,
smooth_mask = TRUE,
smoothed_mask = NULL,
outfile = NULL,
retimg = TRUE,
reorient = FALSE,
intern = FALSE,
verbose = TRUE,
...
)
additional arguments passed to readnii
.
(character) resultant smoothed image name (optional) if not give, will be the stub of the filename then _sigma
(logical) return image of class nifti
(character or nifti) image to be smoothed
(numeric) sigma (in mm) of Gaussian kernel for smoothing
(character) optional mask given for image
(logical) Smooth mask? If TRUE, the masked image will be divided by the smoothed mask.
(character or nifti) If specified and
smooth_mask = TRUE
, then will use this as the smoothed mask for
division.
(logical) If retimg, should file be reoriented when read in?
Passed to readnii
.
(logical) to be passed to system
(logical) print out command before running
Result from system command, depends if intern is TRUE or FALSE.
Functions with underscores have different defaults and will return an output filename, so to be used for piping
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))
s.img = fslsmooth(img, retimg=TRUE)
})
}
#> fslmaths "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpKzob0N/file8575a971e46.nii.gz" -s 10 "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpKzob0N/file857547448b18";
#> user system elapsed
#> 0.092 0.005 0.101