write.fs.transform.lta: Write a FreeSurfer linear transform array (LTA) file.

View source: R/write_fs_transform.R

write.fs.transform.ltaR Documentation

Write a FreeSurfer linear transform array (LTA) file.

Description

Write a transformation in the LTA format, which is the format FreeSurfer uses to exchange linear transformations and that is read by mri_vol2vol, tkregister2, mri_register and lta_convert.

The file states in its header whether the matrix operates on voxel indices (type 0, LINEAR_VOX_TO_VOX) or on RAS coordinates (type 1, LINEAR_RAS_TO_RAS), so the spaces of the transformation determine the type that is written. The geometry of the volumes is written from the src and dst descriptors, which makes the file self-contained: FreeSurfer can convert it to other spaces without being given the volumes again.

Usage

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

Arguments

tf

an fs.transform instance whose matrix maps either voxel coordinates to voxel coordinates, or RAS coordinates to RAS coordinates.

filepath

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

Value

the fs.transform instance tf, invisibly.

Note

The mean and sigma header entries of an LTA file describe the registration that produced the matrix and are not used to interpret it. They are taken from the header field of tf if it has them, and are otherwise set to the center of the source volume and to 10000.

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.fslmat(), write.fs.transform.itk(), write.fs.transform.xfm()

Examples

lta_file <- system.file("extdata", "talairach.lta", package = "freesurferformats", mustWork = TRUE)
tf <- read.fs.transform(lta_file)
out_file <- tempfile(fileext = ".lta")
write.fs.transform.lta(tf, out_file)
max(abs(read.fs.transform(out_file)$matrix - tf$matrix)) # 0, the matrix survives the round trip
unlink(out_file)


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