Print

Print


Hi Jesper,

Thank you for your reply. Could you please clarify to me what A.inv() stands in your notation below?

(x',y',z',1).T() = A.inv()*(x,y,z,1).T() + (d_x(i,j,k),d_y(i,j,k),d_z(i,j,k),0).T()

Thank you,
Eleftherios

 

From: FSL - FMRIB's Software Library [[log in to unmask]] on behalf of Jesper Andersson [[log in to unmask]]
Sent: 01 December 2010 14:23
To: [log in to unmask]
Subject: Re: [FSL] Understanding fnirt displacements

Dear Eleftherios,

there is an affine matrix (that which you supplied to fnirt as a starting guess) "hidden" inside the header of the warp file (the warp file being the output of fnirtfileutils). In addition the transform is applied in "world coordinates" or "mm coordinates". So if we assume (x,y,z) are in "mm coordinates" and corresponds to the index (i,j,k) in the reference image then the transform is given by

(x',y',z',1).T() = A.inv()*(x,y,z,1).T() + (d_x(i,j,k),d_y(i,j,k),d_z(i,j,k),0).T()

So note that you index the displacement fields with the original index, and that yes, the displacements are in mm.

You then need to transform x',y',z' into indices (or "voxel coordinates") in order to use it to index into the image you are warping.

For the transformations back and forth between indices and "world coordinates" you use the diagonal matrix of voxel sizes as you have indicated.

Hope this helps.

Jesper

Yes, it does help. If that is the case then I am probably doing something wrong. Could you please confirm/correct the following?

Lets assume that we have one grid point at location (i,j,k) in the initial FA image and we want to warp it to the reference image (FMRIB58_FA). After warping the point will be at (i',j',k') in the reference image space.

Then as far as I understand we need to do the following

(i',j',k',1).T = A*(i,j,k,1).T 

where A is a 4x4 matrix which is made by the .mat file left multiplied with the inverse diagonal matrix of the voxel sizes(zooms) of the reference image and right multiplied by the diagonal matrix of the voxel sizes(zooms) of the initial image. At this point i',j',k' is now at the reference image space but only affine transformed, then we need to update them with the displacements which will do the warping bit

(i',j',k',1).T= (i',j',k',1).T +(d(i',j',k',0),d(i',j',k',1),d(i',j',k',2),1).T

where .T denotes the transpose, d the displacements read from the output nii of  fnirtfileutils interpolated at the points i',j',k'

Is there anything else that is necessary? 
Do you see any problems with this approach? 
Are the displacements in mm (millimetres)? 


Thank you,
Eleftherios







From: FSL - FMRIB's Software Library [[log in to unmask]] on behalf of Jesper Andersson [[log in to unmask]]
Sent: 01 December 2010 06:28
To: [log in to unmask]
Subject: Re: [FSL] Understanding fnirt displacements

Dear Eleftherios,

For learning purposes I am trying to create my own apply warp where you give as an input your FA image, the affine transform and the displacement nifti and then warp the FA image to the FMRIB58_FA template.  It seemed to me easier to use fnirtfileutils and work directly with the displacements(by fnirtfileutils) rather than the intermediate image generated by fnirt. 

When I use FSL's command applywarp the registration looks very good however when I visualize the displacements it looks like they are applied in the entire space even outside the unmasked area and having quite large displacements near the foreground/background edge. 

So, here is my question:
Do they displacements need any preprocessing/transformation/masking before applying them to the image to be warped?

No, they don't.

The mask is used to select the voxels from which to use information to obtain/create the warps. It doesn't mean there cannot be warps out there. The reason warps are propagated from within the mask (where there is information) to outside the mask is because of the "regularisation". The regularisation term enforces smoothness of the warps, so that all other things equal it will chose the smoothest set of warps. The regularisation term is estimated from the entire FOV, not just within the mask. Hence, the smoothest field is that which changes as little as possible as one goes from inside to outside of the mask.

Hope that helps to clarify things?

Jesper