R/generate_mask.R

Defines functions generate_mask

Documented in generate_mask

#' Helper function: Generate mask nifti object
#'
#' @param img object of class nifti to generate mask
#' @param saveinfti if saveinfti = TRUE, save result to NIfTI file.
#' @param file the name or connection of the file where the csv file is saved to.
#'
#' @return object of class nifti as mask
#' @export
#'
#' @examples
#' library(neurorct)
#'
#'
generate_mask = function(img = neurorct:::template_nifti, saveinfti = FALSE, file = ''){
  mask <- img
  mask@.Data <- 0*img@.Data
  mask@.Data[img@.Data > 1000] <- 1

  if (saveinfti == TRUE) {
    writeNIfTI(mask, file = file, gzipped = FALSE)
  }

  return(mask)
}
seonjoo/neurorct documentation built on May 7, 2020, 3:18 a.m.