R/antsCopy.R

Defines functions antsCopySpacing antsCopyDirection antsCopyOrigin

Documented in antsCopyDirection antsCopyOrigin antsCopySpacing

#' @title Copy Information of One Image to Another
#' @description Wraps \code{antsSetOrigin/antsSetDirection/antsSetSpacing} 
#' and \code{antsGetOrigin/antsGetDirection/antsGetSpacing}
#' to copy the information over.  Finer control than 
#' \code{antsCopyImageInfo}
#'
#' @param reference \code{antsImage} object to get origin values from
#' @param target \code{antsImage} object to copy origin values to
#'
#' @return \code{target} object of class \code{antsImage}
#' @export
#' @name antsCopy
#' @rdname antsCopy
#' @examples
#' library(ANTsR)
#' img <- makeImage(c(10,10),rnorm(100))
#' img2 <- makeImage(c(10,10), rnorm(100))
#' img2 <- antsCopyOrigin(img, img2)
#' @importFrom ANTsRCore antsSetOrigin
antsCopyOrigin = function(reference, target){
  t2 = antsImageClone(target)
  antsSetOrigin(t2, as.numeric(antsGetOrigin(reference)))
  return(t2)
}


#' @rdname antsCopy
#' @export
#' @importFrom ANTsRCore antsSetDirection
antsCopyDirection = function(reference, target){
  t2 = antsImageClone(target)
  antsSetDirection(t2, antsGetDirection(reference))
  return(t2)
}

#' @rdname antsCopy
#' @export
#' @importFrom ANTsRCore antsSetSpacing
antsCopySpacing = function(reference, target){
  t2 = antsImageClone(target)
  antsSetSpacing(t2, antsGetSpacing(reference))
  return(t2)
}
neuroconductor/extrantsr documentation built on Jan. 3, 2020, 10:22 p.m.