I need a full affine matrix that I can save and use with flirt using the *.eddy_parameters file.
For example, I would like to manually use flirt with -applyxfm on the last diffusion weighted image in order to align it with the first diffusion weighted image (This example may seem trivial, but I essentially have to do this with other niftis associated with the diffusion weighted images, to account for the motion correction done by eddy).
I specifically need the transform to get the later diffusion weighted niftis aligned with the first diffusion weighted nifti.
From the documentation, the rotation sub-matrix part of the affine transform should look something like:
thetax = eddy_params(i,4);
thetay = eddy_params(i,5);
thetaz = eddy_params(i,6);
rotx = [1 0 0; ...
0 cos(thetax) sin(thetax); ...
0 -sin(thetax) cos(thetax)];ed
roty = [cos(thetay) 0 -sin(thetay); ...
0 1 0; ...
sin(thetay) 0 cos(thetay)];
rotz = [cos(thetaz) sin(thetaz) 0;
-sin(thetaz) cos(thetaz) 0;
0 0 1];
rot = (rotx * roty * rotz)^-1;
But I am not sure about incorporating the translational parameters. I am specifically not sure if the translation is applied, then the rotation (or vice verse). I am also not sure what the units of translation are. If someone could provide some matlab pseudo code that would be great.
|