Learn R Programming

fslr (version 1.0)

fslerode: Erode image using FSL

Description

This function calls fslmaths -ero to erode 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.

Usage

fslerode(file, outfile = NULL, retimg = FALSE, reorient = FALSE,
  intern = TRUE, kopts = "", opts = "", ...)

Arguments

file
(character) image to be eroded
outfile
(character) resultant eroded image name
retimg
(logical) return image of class nifti
reorient
(logical) If retimg, should file be reoriented when read in? Passed to readNIfTI.
intern
(logical) to be passed to system
kopts
(character) options for kernel
opts
(character) additional options to be passed to fslmaths
...
additional arguments passed to readNIfTI.

Value

  • Result from system command, depends if intern is TRUE or FALSE. If retimg is TRUE, then the image will be returned.

Examples

Run this code
if (have.fsl()){
system.time({
x = array(rnorm(1e6), dim = c(100, 100, 100))
img = nifti(x, dim= c(100, 100, 100),
datatype = convert.datatype()$FLOAT32, cal.min = min(x),
cal.max = max(x), pixdim = rep(1, 4))
mask = img > .5
eroded = fslerode(mask, kopts = "-kernel boxv 5", retimg=TRUE)
})
}

Run the code above in your browser using DataLab