0001
0002
0003
0004
0005
0006 warning off;
0007 disp('This is a demo for reconstructing admittivity changes of the form a + bi')
0008
0009 load datacom srf vtx simp;
0010
0011
0012
0013
0014 trimesh(srf,vtx(:,1),vtx(:,2),vtx(:,3));
0015 axis image;
0016 set(gcf,'Colormap',[0 0 0]);
0017 hold on;
0018
0019 disp('This is a cylindrical mesh with homogeneous distribution 1 + 0.5i')
0020 disp('Wait to attach the electrodes')
0021 disp(sprintf('\n'))
0022
0023 pause(2);
0024
0025 load datacom sels;
0026
0027
0028
0029
0030
0031 hidden off;
0032
0033 load datacom gnd_ind elec no_pl protocol zc sym;
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 [I,Ib] = set_3d_currents(protocol,elec,vtx,gnd_ind,no_pl);
0044
0045 disp('Adjacent current patterns selected')
0046 disp('Calculating reference measurements')
0047 disp(sprintf('\n'))
0048
0049
0050 tol = 1e-5;
0051
0052 pause(2);
0053
0054 mat_ref = (1+0.5i)*ones(828,1);
0055
0056
0057 [Eref,D,Ela,ppr] = fem_master_full(vtx,simp,mat_ref,gnd_ind,elec,zc,sym);
0058 [Vref] = left_divide(Eref,I,tol,ppr);
0059 [refH,refV,indH,indV,dfr]=get_3d_meas(elec,vtx,Vref,Ib,no_pl);
0060 dfr = dfr(1:2:end);
0061
0062 close;
0063 disp('Allow a couple of complex changes ...')
0064 disp(sprintf('\n'))
0065 pause(2);
0066
0067
0068 mat=mat_ref;
0069
0070 load datacom A B
0071
0072 sA = 1.2 + 0.4i;
0073
0074 sprintf ('This one at %f + %f i',real(sA), imag(sA))
0075 mat(A) = sA;
0076
0077 figure;
0078 subplot(1,2,1);
0079 trimesh(srf,vtx(:,1),vtx(:,2),vtx(:,3));
0080 axis image;
0081 set(gcf,'Colormap',[0 0 0]);
0082 hidden off;
0083 hold on;
0084 repaint_inho(real(mat),real(mat_ref),vtx,simp); title('REAL');
0085 camlight left;
0086 lighting flat;
0087
0088 subplot(1,2,2);
0089 trimesh(srf,vtx(:,1),vtx(:,2),vtx(:,3));
0090 axis image;
0091 set(gcf,'Colormap',[0 0 0]);
0092 hidden off;
0093 hold on;
0094 repaint_inho(imag(mat),imag(mat_ref),vtx,simp); title('IMAGINARY');
0095 camlight left;
0096 lighting flat;
0097
0098 pause(2);
0099 close;
0100
0101
0102
0103 sB = 1 + 0.75i;
0104 sprintf('and this one at %f + %f i',real(sB), imag(sB))
0105 mat(B) = sB;
0106
0107 figure; subplot(1,2,1);
0108 trimesh(srf,vtx(:,1),vtx(:,2),vtx(:,3));
0109 axis image;
0110 set(gcf,'Colormap',[0 0 0]);
0111 hidden off;
0112 hold on;
0113 repaint_inho(real(mat),real(mat_ref),vtx,simp); title('REAL');
0114 camlight left;
0115 lighting flat;
0116
0117 subplot(1,2,2);
0118 trimesh(srf,vtx(:,1),vtx(:,2),vtx(:,3));
0119 axis image;
0120 set(gcf,'Colormap',[0 0 0]);
0121 hidden off;
0122 hold on;
0123 repaint_inho(imag(mat),imag(mat_ref),vtx,simp); title('IMAGINARY');
0124 camlight left;
0125 lighting flat;
0126
0127 pause(2);
0128 close;
0129
0130
0131 disp(sprintf('\n'))
0132
0133 [En,D,Ela,ppn] = fem_master_full(vtx,simp,mat,gnd_ind,elec,zc,sym);
0134 [Vn] = left_divide(En,I,tol,ppn);
0135 [voltageH,voltageV,indH,indV,dfv]=get_3d_meas(elec,vtx,Vn,Ib,no_pl);
0136 dfv = dfv(1:2:end);
0137
0138 if size(dfr)~= size(dfv)
0139 error('Mismatched measurements')
0140 end
0141
0142 disp('Measurements calculated')
0143 disp(sprintf('\n'))
0144
0145 dva = voltageH-refH;
0146
0147 disp('Measurements blended with Gaussian noise ...')
0148 dc = mean(real(dva));
0149 dvrG = dc./7 * ones(length(dva),1) + dc * randn(length(dva),1);
0150
0151 dc = mean(imag(dva));
0152 dviG = dc./7 * ones(length(dva),1) + dc * randn(length(dva),1);
0153
0154 dat = (real(dva) + dvrG) + (imag(dva) + dviG)*i;
0155
0156
0157 disp('Calculating measurement fields')
0158 [v_f] = m_3d_fields(vtx,size(elec,1),indH,Eref,tol,gnd_ind);
0159
0160 disp('Calculating a single complex jacobian')
0161 [J] = jacobian_3d(I,elec,vtx,simp,gnd_ind,mat_ref,zc,v_f,dfv,tol,sym);
0162
0163
0164 disp('Computing a smooting prior')
0165 [Reg] = iso_f_smooth(simp,vtx,1,2);
0166
0167 disp('Calculating a linearised step inverse solution')
0168 disp(sprintf('\n'))
0169 tfac = 1e-7;
0170 sol = (J.'*J + tfac*Reg'*Reg)\J.' * dat;
0171 sreal = real(sol);
0172 simag = imag(sol);
0173
0174 truereal = real(mat-mat_ref);
0175 trueimag = imag(mat-mat_ref);
0176
0177 v = version;
0178
0179 if str2num(v(1)) > 5
0180
0181 h01 = figure;
0182 set(h01,'NumberTitle','off');
0183 set(h01,'Name','True conductivity distribution');
0184 subplot(2,3,1); [fc] = slicer_plot_n(2.63,truereal,vtx,simp); view(2); grid; colorbar; axis off; title('z=2.63');
0185
0186 subplot(2,3,2); [fc] = slicer_plot_n(2.10,truereal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=2.10');
0187 subplot(2,3,3); [fc] = slicer_plot_n(1.72,truereal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.72');
0188 subplot(2,3,4); [fc] = slicer_plot_n(1.10,truereal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.10');
0189 subplot(2,3,5); [fc] = slicer_plot_n(0.83,truereal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.83');
0190 subplot(2,3,6); [fc] = slicer_plot_n(0.10,truereal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.10');
0191
0192
0193 h02 = figure;
0194 set(h02,'NumberTitle','off');
0195 set(h02,'Name','True scaled permittivity distribution');
0196 subplot(2,3,1); [fc] = slicer_plot_n(2.63,trueimag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=2.60');
0197 subplot(2,3,2); [fc] = slicer_plot_n(2.10,trueimag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=2.10');
0198 subplot(2,3,3); [fc] = slicer_plot_n(1.72,trueimag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.70');
0199 subplot(2,3,4); [fc] = slicer_plot_n(1.10,trueimag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.10');
0200 subplot(2,3,5); [fc] = slicer_plot_n(0.83,trueimag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.80');
0201 subplot(2,3,6); [fc] = slicer_plot_n(0.10,trueimag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.10');
0202
0203
0204
0205 h2 = figure;
0206 set(h2,'NumberTitle','off');
0207 set(h2,'Name','Reconstructed conductivity distribution');
0208 subplot(2,3,1); [fc] = slicer_plot_n(2.63,sreal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=2.63');
0209 subplot(2,3,2); [fc] = slicer_plot_n(2.10,sreal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=2.10');
0210 subplot(2,3,3); [fc] = slicer_plot_n(1.72,sreal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.72');
0211 subplot(2,3,4); [fc] = slicer_plot_n(1.10,sreal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.10');
0212 subplot(2,3,5); [fc] = slicer_plot_n(0.83,sreal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.83');
0213 subplot(2,3,6); [fc] = slicer_plot_n(0.10,sreal,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.10');
0214
0215 h3 = figure;
0216 set(h3,'NumberTitle','off');
0217 set(h3,'Name','Reconstructed scaled permittivity distribution');
0218 subplot(2,3,1); [fc] = slicer_plot_n(2.63,simag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=2.60');
0219 subplot(2,3,2); [fc] = slicer_plot_n(2.10,simag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=2.10');
0220 subplot(2,3,3); [fc] = slicer_plot_n(1.72,simag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.70');
0221 subplot(2,3,4); [fc] = slicer_plot_n(1.10,simag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.10');
0222 subplot(2,3,5); [fc] = slicer_plot_n(0.83,simag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.80');
0223 subplot(2,3,6); [fc] = slicer_plot_n(0.10,simag,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.10');
0224
0225 else
0226
0227 disp('Change the plotting command above to slicer_plot or upgrate to MATLAB 6')
0228 disp('See demo_real for more details')
0229
0230 end
0231
0232 disp('Done')
0233
0234
0235
0236
0237
0238
0239
0240
0241