Subject: Fwd: Re: tabulating all statistics
From: John Ashburner <john@FIL.ION.UCL.AC.UK>
Date: Tue, 1 Jul 2003 11:47:07 +0000 (07:47 EDT)
To: SPM@JISCMAIL.AC.UK
> I was wondering if it would be possible to write t values for an
> entire volume into a file?
Try this:
fid=fopen('t-values.txt','w');
P=spm_get(1,'*.img','Select statistic image');
V=spm_vol(P);
[x,y,z] = ndgrid(1:V.dim(1),1:V.dim(2),0);
for i=1:V.dim(3),
z = z + 1;
tmp = spm_sample_vol(V,x,y,z,0);
msk = find(tmp~=0 & finite(tmp));
if ~isempty(msk),
tmp = tmp(msk);
xyz1=[x(msk)'; y(msk)'; z(msk)'; ones(1,length(msk))];
xyzt=V.mat(1:3,:)*xyz1;
for j=1:length(tmp),
fprintf(fid,'%.4g %.4g %.4g\t%g\n',...
xyzt(1,j),xyzt(2,j),xyzt(3,j),tmp(j));
end;
end;
end;
fclose(fid);
best regards,
-John
As noted in a 2 Feb 2004 email, to eliminate all voxels below a certain threshold, change
msk = find(tmp~=0 & finite(tmp));
to
msk = find(tmp>0 & finite(tmp));