Dear SPMers,
I am using one of John's scripts to extract the global max t value in a
statistical t image. However, I would also like to get the coordinates
associated with this value (or the closest coordintes). Is there any way
I can do this in SPM or using a Matlab script?
the script for getting the max t is below:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Select one .img file
P = spm_get(1,'*.img');
% Read header/mat file information about the image
V = spm_vol(P);
% Initialise maximum value to the most negative possible
mx = -Inf;
% loop over planes (dim(1:3) is the size of the image)
for i=1:V.dim(3),
% The dimensions of the output image. Co-ordinates
% in this image are x = 1..d(1) and y = 1..d(2)
d = V.dim(1:2);
% An affine transformation mapping from x,y to some
% position in the image, such that the co-ordinate
% x,y in the output image has the following
% co-ordinate in the 3D volume:
% pos = M(1:3,:)*[x y 0 1]';
M = spm_matrix([0 0 i]);
% Sample the volume V, according to the transformation
% matrix M, to create a d(1) by d(2) image using
% interpolation method 0 (nearest neighbour).
img = spm_slice_vol(V,M,d,0);
% Maximum value in this plane is:
mxp = max(img(:));
% Maximum value encountered so far is:
mx = max(mx,mxp);
end;
% Display the maximum value
fprintf('Maximum value is %g\n', mx);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Thanks
Mike
|