View source: R/transforms_convert.R
| transform2world | R Documentation |
Transformation files often store their matrix in voxel coordinates, which means that the matrix alone cannot be used to transform world coordinates (e.g. the coordinates of a brain surface vertex, or a peak coordinate from another study): the geometry of the volumes the matrix relates is required as well. This function converts such a transformation into one that operates on world coordinates.
The result depends on the format the transformation was read from, because the formats disagree about their world space, which is why this is not a pure matrix operation:
For an FSL matrix ('fslmat'), the world space is the one FSL uses: unit voxel axes with a flipped first
axis, see fsl.scaled.voxel.matrix. Both MRtrix3 and FreeSurfer implement exactly this, and
the result is a transformation between FSL world coordinates. The src and dst entries of the result
have the frame 'fsl'.
For an LTA of type 0 (VOX2VOX), the world space is the RAS space of the two volume geometries: the result
is vox2ras_dst \%*\% matrix \%*\% solve(vox2ras_src). The descriptors have the frame 'scanner'.
transform2world(tf, src = NULL, dst = NULL)
tf |
an |
src |
|
dst |
|
an fs.transform instance whose matrix operates on world coordinates.
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(),
write.fs.transform(),
write.fs.transform.dat(),
write.fs.transform.fslmat(),
write.fs.transform.itk(),
write.fs.transform.lta(),
write.fs.transform.xfm()
# Read an LTA file, which records both volumes it relates, and convert it to world coordinates.
lta_file <- system.file("extdata", "talairach.lta", package = "freesurferformats", mustWork = TRUE)
tf <- read.fs.transform(lta_file)
tf_world <- transform2world(tf)
tf_world$space_in
tf_world$matrix
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.