This function is used to read a 4x4 numeric matrix representing an affine
transformation from a file. It is a wrapper around read.table which
additionally ensures that required attributes are set. The type of the
matrix must be specified, as there are differing conventions across
software packages.
readAffine(fileName, source = NULL, target = NULL, type = NULL)A string giving the file name to read the affine matrix from.
The source image for the transformation. If NULL, the
file will be searched for a comment specifying the path to a NIfTI file.
The target image for the transformation. If NULL, the
file will be searched for a comment specifying the path to a NIfTI file.
The type of the affine matrix, which describes what convention
is it is stored with. Currently valid values are "niftyreg" and
"fsl" (for FSL FLIRT). If NULL, the function will look in
the file for a comment specifying the type.
An matrix with class "affine", converted to the NiftyReg
convention and with source and target attributes set
appropriately.
print(readAffine(system.file("extdata","affine.txt",package="RNiftyReg")))
#> NiftyReg affine matrix:
#> 0.997279 0.000236 -0.014852 0.345679
#> -0.000270 0.999953 -0.017860 0.110333
#> 0.017292 0.011234 1.001145 -28.181461
#> 0.000000 0.000000 0.000000 1.000000
#>