Viewer for surface data or P-value or Q-value structures. Usage: [ a, cb ] = SurfStatView( struct, surf [,title [,background] ] ); struct = 1 x v vector of data, v=#vertices, zeros(1,v) if empty, or one of the following structures: P-value structure: struct.P = 1 x v vector of corrected P-values for vertices. struct.C = 1 x v vector of corrected P-values for clusters. struct.mask = 1 x v, 1=inside, 0=outside, v=#vertices. struct.thresh = P-value threshold for plot, 0.05 by default. Q-value structure: struct.Q = 1 x v matrix of Q-values. struct.mask = 1 x v, 1=inside, 0=outside, v=#vertices. struct.thresh = Q-value threshold for plot, 0.05 by default. surf.coord = 3 x v matrix of coordinates. surf.tri = t x 3 matrix of triangle indices, 1-based, t=#triangles. title = any string, data name by default. background = background colour, any matlab ColorSpec, such as 'white' (default), 'black'=='k', 'r'==[1 0 0], [1 0.4 0.6] (pink) etc. Letter and line colours are inverted if background is dark (mean<0.5). a = vector of handles to the axes, left to right, top to bottom. cb = handle to the colorbar. To change the colour limits, use SurfStatColLim( [min, max] ). To change the colour map, use e.g. SurfStatColormap( 'jet' ). Surfaces can be edited in the figure window by clicking e.g. "Rotate 3D". If you want to customize the plot, modify the code in SurfStatViewData.
0001 function [ a, cb ] = SurfStatView( struct, surf, title, background); 0002 0003 %Viewer for surface data or P-value or Q-value structures. 0004 % 0005 % Usage: [ a, cb ] = SurfStatView( struct, surf [,title [,background] ] ); 0006 % 0007 % struct = 1 x v vector of data, v=#vertices, zeros(1,v) if empty, 0008 % or one of the following structures: 0009 % P-value structure: 0010 % struct.P = 1 x v vector of corrected P-values for vertices. 0011 % struct.C = 1 x v vector of corrected P-values for clusters. 0012 % struct.mask = 1 x v, 1=inside, 0=outside, v=#vertices. 0013 % struct.thresh = P-value threshold for plot, 0.05 by default. 0014 % Q-value structure: 0015 % struct.Q = 1 x v matrix of Q-values. 0016 % struct.mask = 1 x v, 1=inside, 0=outside, v=#vertices. 0017 % struct.thresh = Q-value threshold for plot, 0.05 by default. 0018 % surf.coord = 3 x v matrix of coordinates. 0019 % surf.tri = t x 3 matrix of triangle indices, 1-based, t=#triangles. 0020 % title = any string, data name by default. 0021 % background = background colour, any matlab ColorSpec, such as 0022 % 'white' (default), 'black'=='k', 'r'==[1 0 0], [1 0.4 0.6] (pink) etc. 0023 % Letter and line colours are inverted if background is dark (mean<0.5). 0024 % 0025 % a = vector of handles to the axes, left to right, top to bottom. 0026 % cb = handle to the colorbar. 0027 % 0028 % To change the colour limits, use SurfStatColLim( [min, max] ). 0029 % To change the colour map, use e.g. SurfStatColormap( 'jet' ). 0030 % Surfaces can be edited in the figure window by clicking e.g. "Rotate 3D". 0031 % If you want to customize the plot, modify the code in SurfStatViewData. 0032 0033 if nargin<3 | isempty(title) 0034 title=inputname(1); 0035 end 0036 if nargin<4 0037 background='white'; 0038 end 0039 0040 if isempty(struct) 0041 struct=zeros(1,size(surf.coord,2)); 0042 end 0043 0044 if ~isstruct(struct) 0045 [a,cb]=SurfStatViewData(struct,surf,title,background); 0046 else 0047 if isfield(struct,'P') 0048 if ~isfield(struct,'thresh') 0049 struct.thresh=0.05; 0050 end 0051 0052 signifpeak=struct.P<struct.thresh; 0053 if isfield(struct,'C') 0054 signifclus=struct.C<struct.thresh; 0055 t1=signifclus.*(1-signifpeak).*(127-struct.C/struct.thresh*126); 0056 else 0057 signifclus=0; 0058 t1=0; 0059 end 0060 t2=signifpeak.*(255-struct.P/struct.thresh*126); 0061 t3=(1-signifpeak).*(1-signifclus)*128; 0062 tt=(t1+t2+t3).*struct.mask*struct.thresh; 0063 0064 [a,cb]=SurfStatViewData(tt,surf,title,background); 0065 cm=[zeros(1,3); 0066 zeros(127,1) (0:126)'/127 ones(127,1); ones(1,3)*0.8; 0067 ones(127,1) (0:126)'/127 zeros(127,1)]; 0068 SurfStatColormap(cm); 0069 cb = SurfStatColLim( [0 255]*struct.thresh ); 0070 0071 set(cb,'XLim',[0 255]*struct.thresh); 0072 h=get(cb,'Children'); 0073 set(h,'XData',[0 255]*struct.thresh); 0074 set(cb,'XTick',[1 64 127 129 192 255]*struct.thresh); 0075 pstr1=num2str(round(struct.thresh*1000)/1000); 0076 pstr2=num2str(round(struct.thresh*1000/2)/1000); 0077 set(cb,'XTickLabel',strvcat([' ' pstr1],[' ' pstr2],... 0078 ' ',[' 0 ' pstr1],[' ' pstr2],' 0')); 0079 xl=get(cb,'XLabel'); 0080 set(xl,'String','P Cluster P Vertex'); 0081 dcm_obj=datacursormode(gcf); 0082 set(dcm_obj,'UpdateFcn',@SurfStatDataCursorP,'DisplayStyle','window'); 0083 end 0084 if isfield(struct,'Q') 0085 if ~isfield(struct,'thresh') 0086 struct.thresh=0.05; 0087 end 0088 0089 t1=(struct.Q<struct.thresh).*(255-struct.Q/struct.thresh*253); 0090 t2=(struct.Q>=struct.thresh); 0091 tt=(t1+t2).*struct.mask*struct.thresh; 0092 0093 [a,cb]=SurfStatViewData(tt,surf,title,background); 0094 cm=[zeros(1,3); ones(1,3)*0.8; ones(254,1) (0:253)'/254 zeros(254,1)]; 0095 SurfStatColormap(cm); 0096 cb = SurfStatColLim( [0 255]*struct.thresh ); 0097 0098 set(cb,'XLim',[0 255]*struct.thresh); 0099 h=get(cb,'Children'); 0100 set(h,'XData',[0 255]*struct.thresh); 0101 set(cb,'XTick',(2+(0:5)/5*253)*struct.thresh); 0102 set(cb,'XTickLabel',num2str(struct.thresh*(5:-1:0)'/5)); 0103 xl=get(cb,'XLabel'); 0104 set(xl,'String','Q'); 0105 dcm_obj=datacursormode(gcf); 0106 set(dcm_obj,'UpdateFcn',@SurfStatDataCursorQ,'DisplayStyle','window'); 0107 end 0108 end 0109 0110 return 0111 end