SPM2 Gem 3: Finding p–value and statistics for all voxels

(Note: The program in this email was corrected; I have added the corrections to this message. Also, an additional typo was discovered in Sep 2003 and was fixed.)

Subject: Re: tabulate all voxels of a volume or cluster
From: John Ashburner <john@FIL.ION.UCL.AC.UK>
Date: Thu, 27 Mar 2003 14:26:56 +0000 (09:26 EST)
To: SPM@JISCMAIL.AC.UK

> Is there a possibility to tabulate the p-values and statistics for all
> voxels for the entire volume. (not only the peaks) ?
> Or which data file should I readout to get the desired
> values?

Copy and paste the following into Matlab, and select the appropriate
spmT or spmF images.  The first 3 columns are MNI coordinates.  The
fourth is the statistic.  I haven't included any p-values, but this
would be a relatively simple operation, provifing you can figure out
degres of freedom etc.  Use spm_Tcdf.m or spm_Fcdf.m to do this.



 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('%.4g %.4g %.4g\t%g\n',xyzt(1,j),xyzt(2,j),xyzt(3,j),tmp(j));
     end;
   end;
 end;


Best regards,
-John
  

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s