Home > vbmeg > functions > tool_box > dynamics_movie > test_fig > basic_tool > plot_cylinder_prepare.m

plot_cylinder_prepare

PURPOSE ^

--- path coordinate for n-th connection

SYNOPSIS ^

function [hfig, Q, id] = plot_cylinder_prepare(dc, p)

DESCRIPTION ^

 --- path coordinate for n-th connection
  dc.Vc{n} : vertex coordinates along n-th connection path 
 --- pair of vetex index for n-th connection
  dc.I_from(n)   : start vertex index
  dc.I_to(n)     : end vertex index
  p : Plot parameter 

 2014-11-10 Masa-aki Sato
 2017-12-12 Yusuke Takeda Modified details

 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:

SOURCE CODE ^

0001 function    [hfig, Q, id] = plot_cylinder_prepare(dc, p)
0002 % --- path coordinate for n-th connection
0003 %  dc.Vc{n} : vertex coordinates along n-th connection path
0004 % --- pair of vetex index for n-th connection
0005 %  dc.I_from(n)   : start vertex index
0006 %  dc.I_to(n)     : end vertex index
0007 %  p : Plot parameter
0008 %
0009 % 2014-11-10 Masa-aki Sato
0010 % 2017-12-12 Yusuke Takeda Modified details
0011 %
0012 % Copyright (C) 2011, ATR All Rights Reserved.
0013 % License : New BSD License(see VBMEG_LICENSE.txt)
0014 
0015 load(which('disp_brain.mat')); %
0016 d = Data_area;
0017 
0018 % figure handle
0019 hfig = [];
0020 
0021 % reduce points for connection path
0022 [X,id] = reduce_connection(dc, p);
0023 
0024 % number of connections to show
0025 NL = length(X);
0026 
0027 %----- Make cylindrical vertex and patches for each connection pair
0028 V = cell(NL,1);% vertex coordinate for cylindrical lines
0029 F = cell(NL,1);% patch index for cylindrical lines
0030 Q = cell(NL,1);% ring buffer for temporal histry
0031 
0032 hfig.hp = zeros(NL,1);% figure handle
0033 
0034 for n=1:NL
0035     % Make cylindrical vertex and patches for n-th connection
0036     [V{n},F{n},X{n}] = make_cylinder( X{n} ,p.dN,p.dr);
0037     
0038     % activity history ring buffer
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 %----- plot brain
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 %----- lighting
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 %----- plot face
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 %----- plot brain area
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 %        lighting phong;
0105 %        material dull;
0106     end
0107     alpha(hfig.h_area, p.alpha_area(1));
0108 end
0109 
0110 %----- plot cylindrical lines
0111 t = 1; r0 = 0.01;
0112 for n=1:NL
0113     % set values for n-th cylinder
0114     [J, Q{n}] = set_cylinder_val(Q{n},[],t,p.dN);
0115     
0116     % set start-end vertex
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     % plot cylindrical lines
0121     hfig.hp(n) = patch('Faces',F{n},'Vertices',V{n},'FaceColor','interp',...
0122       'FaceVertexCData',J,'EdgeColor','none',...
0123       'FaceLighting','none');
0124     
0125     %material shiny;%metal;dull
0126 end
0127 
0128 %alpha(hfig.hf, p.alpha)
0129 
0130 axis equal
0131 axis tight
0132 
0133 % erase axis
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 % time
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 % save figure
0153 hfig.key  = d.key;
0154 hfig.cmap = d.cmap;
0155 guidata(hfig.hfig, hfig);

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005