plot channel data value on face h = plot_map_on_face(parm,facefile,ch_val,plot_parm) parm : pair channel structure source: {1xNsrc cell} detector: {1xNdet cell} probe_pair: [Npairx2 double] src_pos: [Nsrcx3 double] det_pos: [Ndetx3 double] facefile ch_val : channel data value [Npairx1 double] plot_parm : plot_parm.Msend = 'r.'; plot_parm.Mrecv = 'b.'; plot_parm.Msize = 20; plot_parm.mode = 0 : Smooth interpolation using 3 neighbor [default] = 1 : Binary mode (No pactch reduction & nearest neighbor interpolation) 2015-7-1 Masa-aki Sato Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function h = plot_map_on_face(parm,facefile,ch_val,p) 0002 % plot channel data value on face 0003 % h = plot_map_on_face(parm,facefile,ch_val,plot_parm) 0004 % parm : pair channel structure 0005 % source: {1xNsrc cell} 0006 % detector: {1xNdet cell} 0007 % probe_pair: [Npairx2 double] 0008 % src_pos: [Nsrcx3 double] 0009 % det_pos: [Ndetx3 double] 0010 % facefile 0011 % ch_val : channel data value [Npairx1 double] 0012 % plot_parm : 0013 % plot_parm.Msend = 'r.'; 0014 % plot_parm.Mrecv = 'b.'; 0015 % plot_parm.Msize = 20; 0016 % plot_parm.mode 0017 % = 0 : Smooth interpolation using 3 neighbor [default] 0018 % = 1 : Binary mode (No pactch reduction & nearest neighbor interpolation) 0019 % 0020 % 2015-7-1 Masa-aki Sato 0021 % 0022 % Copyright (C) 2011, ATR All Rights Reserved. 0023 % License : New BSD License(see VBMEG_LICENSE.txt) 0024 0025 % Reduced number of patch in face surface 0026 Npatch=10000; 0027 0028 if ~isfield(p,'mode'), p.mode=0; end 0029 0030 % Face surface 0031 face = load(facefile); 0032 V = face.Vspm; 0033 F = face.F; 0034 0035 if p.mode == 0 0036 [F,V] = vb_reducepatch(F,V, Npatch); 0037 end 0038 0039 Nv = size(V,1); 0040 0041 % get_shortest_path from source to detector along head 0042 [Xpath, Npath] = get_shortest_path(parm, facefile); 0043 0044 % source & detector channel pos 0045 Npair = length(Npath); 0046 0047 src_pos = zeros(Npair,3); 0048 det_pos = zeros(Npair,3); 0049 ch_pos = zeros(Npair,3); 0050 0051 for k=1:Npair 0052 Vpath = Xpath{k}; 0053 0054 src_pos(k,:) = Vpath(1,:); 0055 det_pos(k,:) = Vpath(end,:); 0056 0057 % channel position: mid point 0058 N1 = max(fix( Npath(k)/2 ),1); 0059 ch_pos(k,:) = Vpath(N1,:); 0060 end 0061 0062 pos_mode = 1; 0063 % dd = sq_distance(X,Y, pos_mode=1) 0064 % X : (M x D) matrix 0065 % Y : (N x D) matrix 0066 0067 % max-min distance between probe & channel pos 0068 pos = [src_pos; det_pos]; 0069 dd = sq_distance(pos, ch_pos, pos_mode); 0070 dmin = max(min(dd)); 0071 0072 % Select vertex for channel plot 0073 % DV(ch, id) = dist. of ch_pos(ch,:) & V(id,:) 0074 DV = sq_distance(ch_pos, V, pos_mode); 0075 dV = min(DV); 0076 0077 ix = find(dV < dmin); 0078 0079 % Select patch which include selected vertex points 0080 Vin = V(ix,:); 0081 Fin = vb_patch_select(ix,F,Nv); 0082 % Convert to vertex index within selected subset 'ix' 0083 Itrans = zeros(Nv,1); 0084 Itrans(ix) = 1:length(ix); 0085 Fin = Itrans(Fin); 0086 0087 % Outer area 0088 iz = find(dV >= dmin); 0089 Fout = vb_patch_select2(iz,F,Nv); 0090 0091 % --- Interpolation on face vertex using 3 neighbor channels 0092 % W(n,1:3) : n-th interpolation coefficient 0093 % --- Interpolation using 'W' 0094 % y(n,1:3) = Three data values corresponding to the distance dd(n,1:3) 0095 % y_interp(n) = sum( W(n,1:3) .* y(n,1:3) , 2) 0096 0097 % Find 3 neighbor channels for selected vertex Vin=V(ix,:) 0098 DV = DV(:,ix); 0099 [DV, Ich] = sort(DV); 0100 0101 switch p.mode 0102 case 0 0103 dn = sqrt(DV(1:3,:)'); 0104 W = vb_linear_interpolate3(dn); 0105 y = sum( W .* ch_val(Ich(1:3,:)'), 2); 0106 case 1 0107 y = ch_val(Ich(1,:)'); 0108 end 0109 0110 y = double(y); 0111 0112 % 0113 % --- Plot channel data on face 0114 % 0115 h = figure; 0116 0117 patch('Faces',Fin,'Vertices',Vin,'FaceColor','interp',... 0118 'FaceVertexCData',y,'EdgeColor','none',... 0119 'FaceLighting','none'); 0120 0121 %material dull; 0122 0123 axis equal 0124 hold on; 0125 0126 % Plot source & detector channel 0127 plot3(src_pos(:,1), src_pos(:,2), src_pos(:,3), p.Msend,'MarkerSize',p.Msize); 0128 plot3(det_pos(:,1), det_pos(:,2), det_pos(:,3), p.Mrecv,'MarkerSize',p.Msize); 0129 0130 % 0131 % --- Plot outer surface 0132 vb_plot_surf(V,Fout); 0133 0134 camlight headlight;