% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/imaging-ants-io.R
\name{write_ants_transform}
\alias{write_ants_transform}
\alias{read_ants_transform}
\title{Read and write an \verb{'ITK'}/\verb{'ANTs'} \verb{affine} transform}
\usage{
write_ants_transform(transform, file)

read_ants_transform(file)
}
\arguments{
\item{transform}{a \eqn{4\times 4} (or \eqn{3\times 4}) \verb{RAS} \verb{affine}}

\item{file}{path to the \code{.mat} file}
}
\value{
\code{write_ants_transform} returns \code{file} invisibly;
\code{read_ants_transform} returns a \eqn{4\times 4} \verb{RAS} matrix.
}
\description{
\code{write_ants_transform} stores a \eqn{4\times 4} \verb{RAS}-to-\verb{RAS}
\verb{affine} (such as the \code{transform} returned by
\code{\link{register_volume3d}}) as an \pkg{'ITK'} \code{.mat} file (a
\code{'MATLAB'} level-5 binary, \verb{LPS} convention) compatible with
\code{antsApplyTransforms}. \code{read_ants_transform} reads such a file back
into a \eqn{4\times 4} \verb{RAS} matrix. The reader folds a non-zero
\verb{ITK} center of rotation into the translation, so transforms written by
\pkg{'ANTs'} are read correctly.
}
\examples{
tf <- tempfile(fileext = ".mat")
m <- diag(4); m[1:3, 4] <- c(3, -2, 1)
write_ants_transform(m, tf)
read_ants_transform(tf)
}
\seealso{
\code{\link{register_volume3d}}, \code{\link{save_registration}}
}
