write_ants_transform: Read and write an 'ITK'/'ANTs' affine transform

View source: R/imaging-ants-io.R

write_ants_transformR Documentation

Read and write an ⁠'ITK'⁠/⁠'ANTs'⁠ ⁠affine⁠ transform

Description

write_ants_transform stores a 4\times 4 ⁠RAS⁠-to-⁠RAS⁠ ⁠affine⁠ (such as the transform returned by register_volume3d) as an 'ITK' .mat file (a 'MATLAB' level-5 binary, ⁠LPS⁠ convention) compatible with antsApplyTransforms. read_ants_transform reads such a file back into a 4\times 4 ⁠RAS⁠ matrix. The reader folds a non-zero ⁠ITK⁠ center of rotation into the translation, so transforms written by 'ANTs' are read correctly.

Usage

write_ants_transform(transform, file)

read_ants_transform(file)

Arguments

transform

a 4\times 4 (or 3\times 4) ⁠RAS⁠ ⁠affine⁠

file

path to the .mat file

Value

write_ants_transform returns file invisibly; read_ants_transform returns a 4\times 4 ⁠RAS⁠ matrix.

See Also

register_volume3d, save_registration

Examples

tf <- tempfile(fileext = ".mat")
m <- diag(4); m[1:3, 4] <- c(3, -2, 1)
write_ants_transform(m, tf)
read_ants_transform(tf)

ravetools documentation built on Aug. 21, 2026, 5:06 p.m.