function summary=stat_summary(input_file, fwhm, df, mask_file, mask_thresh, ... input_thresh, flip); %STAT_SUMMARY % % SUMMARY = STAT_SUMMARY( INPUT_FILE , [FWHM , [DF , [MASK_FILE, MASK_THRESH ... % [, INPUT_THRESH [, FLIP]]]]] ) % % Produces an SPM-style glass brain and summary analysis of a T or F statistic % image. P-values for local maxima and cluster sizes are based on non-isotropic % random field theory if an FWHM image is provided (or a Bonferroni correction, % if smaller). The random field theory is based on the assumption that % the search region is a sphere (in isotropic space), which is a very tight % lower bound for any non-spherical region. % % Finds local maxima and clusters of INPUT_FILE above INPUT_THRESH % and MASK_FILE above MASK_THRESH (ignored if empty; empty by default). % If INPUT_THRESH < 1 then it is taken as a probability and threshold is % chosen so that the uncorrected P-value is INPUT_THRESH (0.001 by default), % If MASK_THRESH is a vector [a b], a<=b, then mask is a0 then DF1 and DF2 are the df's of the F statistic image. % DFW1 and DFW2 are the numerator and denominator df of the FWHM image. % If DF=[DF1 DF2] (row) then DFW1=DFW2=Inf, i.e. FWHM is fixed. % If DF=[DF1; DFW1] (column) then DF2=0 and DFW2=DFW1, i.e. t statistic. % If DF=DF1 (scalar) then DF2=0 and DFW1=DFW2=Inf, i.e. t stat, fixed FWHM. % If any component of DF >= 1000 then it is set to Inf. Default is Inf. % % SUMMARY is a matrix with 12 columns. % Col 1: index of cluster, in descending order of cluster volume. % Col 2: volume of cluster in mm^3. % Col 3: resels of cluster. % Col 4: P-value of cluster extent. % Col 5: P-value if the cluster was chosen in advance, e.g. nearest to an ROI. % Col 6: values of local maxima, sorted in descending order. % Col 7: P-value of local maxima. % Col 8: P-value if the peak was chosen in advance, e.g. nearest to an ROI. % Col 9: Q-value or false discovery rate ~ probability that voxel is not signal. % Cols 10-12: x,y,z coords of local maxima in C notation i.e. starting at 0. % If x or y step sizes are negative, then their voxel indices % are reversed so that they agree with 'register'. if nargin < 2 fwhm=0 end if nargin < 3 df=Inf end if nargin < 4 mask_file=[]; end if nargin < 6 input_thresh=0.001 end if nargin < 7 flip=1 end if input_thresh < 1 input_thresh=stat_threshold3(1,1,0,df,input_thresh) end [search_volume, voxel_volume]= ... glass_brain(input_file,input_thresh,mask_file,mask_thresh,flip); lm=locmax(input_file,input_thresh,mask_file,mask_thresh,fwhm,flip); if isstr(fwhm) d=fmris_read_image(fwhm,0,0); numslices=d.dim(3); voxel_volume=abs(prod(d.vox)); if ~isempty(mask_file) mask_thresh1=mask_thresh(1); if length(mask_thresh)>=2 mask_thresh2=mask_thresh(2); else mask_thresh2=Inf; end d=fmris_read_image(mask_file,1:numslices,1); mask=d.data; mask= (mask>mask_thresh1 & mask<=mask_thresh2); d=fmris_read_image(fwhm,1:numslices,2); search_resels=sum(sum(sum(mask.*d.data))) else d=fmris_read_image(fwhm,1:numslices,2); search_resels=sum(sum(sum(d.data))) end voxel_resels=voxel_volume*(search_resels/search_volume) average_fwhm=(search_volume/search_resels)^(1/3) [p_peak, p_cluster, p_peak1, p_cluster1]= ... stat_threshold(search_resels, voxel_resels, 1, ... df, lm(:,1), input_thresh, lm(:,7)); else [p_peak, p_cluster, p_peak1, p_cluster1]= ... stat_threshold(search_volume, voxel_volume, fwhm, ... df, lm(:,1), input_thresh, lm(:,6)); end q_value = fdr_threshold( input_file, input_thresh, ... mask_file, mask_thresh, df, lm(:,1),flip); n=size(lm,1); ['clus vol resel p-val (one) peak p-val (one) q-val x y z'] summary=[repmat(' ',n,1) num2str(round(lm(:,5))) repmat(' ',n,1) ... num2str(round(lm(:,6))) repmat(' ',n,1) ... num2str(round(lm(:,7)*100)/100) repmat(' ',n,1) ... num2str(round(p_cluster*1000)/1000) repmat(' (',n,1) ... num2str(round(p_cluster1*1000)/1000) repmat(') ',n,1) ... num2str(round(lm(:,1)*100)/100) repmat(' ',n,1) ... num2str(round(p_peak*1000)/1000) repmat(' (',n,1) ... num2str(round(p_peak1*1000)/1000) repmat(') ',n,1) ... num2str(round(q_value'*1000)/1000) repmat(' ',n,1) ... num2str(round(lm(:,2:4)))] return