0001 function [hfig, Q, id] = plot_cylinder_prepare(dc, p)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 load(which('disp_brain.mat'));
0016 d = Data_area;
0017
0018
0019 hfig = [];
0020
0021
0022 [X,id] = reduce_connection(dc, p);
0023
0024
0025 NL = length(X);
0026
0027
0028 V = cell(NL,1);
0029 F = cell(NL,1);
0030 Q = cell(NL,1);
0031
0032 hfig.hp = zeros(NL,1);
0033
0034 for n=1:NL
0035
0036 [V{n},F{n},X{n}] = make_cylinder( X{n} ,p.dN,p.dr);
0037
0038
0039 Q{n} = zeros(size(X{n},1),1);
0040 end
0041
0042 if p.mbox == 1
0043 hfig.h = msgbox('Cancel: Press OK button');
0044 set(hfig.h, 'DeleteFcn', 'global cancel; cancel = true;');
0045 end
0046
0047 global cancel;
0048 cancel = false;
0049
0050 hfig.hfig = figure('Color', 'k', 'Unit', p.fig_unit, 'Position', p.fig_pos);
0051
0052 eclr = 'none';
0053
0054 colormap(p.cmap);
0055
0056
0057 NFV = vb_reducepatch(d.F0, d.V0, 3000);
0058
0059 hfig.hf = patch('Faces',NFV.faces,'Vertices',NFV.vertices, ...
0060 'FaceColor',p.faceclr,'EdgeColor',eclr);
0061 set(gca, 'Color', 'k');
0062 hold on
0063 alpha(hfig.hf, p.alpha(1));
0064
0065
0066 lighting phong;
0067 material dull;
0068
0069 camlight(-60,0);
0070 camlight(60,0);
0071 camlight(180,0);
0072
0073 Nkey = length(d.V);
0074
0075
0076 if p.face_on
0077 if exist(p.face_file, 'file') ~= 2
0078 warning('Specified facefile not found.');
0079 else
0080 load(p.face_file, 'surf_face');
0081 NFV = vb_reducepatch(surf_face.F, surf_face.V*1000, 40000);
0082 white = rgb_val_get('white');
0083 h_face = patch('Faces', NFV.faces, 'Vertices', NFV.vertices, ...
0084 'FaceColor', white, 'EdgeColor', eclr);
0085 lighting phong;
0086 material dull;
0087 set(h_face, 'SpecularStrength', 0, 'AmbientStrength', 1.0);
0088 alpha(h_face, p.alpha_face);
0089 hfig.h_face = h_face;
0090 end
0091 end
0092
0093
0094 hfig.h_area = zeros(1,Nkey);
0095
0096 if p.roi==1
0097 for n = 1:Nkey;
0098 fclr = d.cmap(n,:);
0099 if iscell(fclr), fclr = rgb_val_get(char(fclr)); end
0100 NFV = vb_reducepatch(d.F{n}, d.V{n}, 500);
0101
0102 hfig.h_area(n) = patch('Faces',NFV.faces,'Vertices',NFV.vertices, ...
0103 'FaceColor',fclr,'EdgeColor',eclr);
0104
0105
0106 end
0107 alpha(hfig.h_area, p.alpha_area(1));
0108 end
0109
0110
0111 t = 1; r0 = 0.01;
0112 for n=1:NL
0113
0114 [J, Q{n}] = set_cylinder_val(Q{n},[],t,p.dN);
0115
0116
0117 hfig.hp1(n) = plot3(X{n}(1,1),X{n}(1,2),X{n}(1,3),'.','MarkerSize',r0);
0118 hfig.hp2(n) = plot3(X{n}(end,1),X{n}(end,2),X{n}(end,3),'.','MarkerSize',r0);
0119
0120
0121 hfig.hp(n) = patch('Faces',F{n},'Vertices',V{n},'FaceColor','interp',...
0122 'FaceVertexCData',J,'EdgeColor','none',...
0123 'FaceLighting','none');
0124
0125
0126 end
0127
0128
0129
0130 axis equal
0131 axis tight
0132
0133
0134 set(gca,'XTick', [])
0135 set(gca,'YTick', [])
0136 set(gca,'ZTick', [])
0137
0138 set(gca,'XColor', 'k')
0139 set(gca,'YColor', 'k')
0140 set(gca,'ZColor', 'k')
0141
0142 angle = p.angle;
0143 view(angle);
0144
0145
0146 current_axes = gca;
0147 hfig.ax_time = axes;
0148 set(hfig.ax_time, 'Position', [0.52, 0.1, 0.001, 0.001], ...
0149 'Units', 'normalized', 'Color', 'k');
0150 set(hfig.hfig, 'CurrentAxes', current_axes);
0151
0152
0153 hfig.key = d.key;
0154 hfig.cmap = d.cmap;
0155 guidata(hfig.hfig, hfig);