OK, the process isn’t documented particularly well, I have to admit… I’ll try to clarify here.
Not sure what you’re using Matlab for, but what you want to do is to generate a ‘no-warp’ image (for want of a better word) in the target space that you want to warp your tracks into - in your case, the template space:
$ warpinit some_image_in_template_space no-warp.nii
This create a 4D image (no-warp.nii
) with 3 volumes. For each voxel, the 3 volumes correspond to the xyz coordinates in real space of the voxel’s location.
Then you will need to apply the warp that you have previously estimated using whatever registration package you use (ANTs in your case) to warp this image into the original space (subject space, in your case). The process for this will obviously depends on the software used for the registration. If the software can’t handle a 4D NIfTI, break up the NIfTI into a set of 3×3D volumes using the square bracket syntax:
$ warpinit some_image_in_template_space no-warp-[].nii
And warp each of those images into the original space.
At this point, you should have a 4D image (or a set of 3×3D images), where for each voxel, the 3 volumes correspond to the xyz coordinates of the location that this voxel came from in the target space. I’m assuming you’ve called this image warp.nii
(or warp-0.nii
, warp-1.nii
, warp-2.nii
if you broke it up into 3D volumes).
At this point, you can apply the warp:
$ tcknormalise original.tck warp.nii target.tck
Or if your warp was broken up into individual volumes:
$ tcknormalise original.tck warp-[].nii target.tck
This should work as-is, but you may need to play around with it a little…