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)

Arguments

fileName

A string giving the file name to read the affine matrix from.

source

The source image for the transformation. If NULL, the file will be searched for a comment specifying the path to a NIfTI file.

target

The target image for the transformation. If NULL, the file will be searched for a comment specifying the path to a NIfTI file.

type

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.

Value

An matrix with class "affine", converted to the NiftyReg convention and with source and target attributes set appropriately.

See also

Author

Jon Clayden <code@clayden.org>

Examples

print(readAffine(system.file("extdata","affine.txt",package="RNiftyReg")))
#> NiftyReg affine matrix:
#>   0.9972794652    0.0002360211   -0.0148521177    0.3456794620
#>  -0.0002703219    0.9999528527   -0.0178595595    0.1103327721
#>   0.0172918551    0.0112342387    1.0011447668  -28.1814613342
#>   0.0000000000    0.0000000000    0.0000000000    1.0000000000