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