├── MATLAB-Code ├── Z_data.mat ├── project_eit.asv └── project_eit.m ├── MATLAB-Outputs ├── equations.png ├── layers.gif ├── layers.mp4 ├── tumor-animation.gif └── tumorAnimation.mp4 └── README.md /MATLAB-Code/Z_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/candicei/MATLAB-ElT/80cfe84dab2ed16c8ddeea37b93dc5868f7f6be5/MATLAB-Code/Z_data.mat -------------------------------------------------------------------------------- /MATLAB-Code/project_eit.asv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/candicei/MATLAB-ElT/80cfe84dab2ed16c8ddeea37b93dc5868f7f6be5/MATLAB-Code/project_eit.asv -------------------------------------------------------------------------------- /MATLAB-Code/project_eit.m: -------------------------------------------------------------------------------- 1 | %% MATH 406 2 | % Electrical Impedance Tomography (EIT) 3 | % Problem to determine non-uniformity within a circular region (a tumor 4 | % in the region) based on boundary values 5 | % 6 | % Using the solution u(r,theta) = 7 | % [I*a/(2*pi*sigma)]*log[(a^2+r^2+2arcos(phi)/(a^2+r^2-2arcos(phi)] 8 | % where phi = theta-pi/2 9 | % 10 | % Z_data.txt is a file containing for measurement data of voltages 11 | % - size: 16x8 12 | % 13 | % Variables 14 | % [X,Y] = points on the boundary where measurements are taken 15 | % [x_mesh, y_mesh] = made by the mesh we want to determine our inner 16 | % points and will be mapped to... 17 | % [XX, YY] = the mesh points (line above) to the edges given by the 18 | % transformations mapX and mapY 19 | % % % % % 20 | 21 | clear;clc; 22 | % OPENING THE DATA FILE (delta v1) 23 | load('Z_data.mat'); 24 | 25 | % CONSTANTS 26 | a = 10; % radius 27 | sigma = 1 ; % conductance 28 | I = 1/a; % current 29 | k = 16; % boundary points 30 | n = 8; % number of excitation location pairs (of current) 31 | eps = 1e-9; % small number for the voltage boundary values to not have an effect on the data 32 | C1 = I*a/(2*sigma*pi); 33 | N = n*100; % number of radial points within the mesh 34 | 35 | % MAPPING FUNCTIONS 36 | mapX = @(x,y) 2.*a^2.*x./(y.^2+x.^2+a^2); 37 | mapY = @(X) (a^2-X.^2).^(1/2); 38 | 39 | % VARIABLES 40 | phi = 0:pi/n:(2*pi); 41 | u1 = zeros(k+1,n); 42 | r = a; % where we r 43 | 44 | % HOMOGENOUS BOUNDARY VOLTAGE VALUES 45 | u_foo(:,1) = C1*(log(a^2+a^2+2.*a.*a.*cos(phi))- log(a^2+a^2-2.*a.*a.*cos(phi))); 46 | u_foo(abs(u_foo) == inf) = eps; %checking for voltage values at infinity to be set as eps to have little effect on data 47 | % creating the homogenous matrix (of boundary voltages at the points) 48 | for i = 1:n 49 | u1(:,i) = u_foo; 50 | end 51 | 52 | % CREATING THE ZH MATRIX 53 | ZH = diff(u1); % in order to the the delta u1 matrix 54 | ZH([1,8,9,16],:) = eps; 55 | 56 | 57 | % CREATING THE DELTA SIGMA MATRIX 58 | del_sig = -sigma.*(Z./ZH - 1); 59 | del_sig(abs(del_sig)==inf) = eps; % replacing inf locations 60 | 61 | % CREATING THE MESH 62 | r_foo = linspace(0,a,N); 63 | phi_foo = linspace(0,2*pi,N); 64 | [r_mesh, phi_mesh] = meshgrid(r_foo, phi_foo); 65 | x_mesh = r_mesh.*cos(phi_mesh); 66 | y_mesh = r_mesh.*sin(phi_mesh); 67 | 68 | % these XX and YY transformations only go to the top half (+sqrt()) 69 | XX = mapX(x_mesh,y_mesh); 70 | YY = mapY(XX); 71 | 72 | % creating the actual measurment points X, Y on the boundary for only the 73 | % top half 74 | phi = 0:pi/n:(2*pi-pi/n); 75 | X = a.*cos(phi); edgesX = fliplr(X(1:length(X)/2+1)); 76 | Y = a.*sin(phi); edgesY = fliplr(Y(1:length(Y)/2+1)); 77 | 78 | % We check by regions to see if XX is within certain regions (separated by 79 | % the equipotential lines from the mapped x_mesh, y_mesh. This is compare 80 | % to values of our measurement points X and Y. The regions are specified 81 | % such that region 1 = region from X(pi) - X(15*pi/16), region 2 = 82 | % X(15*pi/16) - X(14*pi/16) and so on. Region 8 is the region from phi 83 | % pi/16 to 0. 84 | % This only checks the top curve. From this, 85 | % we determin a mapping (a look-up table) from regions 1, 2, ... 8, to 86 | % determine in which equipotential line we exist in. 87 | % We search down on columns first then to the next row. 88 | lookupX = discretize(XX,edgesX); 89 | 90 | 91 | % CREATING THE MULTIPLE EXCITATION POINT MAPS 92 | uuu = repmat(lookupX,1,1,k/2); 93 | shift = 1*floor(N/(k)); % number of points to "circshift" the data 94 | uu = lookupX; 95 | 96 | %regions 1->8 averaged with the bottom half 97 | avg_del_sig = del_sig(fliplr(1:k/2),:)+del_sig((k/2+1):k,:)/2; 98 | % obtaining the 3d graph for all points for excitation points at phi/16 99 | for ii = 1:n 100 | for i = 1:length(avg_del_sig) 101 | uu(lookupX == i) = avg_del_sig(i,ii); 102 | end 103 | uuu(:,:,ii) = circshift(uu,shift*(ii-1)); 104 | end 105 | 106 | % PLOTTING THE FIGURES 107 | titlename = ['Excitation at \phi = \pi/16']; 108 | figure(1) 109 | for i = 1:n 110 | subplot(2,4,i) 111 | surf(x_mesh,y_mesh,uuu(:,:,i)) 112 | view([0 90]) 113 | shading interp 114 | titlename(22) = num2str(i-1); 115 | title(titlename) 116 | xlabel('X'); 117 | ylabel('Y'); 118 | end 119 | 120 | figure(2) 121 | surf(x_mesh,y_mesh,sum(uuu,3)) 122 | title('Location of Tumor') 123 | zlabel('Conductivity Pertubation(\Delta\sigma)') 124 | xlabel('X') 125 | ylabel('Y') 126 | view([0 90]) 127 | colormap(parula) 128 | shading interp 129 | colorbar 130 | 131 | % To Visualize 132 | % surf(x_mesh,y_mesh,zeros(size(x_mesh))) 133 | % view([0,90]) 134 | % figure(2) 135 | % surf(XX,YY,zeros(size(XX))) 136 | % view([0,90]) 137 | 138 | -------------------------------------------------------------------------------- /MATLAB-Outputs/equations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/candicei/MATLAB-ElT/80cfe84dab2ed16c8ddeea37b93dc5868f7f6be5/MATLAB-Outputs/equations.png -------------------------------------------------------------------------------- /MATLAB-Outputs/layers.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/candicei/MATLAB-ElT/80cfe84dab2ed16c8ddeea37b93dc5868f7f6be5/MATLAB-Outputs/layers.gif -------------------------------------------------------------------------------- /MATLAB-Outputs/layers.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/candicei/MATLAB-ElT/80cfe84dab2ed16c8ddeea37b93dc5868f7f6be5/MATLAB-Outputs/layers.mp4 -------------------------------------------------------------------------------- /MATLAB-Outputs/tumor-animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/candicei/MATLAB-ElT/80cfe84dab2ed16c8ddeea37b93dc5868f7f6be5/MATLAB-Outputs/tumor-animation.gif -------------------------------------------------------------------------------- /MATLAB-Outputs/tumorAnimation.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/candicei/MATLAB-ElT/80cfe84dab2ed16c8ddeea37b93dc5868f7f6be5/MATLAB-Outputs/tumorAnimation.mp4 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Electrical Impedance Tomography (EIT) with Green's Functions 2 | This project is to learn an application of applying Green's Functions towards Electrical Impedance Tomography (EIT) to image a simulated tumour in a circular region using MATLAB. This is part of a project course from the University of British Columbia. 3 | 4 | 5 | **See the resulting EIT scan as a gif!** 6 | 7 |
8 |
9 |
70 |
71 |
88 |
89 |