write.fs.transform.fslmat: Write a transformation matrix in FSL format.

View source: R/write_fs_transform.R

write.fs.transform.fslmatR Documentation

Write a transformation matrix in FSL format.

Description

Write 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.

Usage

write.fs.transform.fslmat(tf, filepath)

Arguments

tf

an fs.transform instance whose matrix maps voxel coordinates to voxel coordinates.

filepath

character string, the full path of the file to write.

Value

the fs.transform instance tf, invisibly.

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)
unlink(out_file)


freesurferformats documentation built on Sept. 25, 2026, 1:07 a.m.