transform2voxel: Convert a transformation to voxel coordinates.

View source: R/transforms_convert.R

transform2voxelR Documentation

Convert a transformation to voxel coordinates.

Description

The inverse operation of transform2world: given a transformation that operates on world coordinates, compute the matrix that maps voxel indices of one volume to voxel indices of another. The result can be saved as an FSL matrix, see write.fs.transform.fslmat.

Usage

transform2voxel(tf, src = NULL, dst = NULL)

Arguments

tf

an fs.transform instance with a matrix in voxel coordinates (space_in and space_out are 'voxel'). A transformation that already operates on world coordinates is returned unchanged.

src

NULL or the volume the transformation maps from (the ⁠-in⁠ image of FSL, the src volume of an LTA). Required for FSL matrices, since their files do not record the volumes.

dst

NULL or the volume the transformation maps to (the -ref image of FSL, the dst volume of an LTA). Required for FSL matrices.

Value

an fs.transform instance whose matrix operates on (zero-based) voxel coordinates.

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

Examples

lta_file <- system.file("extdata", "talairach.lta", package = "freesurferformats", mustWork = TRUE)
tf_world <- transform2world(read.fs.transform(lta_file))
tf_voxel <- transform2voxel(tf_world)
max(abs(tf_voxel$matrix - read.fs.transform(lta_file)$matrix)) # back where we started


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