Home > 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)

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.

 [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)
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 %
0009 % [note]
0010 % If the coordinate system of the sensor position x is RAS (default of
0011 % VBMEG), the contour plot will be drawn in the neurological convention,
0012 % i.e., the view is above the subject and the right of the plot
0013 % corresponds to the right of the subject.
0014 %
0015 % [history]
0016 % 2010-10-04 Taku Yoshioka
0017 % 2012-06-20 taku-y
0018 %  [trivial] Comment was modified.
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 % --- Input arguments
0024 if nargin<3, clim = []; end;
0025 if size(z,2)==1, z = z'; end;
0026 
0027 % --- Draw contour map
0028 cla;
0029 
0030 [phi,theta,r] = cart2sph(x(:,1),x(:,2),x(:,3));
0031 [xa,ya,za] = pol2cart(phi,0.5*pi-theta,r);
0032 xa = mean(xa)-xa;
0033 ya = mean(ya)-ya;
0034 dx = (max(xa)-min(xa))/200;
0035 dy = (max(ya)-min(ya))/200;
0036 r_max = max(sqrt(xa.^2+ya.^2));
0037 xaa = xa;
0038 yaa = ya;
0039 xa = [xa; (1.1*r_max*cos(0:0.02*pi:1.99*pi))'];
0040 ya = [ya; (1.1*r_max*sin(0:0.02*pi:1.99*pi))'];
0041 za = [z'; zeros(100,1)];
0042 
0043 % Colormap
0044 [X,Y,Z] = griddata(xa,ya,za,...
0045            (min(xa):dx:max(xa)),...
0046            (min(ya):dy:max(ya))','cubic');
0047 [C,h] = contourf(X,Y,Z,20);
0048 
0049 if ~isempty(clim), 
0050   caxis(clim);
0051 else
0052   clim = get(gca,'CLim');
0053   if abs(clim(1))>abs(clim(2)), clim(2) = abs(clim(1));
0054   else clim(1) = -1*abs(clim(2)); end
0055   caxis(clim); 
0056 end
0057 set(h,'EdgeColor','none');
0058 hold on;
0059 
0060 % Contour line
0061 z_max = max(abs(clim));
0062 v = (0.2*z_max):(0.4*z_max):(1.0*z_max);
0063 v = [-1*v(end:-1:1) v];
0064 [C,h] = contourf(X,Y,Z,v);
0065 
0066 % Rendering
0067 if vb_matlab_version >= 7
0068   set(h,'Fill','off');
0069 else
0070   set(h,'FaceColor','none');
0071 end
0072 
0073 plot(xaa,yaa,'ko','MarkerSize',2); 
0074 set(gca,'XDir','reverse');
0075 set(gca,'YDir','reverse');
0076 
0077 return;

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005