I had a moment of panic when I thought about this, because the template script does
${WARP} -d ${dim} -e vector -i ${templatename}0warp.nii.gz -o ${templatename}0warp.nii.gz -t [ ${templatename}0GenericAffine.mat,1 ] -r ${template} --verbose 1
and I know warp field vectors are in physical space coordinates, while antsApplyTransforms assumes they are in moving voxel coordinates, and rebases them to the fixed image voxel coordinates.
However, in the shapeupdatetotemplate function, the moving and fixed direction matrices are always the same, so the rebasing cancels to identity.
Before the call above, the average affine transform is applied to the average warp. No reorientation step is done, so if there are rotations in the affine, the vector update will be off as a result.
This problem should converge to near zero after an iteration or two, especially if an affine-only template is built first.
But I wonder if it could contribute to suboptimal convergence if the first round is also deformable.
More generally, it would be nice to have vector reorientation so that we could reorient vectors as well as tensors. It could be like PPD except that it would renormalize to the original vector magnitude. I mostly foresee this being useful for directional data, like fiber orientations, though maybe it would help for templates too.
This would require adding yet another input type to antsApplyTransforms, because one would have to rebase to physical space to compute the orientation from the matrix.
I had a moment of panic when I thought about this, because the template script does
and I know warp field vectors are in physical space coordinates, while
antsApplyTransformsassumes they are in moving voxel coordinates, and rebases them to the fixed image voxel coordinates.However, in the shapeupdatetotemplate function, the moving and fixed direction matrices are always the same, so the rebasing cancels to identity.
Before the call above, the average affine transform is applied to the average warp. No reorientation step is done, so if there are rotations in the affine, the vector update will be off as a result.
This problem should converge to near zero after an iteration or two, especially if an affine-only template is built first.
But I wonder if it could contribute to suboptimal convergence if the first round is also deformable.
More generally, it would be nice to have vector reorientation so that we could reorient vectors as well as tensors. It could be like PPD except that it would renormalize to the original vector magnitude. I mostly foresee this being useful for directional data, like fiber orientations, though maybe it would help for templates too.
This would require adding yet another input type to antsApplyTransforms, because one would have to rebase to physical space to compute the orientation from the matrix.