Home > SurfStat > SurfStatViewData.m

SurfStatViewData

PURPOSE ^

Basic viewer for surface data.

SYNOPSIS ^

function [ a, cb ] = SurfStatViewData( data, surf, title, background );

DESCRIPTION ^

Basic viewer for surface data.
 
 Usage: [ a, cb ] = SurfStatViewData( data, surf [,title [,background]] );
 
 data        = 1 x v vector of data, v=#vertices
 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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ a, cb ] = SurfStatViewData( data, surf, title, background );
0002 
0003 %Basic viewer for surface data.
0004 %
0005 % Usage: [ a, cb ] = SurfStatViewData( data, surf [,title [,background]] );
0006 %
0007 % data        = 1 x v vector of data, v=#vertices
0008 % surf.coord  = 3 x v matrix of coordinates.
0009 % surf.tri    = t x 3 matrix of triangle indices, 1-based, t=#triangles.
0010 % title       = any string, data name by default.
0011 % background  = background colour, any matlab ColorSpec, such as
0012 %   'white' (default), 'black'=='k', 'r'==[1 0 0], [1 0.4 0.6] (pink) etc.
0013 %   Letter and line colours are inverted if background is dark (mean<0.5).
0014 %
0015 % a  = vector of handles to the axes, left to right, top to bottom.
0016 % cb = handle to the colorbar.
0017 
0018 if nargin<3 
0019     title=inputname(1);
0020 end
0021 if nargin<4
0022     background='white';
0023 end
0024 
0025 % find cut between hemispheres, assuming they are concatenated
0026 t=size(surf.tri,1);
0027 v=size(surf.coord,2);
0028 tmax=max(surf.tri,[],2);
0029 tmin=min(surf.tri,[],2);
0030 % to save time, check that the cut is half way
0031 if min(tmin(t/2+1:t))-max(tmax(1:t/2))==1
0032     cut=t/2;
0033     cuv=v/2;
0034 else % check all cuts
0035     for i=1:t-1
0036         tmax(i+1)=max(tmax(i+1),tmax(i));
0037         tmin(t-i)=min(tmin(t-i),tmin(t-i+1));
0038     end
0039     cut=min([find((tmin(2:t)-tmax(1:t-1))==1) t]);
0040     cuv=tmax(cut);
0041 end
0042 tl=1:cut;
0043 tr=(cut+1):t;
0044 vl=1:cuv;
0045 vr=(cuv+1):v;
0046 
0047 clim=[min(data),max(data)];
0048 if clim(1)==clim(2)
0049     clim=clim(1)+[-1 0];
0050 end
0051 
0052 clf;
0053 colormap(spectral(256));
0054 
0055 h=0.39;
0056 w=0.4;
0057 
0058 r=max(surf.coord,[],2)-min(surf.coord,[],2);
0059 w1=h/r(2)*r(1)*3/4;
0060 h1=h/r(2)*r(1); % h/r(2)*r(3)
0061 
0062 a(1)=axes('position',[0.055 0.62 h*3/4 w]);
0063 trisurf(surf.tri(tl,:),surf.coord(1,vl),surf.coord(2,vl),surf.coord(3,vl),...
0064     double(data(vl)),'EdgeColor','none');
0065 view(-90,0); 
0066 daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0067 lighting phong; material shiny; shading interp;
0068 
0069 a(2)=axes('position',[0.3 0.58 w h]);
0070 trisurf(surf.tri,surf.coord(1,:),surf.coord(2,:),surf.coord(3,:),...
0071     double(data),'EdgeColor','none');
0072 view(0,90); 
0073 daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0074 lighting phong; material shiny; shading interp;
0075 
0076 if cut<t
0077     a(3)=axes('position',[1-0.055-h*3/4 0.62 h*3/4 w]);
0078     trisurf(surf.tri(tr,:)-cuv,surf.coord(1,vr),surf.coord(2,vr),surf.coord(3,vr),...
0079         double(data(vr)),'EdgeColor','none');
0080     view(90,0);
0081     daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0082     lighting phong; material shiny; shading interp;
0083 else
0084     a(3)=axes('position',[1-0.055-h*3/4 0.62 h/r(2)*r(1)*3/4 w]);
0085     trisurf(surf.tri,surf.coord(1,:),surf.coord(2,:),surf.coord(3,:),...
0086         double(data),'EdgeColor','none');
0087     view(180,0);
0088     daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0089     lighting phong; material shiny; shading interp;
0090 end
0091 
0092 a(4)=axes('position',[0.055 0.29 h*3/4 w]);
0093 trisurf(surf.tri(tl,:),surf.coord(1,vl),surf.coord(2,vl),surf.coord(3,vl),...
0094     double(data(vl)),'EdgeColor','none');
0095 view(90,0); 
0096 daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0097 lighting phong; material shiny; shading interp;
0098 
0099 a(5)=axes('position',[0.3 0.18 w h]);
0100 trisurf(surf.tri,surf.coord(1,:),surf.coord(2,:),surf.coord(3,:),...
0101     double(data),'EdgeColor','none');
0102 view(0,-90); 
0103 daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0104 lighting phong; material shiny; shading interp;
0105 
0106 if cut<t
0107     a(6)=axes('position',[1-0.055-h*3/4 0.29 h*3/4 w]);
0108     trisurf(surf.tri(tr,:)-cuv,surf.coord(1,vr),surf.coord(2,vr),surf.coord(3,vr),...
0109         double(data(vr)),'EdgeColor','none');
0110     view(-90,0);
0111     daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0112     lighting phong; material shiny; shading interp;
0113 
0114     a(7)=axes('position',[0.055 0.02 w1 h1]);
0115     trisurf(surf.tri,surf.coord(1,:),surf.coord(2,:),surf.coord(3,:),...
0116         double(data),'EdgeColor','none');
0117     view(180,0);
0118     daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0119     lighting phong; material shiny; shading interp;
0120 
0121     a(8)=axes('position',[1-0.055-w1 0.03 w1 h1]);
0122     trisurf(surf.tri,surf.coord(1,:),surf.coord(2,:),surf.coord(3,:),...
0123         double(data),'EdgeColor','none');
0124     view(0,0);
0125     daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0126     lighting phong; material shiny; shading interp;
0127 else
0128     a(6)=axes('position',[1-0.055-h*3/4 0.29 h/r(2)*r(1)*3/4 w]);
0129     trisurf(surf.tri,surf.coord(1,:),surf.coord(2,:),surf.coord(3,:),...
0130         double(data),'EdgeColor','none');
0131     view(0,0);
0132     daspect([1 1 1]); axis tight; camlight; axis vis3d off;
0133     lighting phong; material shiny; shading interp;
0134 end    
0135     
0136 id0=[0 0 cuv 0 0 cuv 0 0];
0137 for i=1:length(a)
0138     set(a(i),'CLim',clim);
0139     set(a(i),'Tag',['SurfStatView ' num2str(i) ' ' num2str(id0(i))]);
0140 end
0141 
0142 cb=colorbar('location','South');
0143 set(cb,'Position',[0.35 0.085 0.3 0.03]);
0144 set(cb,'XAxisLocation','bottom');
0145 h=get(cb,'Title');
0146 set(h,'String',title);
0147 
0148 whitebg(gcf,background);
0149 set(gcf,'Color',background,'InvertHardcopy','off');
0150 
0151 dcm_obj=datacursormode(gcf);
0152 set(dcm_obj,'UpdateFcn',@SurfStatDataCursor,'DisplayStyle','window');
0153 
0154 set(gcf,'PaperPosition',[0.25 2.5 6 4.5]);
0155 
0156 return
0157 end

Generated on Fri 26-Sep-2008 14:05:29 by m2html © 2003