0001
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';
0014
0015
0016
0017
0018 file = strcat(elecpath,elecfile);
0019 [elec,type,X,Y,Z,th,phi,r] = elec_load(file,'cart');
0020
0021
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
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
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
0040 grid = 1.0; xi = -m:grid:m; yi = xi'; gridSize = length(xi);
0041
0042
0043 switch shape
0044 case 'ellipse'
0045 [r,Xe,Ye,Ze,Xes,Yes,Zes] = elec_ellipse_fit1(X,Y,Z,xo,yo,0,gridSize);
0046 [Xi,Yi,Zi] = griddata(Xe,Ye,Ze,xi,yi,'cubic');
0047
0048
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);
0052 [Xi,Yi,Zi] = griddata(Xs,Ys,Zs,xi,yi,'cubic');
0053
0054
0055 clear Xss Yss Zss;
0056 otherwise
0057 [Xi,Yi,Zi] = griddata(X,Y,Z,xi,yi,'linear');
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;