R/dim_.R

#' @docType methods
#' @rdname dim_-methods
#' @title Extract Image dim_ attribute 
#' @name dim_-methods
#' @description \code{dim_} method for class character
#' @aliases dim_,character-method
#' @param object is a filename to pass to \link{fslval}
#' @import oro.nifti
#' @export
setMethod("dim_", "character", function(object){
  object = path.expand(object)
  stopifnot(file.exists(object))
  slots = paste0("dim", 0:7)
  res = sapply(slots, function(key) {
    fslval(object, keyword = key, verbose = FALSE)
  })
  res = as.numeric(res)
  return(res)
})
muschellij2/fslr documentation built on Aug. 31, 2022, 8:47 p.m.