-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiplayRes.m
189 lines (162 loc) · 5.53 KB
/
DiplayRes.m
1
function Res = DiplayRes(Res,background); % DISPLAYCI displays the results of the Pixel and Cluster tests.% tCi = DisplayCi(Res,[background]) returns, for the Pixel test % (typeTest = 'P'), the Z-scores (tCi) above threshold (tP); and, for the Cluster test % (typeTest = 'C'), the Z-scores (tCi) above threshold (tC) and belonging to clusters % greater than the minimum size (k).% % Res.ZCi = Z-transformed smooth classification image (see ZTRANSCI) % Res.tC = Cluster test threshold (set by the user)% Res.k = Minimun cluster size (see STAT_THRESHOLD)% Res.tP = Pixel test threshold (see STAT_THRESHOLD)% Res.FWHM = full width half maximum of the Gaussian smoothing filter (see HALFMAX)% Res.p = p-value for Pixel and Cluster tests (set by user)% [background] = image overlaid to the classification image to help interpretation.% With red pixels indicating the regions that attained statistical significance. % % E.g.,% SCi = double(imread('GenderCi.tiff')); % sCi = cIm2hrCi(SCi); % sigma_b = 20; % S_r = double(imread('faceMask.tif'));% vecSCi = SCi(eq(S_r,0));% ZSCi = ZTransSCi(SCi,[mean(vecSCi(:)),std(vecSCi(:))]);% ZSCi = ZSCi.*S_r;% P = .05; % tC = 2.7; % Res = StatThresh(ZSCi,p,sigma_b,tC,S_r);% background = double(imread('w1H.JPG')); % tCi = DiplayRes(Res,background); % % For both tests, DISPLAYCI also returns a table with all relevant statistics (tC, tP, % p, sizes of significant clusters, and so on).%% Requires the ImageProcessing Toolbox.% % See also STATRESH, ZTRANSCI, DEMOSTAT4CI% % The Stat4Ci toolbox is free (http://mapageweb.umontreal.ca/gosselif/stat4ci.html); if you use % it in your research, please, cite us:% Chauvin, A., Worsley, K. J., Schyns, P. G., Arguin, M. & Gosselin, F. (2005). Accurate % statistical tests for smooth classification images.% % Alan Chauvin & FrŽdŽric Gosselin ([email protected]), 01//03/2005% ------------------------------------------------------------% 1. displays cluster result cCi = ( Res.ZSCi >= Res.tC);[LabelClC ,nbClusterC] = BWLABEL(cCi); % labels all clusters in Res.ZSCiif nbClusterC ~=0 for ii = 1 : nbClusterC cm(ii) = length(find(LabelClC == ii)); end; %dbstop at 65 cm = [[1:nbClusterC];cm]; if nbClusterC > 1 %cm = sortrows(cm,2); % sorts clusters per size cm = sortrows(cm',1)'; % sorts clusters per size end; ii = 0;c= 0; while ii < nbClusterC ii = ii + 1; if cm(2,ii) < Res.k LabelClC(find(LabelClC == cm(1,ii))) = 0; else c = c +1; maxZ(c) = max(max(Res.ZSCi(find(LabelClC == cm(1,ii))))); sizeZ(c) = cm(2,ii); [I,J]=find(LabelClC == cm(1,ii)); yZ(c) = round((max(I)+min(I))/2); xZ(c) = round((max(J)+min(J))/2); LabelClC(find(LabelClC == cm(1,ii))) = 1; end; end; for i = 1 : c Results(i,2) = Res.tC; Results(i,3) = sizeZ(i); Results(i,4) = sizeZ(i)/Res.FWHM/Res.FWHM'; Results(i,5) = maxZ(i); Results(i,6) = xZ(i); Results(i,7) = yZ(i); if i == c Results(i,1) = 67; % ascii code for 'C' else Results(i,1) = 32; % ascii code for 'space' end; end; if c, clear maxZ sizeZ yZ xZ;end; if c > 0 Results = flipud(sortrows(Results,3)); fprintf('\n'); fprintf('\tt\t\tsize\tresels\tZmax\tx\ty\n'); fprintf('\t-----------------------------------------\n'); fprintf('%c\t[%.2f]\t%d\t\t%.2f\t%.2f\t%d\t%d\n',Results'); else fprintf('\t-----------------------------------------\n'); fprintf('\tno cluster reach significance\n') end;else fprintf('\t-----------------------------------------\n'); fprintf('\tno cluster reach significance\n')end;% --------------------------------------------------------% 2. displays pixel resultspCi = ( Res.ZSCi >= Res.tP);nbClusterP = ( sum(pCi(:)) >= 1 );if nbClusterP fprintf('\t-----------------------------------------\n'); fprintf('P\t%.2f\t-\t-\t-\t-\t-\n',Res.tP);end;fprintf('\n');fprintf('p-value = [%.2f]\n',Res.p);fprintf('FWHM == [%.1f]\n',Res.FWHM);fprintf('Minimum cluster size = %.1f\n',max(Res.k,0));% --------------------------------------------------------% 3. displays the figureif nbClusterC == 0 & nbClusterP == 0; Res.tCi = zeros(Res>ZSci); return;end;figurefor ii = 1 : 2 if ii == 1 % 3.1 Pixel test t = Res.tP; LabelCl = ones(size(Res.ZSCi)); Res.PixTest = (Res.ZSCi >= t) .* LabelCl; tCi = Res.PixTest; ss = sprintf('Pixel Test'); else % 3.1 Cluster test t = Res.tC; LabelCl = LabelClC; Res.ClusTest = (Res.ZSCi >= t) .* LabelCl; tCi = Res.ClusTest; ss = sprintf('Cluster Test'); end; subplot(1,2,ii) if ~exist('background') image(tCi);axis image;axis off s = sprintf('t = %.2f, pval = %.3f',t,p); title(s) else % thresholded classification image is overlaid on an image background = 2*( ( background-min(background(:)) ) / ( max(background(:))-min(background(:)) ) ) - 1; for ii = 1 : 3 colorIma(:,:,ii) = 2*background; end; mmax = max(Res.ZSCi(:)); mmin = min(Res.ZSCi(:)); cIma = colorIma/2; cIma(:,:,1) = colorIma(:,:,1)/2 + tCi; cIma = ( cIma-min(cIma(:)) ) / ( max(cIma(:))-min(cIma(:))+0.0001 ); tCi = cIma; % figure,imshow(cIma);axis on imagesc(cIma); axis square;colormap(jet);axis off s = sprintf('%s, t = %.2f, pval = %.3f',ss, t,Res.p); title(s) if ii == 1 % 3.1 Pixel test Res.PixTest = cIma; else % 3.1 Cluster test Res.ClusTest = cIma; end; end;end;clear cm