Home > bioelectromagnetism > elec_load_testscript.m

elec_load_testscript

PURPOSE ^

elec_load_testscript - test loading and display of electrode data files

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 elec_load_testscript - test loading and display of electrode data files

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % elec_load_testscript - test loading and display of electrode data files
0002 
0003 clear;
0004 
0005 shape = '';
0006 shade = 'interp';
0007 
0008 elecpath = 'D:\MyDocuments\emse_data\ptsd-pet\source modelling\c07\meshes\';
0009 elecfile = 'c07_124fit.txt';
0010 
0011 elecpath = '';
0012 elecfile = 'elec_simul32.txt';
0013 elec_type = 'cart'; %'sphere1';
0014 
0015 
0016 % load electrode co-ordinates and create 3D interpolated surface
0017 
0018 file = strcat(elecpath,elecfile);
0019 [elec,type,X,Y,Z,th,phi,r] = elec_load(file,'cart');
0020 
0021 % Get electrode dataset centroid & reload
0022 index = find(type == 99);    xo = X(index);    yo = Y(index);    zo = Z(index);
0023 [elec,type,X,Y,Z,th,phi,r] = elec_load(file,'cart',xo,yo,zo);
0024 
0025 % Select electrodes only
0026 index = find(type == 69);    
0027 elec = elec(index);    
0028 X = X(index);    Y = Y(index);    Z = Z(index);
0029 th = th(index);   phi = phi(index);    r = r(index);
0030 
0031 % Gradations within co-ordinates
0032 Xmin = floor(min(X));    Xmax = ceil(max(X));
0033 Ymin = floor(min(Y));    Ymax = ceil(max(Y));
0034 
0035 if abs(Xmin) < abs(Xmax) x = abs(Xmax); else x = abs(Xmin); end
0036 if abs(Ymin) < abs(Ymax) y = abs(Ymax); else y = abs(Ymin); end
0037 if (x < y) m = y; else m = x; end
0038 
0039 % grid, given cm input for electrode locations
0040 grid = 1.0;    xi = -m:grid:m;    yi = xi';     gridSize = length(xi);
0041 
0042 % Interpolate the electrode co-ordinates
0043 switch shape
0044     case 'ellipse'
0045         [r,Xe,Ye,Ze,Xes,Yes,Zes] = elec_ellipse_fit1(X,Y,Z,xo,yo,0,gridSize); % Fit ellipse to X,Y,Z
0046         [Xi,Yi,Zi] = griddata(Xe,Ye,Ze,xi,yi,'cubic');    % Cubic spline interpolation
0047         %figure; plot3(X,Y,Z,'d'), hold on; plot3(Xe,Ye,Ze,'r.'), hold off; rotate3D
0048         %figure; surf(Xes,Yes,Zes); shading (shade); view([-20 20]); rotate3D
0049         clear Xes Yes Zes;
0050     case 'sphere'
0051         [r,Xs,Ys,Zs,Xss,Yss,Zss] = elec_sphere_fit1(X,Y,Z,xo,yo,0,gridSize); % Fit sphere to Z
0052         [Xi,Yi,Zi] = griddata(Xs,Ys,Zs,xi,yi,'cubic');   % Cubic spline interpolation
0053         %figure; plot3(X,Y,Z,'d'), hold on; plot3(Xs,Ys,Zs,'r.'), hold off; rotate3D
0054         %figure; surf(Xss,Yss,Zss); shading (shade); view([-20 20]); rotate3D
0055         clear Xss Yss Zss;
0056     otherwise
0057         [Xi,Yi,Zi] = griddata(X,Y,Z,xi,yi,'linear');        % Cubic spline interpolation
0058 end
0059 
0060 
0061 figure; polar(th,phi,'d');
0062 
0063 figure; plot3(X,Y,Z,'d'), hold on;
0064 surf(Xi,Yi,Zi); axis tight; rotate3d;

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003