Steve Smith wrote:
> Then...the other good news is that we can convert from the IRTK dof warp
> format to a NIFTI warp image (script attached)....the bad news is that
> we haven't released a warp inversion program yet....
Hi,
Not sure if this will help (or make sense to non-SPM users) but...
I think it should be possible to use SPM5's deformation toolbox to
invert the warp once it's in NIfTI format. Some slight tweaking will
be necessary though, since the SPM5 warps are stored including the
affine part (i.e. the values in the 5D nifti are voxel-world mappings
encompassing both the affine and non-rigid mappings).
So I think if you do something like:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
v = spm_vol('image.nii');
w = nifti('warp.nii');
[x y z] = ndgrid(1:v.dim(1),1:v.dim(2),1:v.dim(3));
XYZ = v.mat*[x(:) y(:) z(:) ones(size(x(:)))]';
X = reshape(XYZ(1,:), v.dim(1:3));
Y = reshape(XYZ(2,:), v.dim(1:3));
Z = reshape(XYZ(3,:), v.dim(1:3));
% I think this changes values in-place:
w.dat(:,:,:,1,1) = w.dat(:,:,:,1,1)+X;
w.dat(:,:,:,1,2) = w.dat(:,:,:,1,2)+Y;
w.dat(:,:,:,1,3) = w.dat(:,:,:,1,3)+Z;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
then invert the warp (easiest with the SPM5 GUI,
Tasks->Util->Deformations; otherwise investigate spm_defs.m), and then
do something like the above but subtracting the affine component, you
should end up with the inverted warp in NIfTI format... hopefully!
I've had a quick attempt at this, but I can't actually get dof2warp to
work on my dof-files, in fact dof2gipl seems to fail... (these dofs
didn't come from the FSL version of DR's code though, so that might be
a different problem...)
Anyway, Vasanth or anyone else, if you're interested, let me know and
I could try to code up a more complete version of my fragment above.
Best,
Ged.
|