R/fsldiv.R

Defines functions fsldiv

Documented in fsldiv

#' @title Divide Images using FSL 
#' @description This function calls \code{fslmaths -div}.  
#' The R functions wraps \code{fslmaths}
#' @param file (character) input image 
#' @param file2 (character) image to be divided
#' @param outfile (character) resultant image name (optional)
#' @param retimg (logical) return image of class nifti
#' @param reorient (logical) If retimg, should file be reoriented 
#' when read in?
#' Passed to \code{\link{readnii}}.
#' @param intern (logical) to be passed to \code{\link{system}}
#' @param opts (character) operations to be passed to \code{fslmaths}
#' @param ... additional arguments passed to \code{\link{readnii}}.
#' @return If \code{retimg} then object of class nifti.  Otherwise,
#' Result from system command, depends if intern is TRUE or FALSE.
#' @export
fsldiv = function(
  file,
  file2,
  outfile=NULL, 
  retimg = TRUE,
  reorient = FALSE,
  intern = FALSE, 
  opts = "", 
  ...){
  
  file2 = checkimg(file2, ...)
  all.opts = paste(paste("-div ", file2), 
                   opts, collapse=" ")
  res = fslmaths(file=file, 
                 outfile=outfile, 
                 retimg=retimg, reorient=reorient,
                 intern=intern, opts = all.opts, ...)
  
  return(res)  
}
muschellij2/fslr documentation built on Aug. 31, 2022, 8:47 p.m.