Write a transformation matrix in FSL format.
Source:R/write_fs_transform.R
write.fs.transform.fslmat.RdWrite a 4x4 matrix as an FSL matrix file, i.e. as the plain text file that FSL's flirt writes
with the -omat option and that FSL, MRtrix3 and FreeSurfer read as the registration between two images. The
matrix must map voxel coordinates to voxel coordinates (space_in and space_out are 'voxel'), because that
is what an FSL matrix stores: it relates the voxel grid of the image given to flirt -in to the voxel grid of
the image given to flirt -ref, and it does not record which images those were. Use
transform2voxel to convert a transformation in world coordinates into one that can be
written.
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.fslmat(),
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.itk(),
write.fs.transform.lta(),
write.fs.transform.xfm()
Examples
tf_file <- system.file("extdata", "talairach.lta", package = "freesurferformats", mustWork = TRUE)
out_file <- tempfile(fileext = ".mat")
write.fs.transform.fslmat(read.fs.transform(tf_file), out_file)
readLines(out_file)
#> [1] "1.054775714874268 0.0070816967636346817 -0.051513675600290298 -2.0295562744140621"
#> [2] "0.0055567356757819653 1.116058945655823 0.33849042654037481 -5.8823056221008301"
#> [3] "0.060359492897987373 -0.27478843927383417 0.85348159074783325 37.464622497558587"
#> [4] "0 0 0 1"
unlink(out_file)