Thanks Tom,
After fighting a bit with the code I found a way to do this. Here is my
piece of code. There might be more elegant and economic ways of doing it but
this works:
load('SPM.mat');
XYZ0 = SPM.xVol.XYZ;
xCon = SPM.xCon;
VHp = SPM.VResMS;
ic=1; %contrast number in xCon
cB = spm_get_data(xCon(ic).Vcon,XYZ0);
l = spm_get_data(VHp,XYZ0);
VcB = xCon(ic).c'*SPM.xX.Bcov*xCon(ic).c;
Z = cB./sqrt(l*VcB);
M = SPM.xCon(ic).Vcon.mat;
iM=inv(M);
oxyz=[52 30 34]'; %specified location around which I want to find the
maximum
XYZvox = XYZ0;
[null,null,XYZvox,null] = spm_max(Z,XYZvox);
XYZ = M(1:3,:)*[XYZvox; ones(1,size(XYZvox,2))];
[xyz,i,d] = spm_XYZreg('NearestXYZ',oxyz,XYZ);
disp(sprintf(['\n\tJumped %0.2fmm from [%3.0f, %3.0f, %3.0f],\n\t\t\t',...
'to [%3.0f, %3.0f, %3.0f]\n'],...
d, oxyz, xyz))
%load the contrast image
V=spm_vol(['con000' num2str(ic)]);
ijk=iM(1:3,:)*[xyz; 1];
contrast_at_nearest_local_maximum=spm_sample_vol(V,ijk(1),ijk(2),ijk(3),0);
Hope this helps others.
Albert
|