Learn R Programming

freesurferformats (version 1.1.0)

write.fs.transform.dat: Write a tkregister dat file.

Description

Write a transformation in the FreeSurfer tkregister format (register.dat), the format that mri_vol2vol --reg, tkregister2 and bbregister use. Such a matrix maps the voxel coordinates of the movable volume (the source) to RAS coordinates in the tkregister frame of the target volume, see mghheader.vox2ras.tkreg, so a transformation can only be written if this is what it maps.

Usage

write.fs.transform.dat(
  tf,
  filepath,
  subject = NULL,
  in_plane_resolution = NULL
)

Value

the fs.transform instance tf, invisibly.

Arguments

tf

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

filepath

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

subject

NULL or character string, the subject identifier to store in the first line of the file. This is metadata for the tools that read the file and does not influence the transformation. If NULL and tf has a subject field (as read by read.fs.transform.dat), that value is used.

in_plane_resolution

NULL or numerical vector of length 2, the in-plane and between-plane resolution of the movable volume in millimeters, stored in the second and third line of the file. These are metadata that describe the acquisition and do not influence the transformation. If NULL and tf has the corresponding fields, they are used, otherwise they are derived from the geometry of the source volume, and set to 1 if that is not available either.

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

Examples

Run this code
dat_file <- system.file("extdata", "register.dat", package = "freesurferformats", mustWork = TRUE)
tf <- read.fs.transform(dat_file)
out_file <- tempfile(fileext = ".dat")
write.fs.transform.dat(tf, out_file)
max(abs(read.fs.transform(out_file)$matrix - tf$matrix)) # 0
unlink(out_file)

Run the code above in your browser using DataLab