This function calls fslmaths -ero
after inverting the image
to dilate an image with either
the default FSL kernel or the kernel specified in kopts
. The function
either saves the image or returns an object of class nifti.
fsl_dilate(..., outfile = tempfile(fileext = ".nii.gz"), retimg = FALSE)
fsldilate(
file,
outfile = NULL,
retimg = TRUE,
reorient = FALSE,
intern = FALSE,
kopts = "",
opts = "",
verbose = TRUE,
...
)
additional arguments passed to readnii
.
(character) resultant dilated image name
(logical) return image of class nifti
(character) image to be dilated
(logical) If retimg, should file be reoriented when read in?
Passed to readnii
.
(logical) to be passed to system
(character) options for kernel
(character) additional options to be passed to fslmaths
(logical) print out command before running
Result from system command, depends if intern is TRUE or FALSE. If retimg is TRUE, then the image will be returned.
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))
mask = img > .5
dilated = fsldilate(mask, kopts = "-kernel boxv 5", retimg=TRUE)
})
}
#> fslmaths "/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpKzob0N/file85753ad87784.nii.gz" -bin -mul -1 -add 1 -kernel boxv 5 -ero -mul -1 -add 1 "/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T//RtmpKzob0N/file85753cc929d1"
#> user system elapsed
#> 0.311 0.004 0.316