0001 function h = vb_plot_cortex(plot_parm,V,F,inf_C,J,Jmin,Jmax,ix_area)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 if nargin<8, ix_area = []; end
0071 if nargin<5,
0072 J = [];
0073 Jmin = [];
0074 Jmax = [];
0075 else
0076 if nargin<7, Jmax = max(abs(J)); end
0077 if nargin<6, Jmin = max(abs(J))*0.1; end
0078 end
0079 if nargin<4, inf_C = []; end;
0080
0081 if isfield(plot_parm,'color') & ~isempty(plot_parm.color)
0082 fclr = plot_parm.color;
0083 else
0084 fclr = [0.8 0.8 0.8];
0085 end
0086
0087 if ~isfield(plot_parm,'isact'),
0088 plot_parm.isact = true;
0089 end
0090
0091
0092
0093
0094
0095 switch plot_parm.LRflag
0096 case 'L'
0097 F0 = F.F3L;
0098 case 'R'
0099 F0 = F.F3R;
0100 case 'LR'
0101 F0 = F.F3;
0102 end
0103
0104
0105
0106
0107
0108 if ~isfield(plot_parm,'index'), index = [];
0109 else index = plot_parm.index; end
0110 if length(index) == 0, FF = F0;
0111 else FF = vb_patch_select2(index,F0,size(V,1)); end
0112
0113
0114
0115
0116
0117 h = gcf;
0118 set(h, 'renderer', 'zbuffer');
0119 if isempty(inf_C)
0120
0121 patch('Faces',FF,'Vertices',V,'FaceColor',fclr, ...
0122 'FaceLighting','phong','EdgeColor','none', ...
0123 'FaceAlpha',0.99);
0124
0125
0126 h = camlight('headlight');
0127 else
0128 c = repmat(fclr,[length(inf_C) 1]) ...
0129 -0.4*[fclr(1)*inf_C fclr(2)*inf_C fclr(3)*inf_C];
0130 patch('Faces',FF,'Vertices',V,'FaceColor','interp',...
0131 'EdgeColor','none','FaceVertexCData',c, ...
0132 'FaceAlpha',0.99);
0133 h = [];
0134 end
0135
0136 material dull;
0137 hold on;
0138
0139
0140
0141
0142
0143 if plot_parm.isact & ~isempty(J),
0144 plot_value(plot_parm,V,F0,J,index,Jmin,Jmax);
0145 end
0146
0147
0148
0149
0150
0151 if ~isempty(ix_area),
0152 if ~isempty(index), ix_area = intersect(index,ix_area); end
0153 FF = vb_patch_select2(ix_area,F0,size(V,1));
0154 patch('Faces',FF,'Vertices',V,'FaceColor','b',...
0155 'EdgeColor','none','EraseMode','xor', ...
0156 'FaceAlpha',0.99);
0157 end
0158
0159 plot_area(plot_parm,V,F0);
0160
0161 return;
0162
0163
0164
0165
0166
0167 function plot_value(plot_parm,V,F0,J,index,wmin,wmax);
0168
0169 if length(J) == 0
0170 return;
0171 end
0172
0173
0174 if length(index) == 0
0175 tmp = ones(length(J),1);
0176 else
0177 tmp = zeros(length(J),1);
0178 tmp(index) = 1;
0179 end
0180
0181
0182 tmp2 = zeros(length(J),1);
0183 tmp2(unique(F0(:))) = 1;
0184
0185 tmp = J.*tmp.*tmp2;
0186 ix = find(abs(tmp) >= wmin);
0187 if plot_parm.wmode==1
0188 J = abs(J);
0189 end
0190
0191
0192 if plot_parm.paint==1
0193 h = scatter3(V(ix,1),V(ix,2),V(ix,3),1,J(ix),'.','filled');
0194 set(h,'MarkerSize',plot_parm.ms);
0195 else
0196 FF = vb_patch_select2(ix,F0,size(V,1));
0197 if ~isempty(FF),
0198 patch('Faces',FF,'Vertices',V,'FaceColor','interp',...
0199 'FaceVertexCData',J,'EdgeColor','none',...
0200 'FaceLighting','none','FaceAlpha',0.99);
0201 material dull;
0202 end
0203 end
0204
0205 if plot_parm.wmode==1
0206 caxis([0 wmax]);
0207 else
0208 caxis([-wmax wmax]);
0209 end
0210
0211 if plot_parm.cmap==1
0212 colormap(hot);
0213 else
0214 colormap(jet);
0215 end
0216
0217 return;
0218
0219
0220
0221
0222
0223 function plot_area(plot_parm,V,F0);
0224
0225 if isfield(plot_parm,'area'),
0226 if ~isfield(plot_parm,'index') | isempty(plot_parm.index),
0227 tmp = ones(size(V,1),1);
0228 else
0229 tmp = zeros(size(V,1),1);
0230 tmp(plot_parm.index) = 1;
0231 end
0232
0233
0234 if isfield(plot_parm,'Rlabel'),
0235 plot_parm.area.Rlabel = plot_parm.Rlabel;
0236 elseif ~isfield(plot_parm.area,'Rlabel'),
0237 plot_parm.area.Rlabel = 1;
0238 end
0239
0240 if isfield(plot_parm,'areafile'),
0241 plot_parm.area.area_file = plot_parm.areafile;
0242 end
0243
0244
0245 if isfield(plot_parm.area,'transparent') & plot_parm.area.transparent,
0246 alpha = 0.5;
0247 else
0248 alpha = 1.0;
0249 end
0250
0251
0252 area_file = plot_parm.area.area_file;
0253 for i = 1:length(plot_parm.area.key)
0254 Area = vb_get_area(area_file,plot_parm.area.key{i});
0255 if isfield(Area,'clr'),
0256 clr = Area.clr;
0257 if max(clr)>1 | min(clr)<0,
0258 vb_disp(['Invalid color value of cortical region. area.clr must ' ...
0259 'be in range [0 1], where area = vb_get_area(area_file,' ...
0260 'area_key). Normalized in ' ...
0261 'vb_plot_cortex.']);
0262 clr = abs(clr)./max(abs(clr));
0263 end
0264 else
0265 Nclr = length(plot_parm.area.clr);
0266 clr = plot_parm.area.clr{1+mod(i-1,Nclr)};
0267 end
0268 ix = Area.Iextract;
0269 ix = ix(:);
0270 ix = ix(find(ix.*tmp(ix)));
0271
0272
0273 if plot_parm.paint==1
0274 ix2 = intersect(ix,unique(F0(:)));
0275 plot3(V(ix2,1),V(ix2,2),V(ix2,3),'.',...
0276 'MarkerFaceColor',clr,'MarkerEdgeColor',clr, ...
0277 'MarkerSize',plot_parm.ms);
0278 else
0279 FF = vb_patch_select2(ix,F0,size(V,1));
0280 patch('Faces',FF,'Vertices',V,...
0281 'FaceColor',clr,'EdgeColor','none', ...
0282 'FaceLighting','gouraud','FaceAlpha',alpha);
0283 end
0284
0285
0286 if isfield(plot_parm.area,'str') & ...
0287 ~isempty(plot_parm.area.str) & length(FF) > 0,
0288 V0 = mean(V);
0289 pos = median(V(ix,:))-V0;
0290 [theta,phi,r] = cart2sph(pos(1),pos(2),pos(3));
0291 r = plot_parm.area.Rlabel*r;
0292
0293 [x,y,z] = sph2cart(theta,phi,r);
0294 x = x+V0(1);
0295 y = y+V0(2);
0296 z = z+V0(3);
0297 pos = pos+V0;
0298 plot3([pos(1) x],[pos(2) y],[pos(3) z]);
0299 h = text(x,y,z,plot_parm.area.str{i},...
0300 'Interpreter','none','FontSize',plot_parm.fs,...
0301 'HorizontalAlignment','center');
0302 end
0303 end
0304 end
0305
0306 return;