elec_meshplot - Plot a mesh and points for 3D electrode positions. Usage: H = elec_meshplot(X,Y,Z [,interp] [,grid_resolution]) Uses an interpolated mesh at 0.25 cm resolution, unless user specifies alternative grid resolution (optional). Interpolation can be 'linear' or 'cubic'. Unless specified, cubic is the default. Returns a handle to the figure created.
0001 function H = elec_meshplot(X,Y,Z,interp,grid_res) 0002 0003 % elec_meshplot - Plot a mesh and points for 3D electrode positions. 0004 % 0005 % Usage: H = elec_meshplot(X,Y,Z [,interp] [,grid_resolution]) 0006 % 0007 % Uses an interpolated mesh at 0.25 cm resolution, unless 0008 % user specifies alternative grid resolution (optional). 0009 % 0010 % Interpolation can be 'linear' or 'cubic'. Unless specified, 0011 % cubic is the default. 0012 % 0013 % Returns a handle to the figure created. 0014 % 0015 0016 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:34 $ 0017 0018 % Licence: Gnu GPL 0019 % Author: Darren.Weber_at_radiology.ucsf.edu 0020 % Created: 18/05/00 0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0022 0023 H = figure('NumberTitle','off','Name','Electrode Mesh Plot','Position',[200 200 650 500],'PaperUnits','centimeters','PaperType','A4','Units','centimeters'); 0024 0025 colormap(gray); 0026 0027 if ~exist( 'grid_res', 'var' ) grid_res = 0.25; end 0028 0029 xi = (min(X) - 2):grid_res:(max(X) + 2); 0030 yi = [(min(Y) - 2):grid_res:(max(Y) + 2)]'; 0031 0032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0033 % Use 'linear' for a linear grid or 'cubic' for a polynomial grid 0034 0035 if ~exist( 'interp', 'var' ) interp = 'cubic'; end 0036 0037 [Xi,Yi,Zi] = griddata(X,Y,Z,xi,yi,interp); 0038 0039 surf(Xi,Yi,Zi); 0040 0041 brighten(0.75); 0042 0043 mesh(Xi,Yi,Zi); 0044 0045 hold on; 0046 0047 plot3(X,Y,Z,'ro'); 0048 0049 rotate3d; 0050 0051 clear xi yi Xi Yi Zi X Y Z; 0052 0053 % view(2); % top view 0054 % view( 0,0); % back view 0055 % view(-180,0); % front view 0056 % view(-90, 0); % left side view 0057 % view( 90, 0); % right side view