It can't do this, but if you can do a bit of MATLAB coding (and you have
DARTEL installed and your path set up to it), then this snippet of code may
be helpful.
Best regards,
-John
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
make_rectangles
d = size(f);
d = d(1:2);
prm = [0 1 1 0.1 0.1 1e-4]; % You may need to fiddle here
A = zeros([d,3]);
bs_args = [3 3 0 1 1 1];
g = spm_bsplinc(g,bs_args);
u0 = zeros([d,2]);
phi = dartel2('Exp',u0,0);
for iter=1:128,
[g1,d1,d2,tmp] = spm_bsplins(double(g),...
double(phi(:,:,1)),phi(:,:,2),...
ones(d),bs_args);
tmp = (g1-f);
ll = 0.5*sum(tmp(:).^2); % Likelihood term
b = zeros([d,2]); % First derivatives
b(:,:,1) = tmp.*d1;
b(:,:,2) = tmp.*d2;
A = zeros([d,3]); % Approx. second derivatives
A(:,:,1) = d1.*d1;
A(:,:,2) = d2.*d2;
A(:,:,3) = d1.*d2;
m0 = dartel2('vel2mom',u0,prm);
ll1 = 0.5*sum(m0(:).*u0(:)); % Prior term
closeness = sum((b(:)+m0(:)).^2)/(sum(b(:).^2)+eps);
fprintf('%2d\t%g\t%g\t%g\t%g\n', iter, ...
ll/prod(d), ll1/prod(d), (ll1+ll)/prod(d), ...
closeness);
u0 = u0 - dartel2('fmg',A, b+m0, [prm(1:5) prm(6)+1e-6 4 4]);
phi = dartel2('Exp', u0,0);
if closeness<1e-5, break; end % Done
end
figure
plot(phi(:,1:4:end,1),phi(:,1:4:end,2),'k',phi(1:4:end,:,1)',phi(1:4:end,:,2)','k')
axis image xy
figure
imagesc([g' g1' f']);
axis image xy off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
On Tuesday 18 November 2008 15:26, you wrote:
> I would like to use the SPM5 normalisation tools to warp a 2D image that is
> not a brain. Can SPM5 do this?
>
> At the moment I am getting an error saying there is not enough overlap.
> Could this be because there is only one slice?
>
> Is there a way of restricting the warping to 2D?
>
> I assume that restricting the bounding box doesn't do this.
>
> Details:
> source is 512*512 image
> template is 512*512 image
> Have set origin to voxel [256 256 1] and bounding box to [255 -255 0;-256
> 256 0] (set voxel size to 1x1x1mm and default flipping is 1
>
>
> Regards
> Joel
|