Home > functions > plotfunc > vb_plot_brain_inflate_new.m

vb_plot_brain_inflate_new

PURPOSE ^

Plot inflated brain model with activity

SYNOPSIS ^

function vb_plot_brain_inflate_new(V,F,inf_C,plot_parm,xxP,ix,area_key,area_color,priority,ix_display)

DESCRIPTION ^

 Plot inflated brain model with activity 
 
 --- Syntax
 function vb_plot_brain_inflate_new(V,F,inf_C,plot_parm,xxP,ix,...
                                 area_key,area_color,priority,...
                                 ix_display)

 --- Input
 V, F, inf_C: Inflated brain model
 plot_parm  : Plotting parameters

 --- Optional Input
 xxP        : Activity map (length(xxP)==size(V,1))
 ix         : Area data (set of vertices), cell array
 area_key   : Key of areas (length(ix)==length(area_key))
 area_color : Color of areas (length(ix)==length(area_color))
 priority   : 'activity' or 'area'
 
 2007-02-16 Taku Yoshioka

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function vb_plot_brain_inflate_new(V,F,inf_C,plot_parm,xxP,ix,...
0002                 area_key,area_color,priority,...
0003                 ix_display)
0004 % Plot inflated brain model with activity
0005 %
0006 % --- Syntax
0007 % function vb_plot_brain_inflate_new(V,F,inf_C,plot_parm,xxP,ix,...
0008 %                                 area_key,area_color,priority,...
0009 %                                 ix_display)
0010 %
0011 % --- Input
0012 % V, F, inf_C: Inflated brain model
0013 % plot_parm  : Plotting parameters
0014 %
0015 % --- Optional Input
0016 % xxP        : Activity map (length(xxP)==size(V,1))
0017 % ix         : Area data (set of vertices), cell array
0018 % area_key   : Key of areas (length(ix)==length(area_key))
0019 % area_color : Color of areas (length(ix)==length(area_color))
0020 % priority   : 'activity' or 'area'
0021 %
0022 % 2007-02-16 Taku Yoshioka
0023 %
0024 % Copyright (C) 2011, ATR All Rights Reserved.
0025 % License : New BSD License(see VBMEG_LICENSE.txt)
0026 
0027 % Set default parameters
0028 if nargin<10, ix_display = []; end
0029 if nargin<9 | isempty(priority), priority='activity'; end
0030 if nargin<8 | isempty(area_color), area_color={'r','g','b'}; end
0031 if nargin<7, area_key = []; end
0032 if nargin<6, ix = []; end
0033 if nargin<5, xxP=[]; end
0034 
0035 % Left/Right/Both hemisphere to be displayed
0036 switch plot_parm.LRflag
0037  case 'LR',
0038   F3 = F.F3;
0039  case 'L',
0040   F3 = F.F3L;
0041  case 'R',
0042   F3 = F.F3R;
0043 end
0044 
0045 %
0046 % Display inflated model
0047 %
0048 
0049 % Select display patches
0050 if length(ix_display) == 0
0051   FF = F3;
0052 else
0053   FF = vb_patch_select2(index,F3,size(V,1));  
0054 end
0055 
0056 % Color of inflated model
0057 cscale = -0.4;
0058 c0 = 0.8;
0059 if ~isfield(plot_parm,'color') | isempty(plot_parm.color)
0060   plot_parm.color = [0.8 0.8 0.8];
0061 end
0062 
0063 % Display surface
0064 colors = [plot_parm.color(1)*inf_C ...
0065       plot_parm.color(2)*inf_C ...
0066       plot_parm.color(3)*inf_C] * cscale ...
0067      + repmat(plot_parm.color,[length(inf_C) 1]);
0068 patch('Faces',FF,'Vertices',V,'FaceColor','interp',...
0069       'EdgeColor','none','FaceVertexCData',colors);
0070 material dull;
0071 hold on;
0072 
0073 % Plot activity and/or area information
0074 if strcmp(priority,'activity'), 
0075   plot_area(plot_parm,V,F3,ix_display,mean(V),ix,area_key, ...
0076         area_color);
0077   plot_value(plot_parm,V,F3,xxP,ix_display);
0078 else
0079   plot_area(plot_parm,V,F3,ix_display,mean(V),ix,area_key, ...
0080         area_color);
0081   plot_area(plot_parm,V,F3,ix_display,mean(V));
0082 end
0083 
0084 function plot_area(plot_parm,V,F3,ix_display,V0,ix,area_key, ...
0085            area_color)
0086 
0087 if isempty(ix), return; 
0088 elseif ~iscell(ix), ix = {ix}; end
0089 
0090 % Restrict area to be displayed
0091 if isempty(ix_display)
0092   tmp = ones(size(V,1),1);
0093 else
0094   tmp = zeros(size(V,1),1);
0095   tmp(ix_display) = 1;
0096 end
0097 
0098 % Transparent parameter
0099 alpha = 0.5;
0100 
0101 %
0102 % Plot areas
0103 %
0104 Nclr = length(area_color);
0105 for i = 1:length(ix)
0106   ixx = ix{i};
0107   ixx = ixx(find(ixx.*tmp(ixx))); 
0108     
0109   % Color of area
0110   clr = area_color{1+mod(i-1,Nclr)};
0111   
0112   % Plot area
0113   if plot_parm.paint==ON % Plot as points
0114     ix2 = intersect(ix,unique(F3(:)));
0115     tmp = length(ix2);
0116     plot3(V(ix2,1),V(ix2,2),V(ix2,3),'.',...
0117       'MarkerFaceColor',clr,'MarkerEdgeColor',clr,...
0118       'MarkerSize',plot_parm.ms);
0119 
0120   else                  % Paint
0121     FF = vb_patch_select2(ix,F3,size(V,1));
0122     tmp = size(FF,1);
0123     patch('Faces',FF,'Vertices',V,'FaceColor',clr,...
0124       'EdgeColor','none','FaceLighting','none',...
0125       'FaceAlpha',alpha);
0126   end
0127   
0128   % Plot key
0129   if ~isempty(area_key) & tmp>0, 
0130     pos = median(V(ix{i},:)) - V0;
0131     [theta,phi,r] = cart2sph(pos(1),pos(2),pos(3));
0132     r = r*1.1;
0133     [x,y,z] = sph2cart(theta,phi,r);
0134     x = x + V0(1);
0135     y = y + V0(2);
0136     z = z + V0(3);
0137     pos = pos + V0;
0138     plot3([pos(1) x],[pos(2) y],[pos(3) z]);
0139     h = text(x,y,z,plot_parm.area_key{i},...
0140          'Interpreter','none','FontSize',plot_parm.fs,...
0141          'HorizontalAlignment','center');
0142   end
0143 end
0144 
0145 function plot_value(plot_parm,V,F3,xxP,ix_display)
0146 
0147 if length(xxP)==0 | max(xxP)==0, return; end
0148 
0149 % Maximum and minimum of activity
0150 wmin = max(xxP)*plot_parm.wmin;
0151 wmax = max(xxP)*plot_parm.wmax;
0152 
0153 % Restrict area to be displayed
0154 if length(ix_display) == 0
0155   tmp = ones(length(xxP),1);
0156 else
0157   tmp = zeros(length(xxP),1);
0158   tmp(index) = 1;
0159 end
0160 
0161 tmp2 = zeros(length(xxP),1);
0162 tmp2(unique(F3(:))) = 1;
0163 ix = find(tmp.*tmp2);
0164 
0165 if plot_parm.wmode==1, 
0166   xxP = abs(xxP);
0167   ix = intersect(ix,find(xxP>=wmin));
0168 end
0169 
0170 % Plot activity map
0171 if plot_parm.paint==OFF
0172   h = scatter3(V(ix,1),V(ix,2),V(ix,3),1,xxP(ix),'.','filled');
0173   set(h,'MarkerSize',plot_parm.ms);
0174 else
0175   FF = vb_patch_select2(ix,F3,size(V,1));
0176   patch('Faces',FF,'Vertices',V,'FaceColor','interp',...
0177     'FaceVertexCData',xxP,'EdgeColor','none',...
0178     'FaceLighting','none');
0179   material dull;
0180 end
0181 
0182 if plot_parm.wmode==1, caxis([0 wmax]);
0183 else caxis([-wmax wmax]); end
0184   
0185 if strcmp(plot_parm.cmap,'jet') | plot_parm.cmap==2, colormap(jet);
0186 else colormap(hot); end
0187

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005