linear transform track file

Hi, is there any tool can linearly transform a tck file with a tranformation matrix, as the " tcktransform" needs an image warp

1 Like

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.


1 Like

For clarity, this is a bit of a feature hole at the moment that we will hopefully rectify. I had this functionality implemented a long time ago, but in an exceptionally large feature development branch that is well and truly incomplete, and hence it never made it to the public release.