fslerode: Erode image using FSL

View source: R/fslhd.R

fsl_erodeR Documentation

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

fsl_erode(..., outfile = tempfile(fileext = ".nii.gz"), retimg = FALSE)

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

Arguments

...

additional arguments passed to readnii.

outfile

(character) resultant eroded image name

retimg

(logical) return image of class nifti

file

(character) image to be eroded

reorient

(logical) If retimg, should file be reoriented when read in? Passed to readnii.

intern

(logical) to be passed to system

kopts

(character) options for kernel

opts

(character) additional options to be passed to fslmaths

verbose

(logical) print out command before running

Value

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

Note

Functions with underscores have different defaults and will return an output filename, so to be used for piping

Examples

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
eroded = fslerode(mask, kopts = "-kernel boxv 5", retimg=TRUE)
})
}    

muschellij2/fslr documentation built on Aug. 31, 2022, 8:47 p.m.