Read a transformation matrix from an FSL matrix file.
Source:R/read_fs_transform.R
read.fs.transform.fslmat.RdRead the plain text 4x4 matrix that FSL's flirt writes with the -omat option, and that FSL,
MRtrix3 and FreeSurfer read as the registration between two images.
Value
an fs.transform instance. An FSL matrix maps the voxel coordinates of the image given to flirt -in to those of the image given to flirt -ref. Both are voxel indices, so space_in and space_out are
'voxel' and voxel_base is 0 (FSL voxel indices are zero-based). The two images are not recorded in the
file, so src and dst are NULL and the volumes have to be passed to transform2world
to interpret the matrix in world coordinates.
See also
Other header coordinate space:
invert.fs.transform(),
is.fs.transform(),
mghheader.is.ras.valid(),
mghheader.ras2vox(),
mghheader.ras2vox.tkreg(),
mghheader.scanner2tkreg(),
mghheader.tkreg2scanner(),
mghheader.vox2ras(),
mghheader.vox2ras.tkreg(),
print.fs.transform(),
read.fs.transform(),
read.fs.transform.dat(),
read.fs.transform.itk(),
read.fs.transform.lta(),
read.fs.transform.xfm(),
sm0to1(),
sm1to0(),
summary.fs.transform(),
transform2lps(),
transform2ras(),
transform2voxel(),
transform2world(),
write.fs.transform(),
write.fs.transform.dat(),
write.fs.transform.fslmat(),
write.fs.transform.itk(),
write.fs.transform.lta(),
write.fs.transform.xfm()
Examples
# Write the example LTA as an FSL matrix and read it back: no FSL installation is needed for that.
lta_file <- system.file("extdata", "talairach.lta", package = "freesurferformats", mustWork = TRUE)
mat_file <- tempfile(fileext = ".mat")
write.fs.transform(read.fs.transform(lta_file), mat_file, format = "fslmat")
read.fs.transform(mat_file)$matrix
#> [,1] [,2] [,3] [,4]
#> [1,] 1.054775715 0.007081697 -0.05151368 -2.029556
#> [2,] 0.005556736 1.116058946 0.33849043 -5.882306
#> [3,] 0.060359493 -0.274788439 0.85348159 37.464622
#> [4,] 0.000000000 0.000000000 0.00000000 1.000000
unlink(mat_file)