0001 function h = vb_plot_brain(plot_parm)
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 if isfield(plot_parm,'color') & ~isempty(plot_parm.color)
0061 fclr = plot_parm.color;
0062 else
0063 fclr = [0.8 0.8 0.8];
0064 end
0065
0066
0067 [V,F,xx,inf_C,xxA]= vb_load_cortex(plot_parm.brainfile);
0068 V = V .* 1000;
0069
0070 V0 = mean(V);
0071
0072
0073 switch plot_parm.LRflag
0074 case 'L'
0075 F0 = F.F3L;
0076 case 'R'
0077 F0 = F.F3R;
0078 case 'LR'
0079 F0 = F.F3;
0080 end
0081
0082
0083 J = plot_parm.J;
0084 if plot_parm.norm==2
0085 J = J./xxA;
0086 end
0087
0088 if isfield(plot_parm,'cmax')
0089 wmax = plot_parm.cmax;
0090 else
0091 wmax = plot_parm.wmax*max(abs(J(:)));
0092 end
0093 wmin = plot_parm.wmin*max(abs(J(:)));
0094 index = plot_parm.index;
0095
0096
0097
0098
0099
0100
0101 if length(index) == 0
0102 FF = F0;
0103 else
0104 FF = vb_patch_select2(index,F0,size(V,1));
0105 end
0106
0107
0108 h = patch('Faces',FF,'Vertices',V,'FaceColor',fclr,...
0109 'FaceLighting','phong','EdgeColor','none');
0110 material dull;
0111 hold on;
0112
0113 if isfield(plot_parm,'priority') & plot_parm.priority==2
0114 plot_value(plot_parm,V,F0,J,index,wmin,wmax);
0115 plot_area(plot_parm,V,F0,index,V0);
0116 else
0117 plot_area(plot_parm,V,F0,index,V0);
0118 plot_value(plot_parm,V,F0,J,index,wmin,wmax);
0119 end
0120
0121 function plot_area(plot_parm,V,F0,index,V0);
0122
0123
0124
0125 if isfield(plot_parm,'area')
0126 if isempty(index)
0127 tmp = ones(size(V,1),1);
0128 else
0129 tmp = zeros(size(V,1),1);
0130 tmp(index) = 1;
0131 end
0132
0133
0134 if isfield(plot_parm.area,'transparent') & ...
0135 plot_parm.area.transparent
0136 alpha = 0.5;
0137 else
0138 alpha = 1;
0139 end
0140
0141 for i = 1:length(plot_parm.area.key)
0142 Area = vb_get_area(plot_parm.areafile,plot_parm.area.key{i});
0143 ix = Area.Iextract;
0144 ix = ix(:);
0145 ix = ix(find(ix .* tmp(ix)));
0146
0147
0148 Nclr = length(plot_parm.area.clr);
0149 if plot_parm.paint==1
0150 ix2 = intersect(ix,unique(F0(:)));
0151 plot3(V(ix2,1),V(ix2,2),V(ix2,3),'.',...
0152 'MarkerFaceColor',plot_parm.area.clr{1+mod(i-1,Nclr)},...
0153 'MarkerEdgeColor',plot_parm.area.clr{1+mod(i-1,Nclr)},...
0154 'MarkerSize',plot_parm.ms);
0155 else
0156 FF = vb_patch_select2(ix,F0,size(V,1));
0157 patch('Faces',FF,'Vertices',V,...
0158 'FaceColor',plot_parm.area.clr{1+mod(i-1,Nclr)},...
0159 'EdgeColor','none','FaceLighting','none',...
0160 'FaceAlpha',alpha);
0161 end
0162
0163
0164 if isfield(plot_parm.area,'str') & ...
0165 ~isempty(plot_parm.area.str) & length(FF) > 0
0166 pos = median(V(ix,:)) - V0;
0167 [theta,phi,r] = cart2sph(pos(1),pos(2),pos(3));
0168 r = plot_parm.Rlabel * r;
0169
0170 [x,y,z] = sph2cart(theta,phi,r);
0171 x = x + V0(1);
0172 y = y + V0(2);
0173 z = z + V0(3);
0174 pos = pos + V0;
0175 plot3([pos(1) x],[pos(2) y],[pos(3) z]);
0176 h = text(x,y,z,plot_parm.area.str{i},...
0177 'Interpreter','none','FontSize',plot_parm.fs,...
0178 'HorizontalAlignment','center');
0179 end
0180 end
0181 end
0182
0183 function plot_value(plot_parm,V,F0,J,index,wmin,wmax);
0184
0185
0186
0187
0188 if length(J) == 0
0189 return;
0190 end
0191
0192
0193 if length(index) == 0
0194 tmp = ones(length(J),1);
0195 else
0196 tmp = zeros(length(J),1);
0197 tmp(index) = 1;
0198 end
0199
0200
0201 tmp2 = zeros(length(J),1);
0202 tmp2(unique(F0(:))) = 1;
0203
0204 tmp = J.*tmp.*tmp2;
0205 ix = find(abs(tmp) >= wmin);
0206 if plot_parm.wmode==1
0207 J = abs(J);
0208 end
0209
0210
0211 if plot_parm.paint==1
0212 h = scatter3(V(ix,1),V(ix,2),V(ix,3),1,J(ix),'.','filled');
0213 set(h,'MarkerSize',plot_parm.ms);
0214 else
0215 FF = vb_patch_select2(ix,F0,size(V,1));
0216 patch('Faces',FF,'Vertices',V,'FaceColor','interp',...
0217 'FaceVertexCData',J,'EdgeColor','none',...
0218 'FaceLighting','none');
0219 material dull;
0220 end
0221
0222 if plot_parm.wmode==1
0223 caxis([0 wmax]);
0224 else
0225 caxis([-wmax wmax]);
0226 end
0227
0228 if plot_parm.cmap==1
0229 colormap(hot);
0230 else
0231 colormap(jet);
0232 end
0233