View source: R/write_fs_transform.R
| write.fs.transform | R Documentation |
Save an fs.transform instance in one of the supported transformation file formats.
A transformation stores its matrix together with the coordinate spaces it maps between, and the formats
disagree about which spaces they can express. A transformation is only written if the format can represent it
exactly, because a silent conversion would change the meaning of the matrix: FSL matrix files, for example,
store voxel-to-voxel matrices, so a transformation in world coordinates must be converted first with
transform2voxel. A format that cannot express the transformation at all is an error, not a
warning.
write.fs.transform(tf, filepath, format = "auto")
tf |
an |
filepath |
character string, the full path of the file to write. |
format |
character string, the file format, one of 'auto' (guess from the file extension), 'fslmat' (an
FSL/FLIRT matrix file, i.e. a plain text 4x4 matrix as written by FSL's |
the fs.transform instance tf, invisibly.
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.dat(),
write.fs.transform.fslmat(),
write.fs.transform.itk(),
write.fs.transform.lta(),
write.fs.transform.xfm()
tf <- read.fs.transform(system.file("extdata", "talairach.lta",
package = "freesurferformats", mustWork = TRUE
))
out_file <- tempfile(fileext = ".mat")
# An LTA of type 0 is a voxel-to-voxel transformation, so it can be written as an FSL matrix.
write.fs.transform(tf, out_file, format = "fslmat")
read.fs.transform(out_file)$matrix
unlink(out_file)
# The same transformation can be written in the FreeSurfer formats of the spaces it maps between.
out_file <- tempfile(fileext = ".lta")
write.fs.transform(tf, out_file)
unlink(out_file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.