R/correct_image_dim.R

Defines functions correct_image_dim

Documented in correct_image_dim

#' @title Image Dimension Correction
#' @description This function takes an image and drops dimensions
#' until the volume is a user specified dimension.
#' @param image volume of class \code{\link{nifti}}
#' @param dim scalar value of desired image dimension
#' @return Returns a volume of class \code{\link{nifti}} of desired dimension.
#' @examples \dontrun{
#' library(neurobase)
#' flair <- readnii('path/to/flair', reorient = FALSE)
#' flair <- correct_image_dim(flair, dim = 3)
#' }
#' @export
#' @importFrom oro.nifti drop_img_dim
correct_image_dim <- function(image, dim = 3){
  out.img <- image
  while (length(dim(out.img)) > dim) {
    out.img <- drop_img_dim(out.img)
  }
  return(out.img)
}

Try the oasis package in your browser

Any scripts or data that you put into this service are public.

oasis documentation built on May 2, 2019, 2:31 a.m.