linear transform track file

A workaround is to create a linear warp from a linear transform.

Assuming you have a target space image target.mif and an affine transformation A.txt, you can create a warp wi_Ai.mif that does the same as applying A.txt:

$ cat A.txt
1 0 0 50
0 1 0 0
0 0 1 0

# create an identity warp
$ warpinit image.mif wi.mif

# either transform the identity warp to obtain the affine warp `wi_Ai.mif`
$ mrtransform wi.mif -linear A.txt wi_Ai.mif -template target.mif -interp linear -nan
# or compose warp and linear transform:
# $ transformcompose wi.mif A.txt wi_Ai.mif -template target.mif

# check that warp and transformation are equivalent:
# apply the warp
$ mrtransform image.mif -warp wi_Ai.mif image_warped.mif
#  directly use the linear transformation:
$ mrtransform image.mif -linear A.txt image_transformed.mif -template target.mif
$ mrview image_warped.mif image_transformed.mif

Note that the direction and reference space for warps applied to images and to track files are different. See here for more information.

Cheers,
Max

2 Likes