Home > vbmeg > functions > plotfunc > vb_plot_sensor_2d.m

vb_plot_sensor_2d

PURPOSE ^

Plot M/EEG spatial pattern on 2 dimentional surface.

SYNOPSIS ^

function vb_plot_sensor_2d(x,z,clim, face_disp, highlight_channel_ix, XY_scale)

DESCRIPTION ^

 Plot M/EEG spatial pattern on 2 dimentional surface.
 
 [input]
 x                    : <<matrix>> Sensor position.
 z                    : <<vector>> Signal value.
 clim                 : <optional> <<vector>> Minimum and maximum of contour map.
 face_disp            : <optional> plot nose and ears(true or false) (default : false)
 highlight_channel_ix : <optional> <<vector>> highlight channel index(x's indices)
 XY_scale             : <optional> face radius expand/shrink ratio(default : 1.0)

 [note]
 If the coordinate system of the sensor position x is RAS (default of
 VBMEG), the contour plot will be drawn in the neurological convention,
 i.e., the view is above the subject and the right of the plot
 corresponds to the right of the subject. 

 [history]
 2010-10-04 Taku Yoshioka
 2012-06-20 taku-y
  [trivial] Comment was modified. 

 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 vb_plot_sensor_2d(x,z,clim, face_disp, highlight_channel_ix, XY_scale)
0002 % Plot M/EEG spatial pattern on 2 dimentional surface.
0003 %
0004 % [input]
0005 % x                    : <<matrix>> Sensor position.
0006 % z                    : <<vector>> Signal value.
0007 % clim                 : <optional> <<vector>> Minimum and maximum of contour map.
0008 % face_disp            : <optional> plot nose and ears(true or false) (default : false)
0009 % highlight_channel_ix : <optional> <<vector>> highlight channel index(x's indices)
0010 % XY_scale             : <optional> face radius expand/shrink ratio(default : 1.0)
0011 %
0012 % [note]
0013 % If the coordinate system of the sensor position x is RAS (default of
0014 % VBMEG), the contour plot will be drawn in the neurological convention,
0015 % i.e., the view is above the subject and the right of the plot
0016 % corresponds to the right of the subject.
0017 %
0018 % [history]
0019 % 2010-10-04 Taku Yoshioka
0020 % 2012-06-20 taku-y
0021 %  [trivial] Comment was modified.
0022 %
0023 % Copyright (C) 2011, ATR All Rights Reserved.
0024 % License : New BSD License(see VBMEG_LICENSE.txt)
0025 
0026 % --- Input arguments
0027 if nargin<3, clim = []; end
0028 if size(z,2)==1, z = z'; end
0029 if ~exist('highlight_channel_ix', 'var')
0030     highlight_channel_ix = [];
0031 end
0032 if ~exist('XY_scale', 'var') || isempty(XY_scale)
0033     XY_scale = 1;
0034 end
0035 
0036 % --- Draw contour map
0037 cla;
0038 
0039 [phi,theta,r] = cart2sph(x(:,1),x(:,2),x(:,3));
0040 [xa,ya,za] = pol2cart(phi,0.5*pi-theta,r);
0041 % xa = mean(xa)-xa;
0042 % ya = mean(ya)-ya;
0043 ya = ya * -1;
0044 xa = xa * -1;
0045 
0046 dx = (max(xa)-min(xa))/200;
0047 dy = (max(ya)-min(ya))/200;
0048 r_max = max(sqrt(xa.^2+ya.^2));
0049 xaa = xa;
0050 yaa = ya;
0051 
0052 
0053 xa = [xa; (XY_scale*1.1*r_max*cos(0:0.02*pi:1.99*pi))'];
0054 ya = [ya; (XY_scale*1.1*r_max*sin(0:0.02*pi:1.99*pi))'];
0055 za = [z'; zeros(100,1)];
0056 
0057 % Colormap
0058 warning('off', 'MATLAB:griddata:DuplicateDataPoints');
0059 [X,Y,Z] = griddata(xa,ya,za,...
0060            (min(xa):dx:max(xa)),...
0061            (min(ya):dy:max(ya))','cubic');
0062 warning('on', 'MATLAB:griddata:DuplicateDataPoints');
0063 [C,h] = contourf(X,Y,Z,20);
0064 
0065 if ~isempty(clim),
0066   caxis(clim);
0067 else
0068   clim = get(gca,'CLim');
0069   if abs(clim(1))>abs(clim(2)), clim(2) = abs(clim(1));
0070   else clim(1) = -1*abs(clim(2)); end
0071   caxis(clim); 
0072 end
0073 set(h,'EdgeColor','none');
0074 hold on;
0075 
0076 % Contour line
0077 z_max = max(abs(clim));
0078 v = (0.2*z_max):(0.4*z_max):(1.0*z_max);
0079 v = [-1*v(end:-1:1) v];
0080 [C,h] = contourf(X,Y,Z,v);
0081 
0082 % Rendering
0083 if vb_matlab_version >= 7
0084   set(h,'Fill','off');
0085 else
0086   set(h,'FaceColor','none');
0087 end
0088 
0089 plot(xaa,yaa,'ko','MarkerSize',2); 
0090 set(gca,'XDir','reverse');
0091 set(gca,'YDir','reverse');
0092 
0093 if ~isempty(highlight_channel_ix)
0094     xaw = xa(highlight_channel_ix);
0095     yaw = ya(highlight_channel_ix);
0096     plot(xaw,yaw,'ko','MarkerSize',6, 'MarkerEdgeColor','w', 'MarkerFaceColor',[1, 1, 1]); 
0097 end
0098 
0099 if exist('face_disp', 'var') && face_disp
0100     vb_plot_sensor_2d_head_plot_add(gca);
0101 end
0102 
0103 
0104 
0105 return;

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