0001 function [imgr, img]= compare_2d_algs(option,shape);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 if nargin<2
0030 shape=0;
0031 end
0032
0033 calc_colours('ref_level','auto');
0034
0035 imb= mk_common_model('c2c',16);
0036 e= size(imb.fwd_model.elems,1);
0037 sigma= ones(e,1);
0038 img= eidors_obj('image','');
0039 img.elem_data= sigma;
0040 img.fwd_model= imb.fwd_model;
0041 vh= fwd_solve( img );
0042
0043 if shape==0
0044 sigma([25,37,49:50,65:66,81:83,101:103,121:124])=2;
0045 sigma([95,98:100,79,80,76,63,64,60,48,45,36,33,22])=2;
0046 elseif shape==1
0047 sigma([65,81,82,101,102,122])=2;
0048 elseif shape==2
0049 sigma(1:4)=2;
0050 else
0051 error('shape not defined (%d)',shape);
0052 end
0053
0054 img.elem_data= sigma;
0055 vi= fwd_solve( img );
0056
0057 sig= sqrt(norm(vi.meas - vh.meas));
0058 m= size(vi.meas,1);
0059 vi.meas = vi.meas + .0001*sig*randn(m,1);
0060 figure(2); img.elem_data= img.elem_data - 1; show_slices(img); figure(1);
0061
0062
0063 imb= mk_common_model('b2c2',16);
0064 inv2d= eidors_obj('inv_model', 'EIT inverse');
0065 inv2d.reconst_type= 'difference';
0066 inv2d.jacobian_bkgnd.value= 1;
0067 inv2d.fwd_model= imb.fwd_model;
0068 inv2d.fwd_model.np_fwd_solve.perm_sym= '{y}';
0069 inv2d.parameters.term_tolerance= 1e-4;
0070
0071 if option>100
0072 inv2d.fwd_model = mdl_normalize(inv2d.fwd_model,1);
0073 option=option-100;
0074 end
0075
0076 switch option
0077 case 1,
0078 inv2d.hyperparameter.value = 1e-3;
0079 inv2d.solve= 'inv_solve_diff_GN_one_step';
0080 inv2d.RtR_prior= 'prior_laplace';
0081
0082 case 2,
0083 inv2d.hyperparameter.value = 1e-3;
0084 inv2d.RtR_prior= 'prior_laplace';
0085 inv2d.solve= 'np_inv_solve';
0086
0087 case 3,
0088 inv2d.hyperparameter.func = @choose_noise_figure;
0089 inv2d.hyperparameter.noise_figure= 2;
0090 inv2d.hyperparameter.tgt_elems= 1:4;
0091 inv2d.RtR_prior= 'prior_gaussian_HPF';
0092 inv2d.solve= 'inv_solve_diff_GN_one_step';
0093
0094 case 3.1,
0095 inv2d.hyperparameter.func = @choose_noise_figure;
0096 inv2d.hyperparameter.noise_figure= 2;
0097 inv2d.hyperparameter.tgt_elems= 1:4;
0098 inv2d.RtR_prior= @prior_laplace;
0099 inv2d.solve= 'inv_solve_diff_GN_one_step';
0100
0101 case 4,
0102 inv2d.hyperparameter.value = 1e-6;
0103 inv2d.parameters.max_iterations= 10;
0104 inv2d.R_prior= 'prior_TV';
0105 inv2d.solve= 'inv_solve_TV_pdipm';
0106 inv2d.parameters.keep_iterations=1;
0107
0108 case 5,
0109 inv2d.hyperparameter.value = 1e-4;
0110 inv2d.solve= 'aa_inv_total_var';
0111 inv2d.R_prior= 'prior_laplace';
0112 inv2d.parameters.max_iterations= 10;
0113
0114 case 6,
0115 subplot(141); show_slices(img);
0116 inv2d.hyperparameter.value = 1e-4;
0117 inv2d.solve= 'aa_inv_total_var';
0118 inv2d.R_prior= 'prior_TV';
0119 inv2d.parameters.max_iterations= 1;
0120 inv2d.parameters.keep_iterations=1;
0121 subplot(142); show_slices( inv_solve( inv2d, vh, vi) );
0122 inv2d.parameters.max_iterations= 2;
0123 subplot(143); show_slices( inv_solve( inv2d, vh, vi) );
0124 inv2d.parameters.max_iterations= 5;
0125 subplot(144); show_slices( inv_solve( inv2d, vh, vi) );
0126 return;
0127
0128 case 7,
0129 inv2d.hyperparameter.value = 1e-2;
0130 inv2d.parameters.max_iterations = 1e3;
0131 inv2d.parameters.term_tolerance = 1e-3;
0132 inv2d.solve= 'aa_inv_conj_grad';
0133 inv2d.R_prior= 'prior_TV';
0134
0135
0136 case 8,
0137 inv2d.hyperparameter.value = 1e-5;
0138 inv2d.parameters.max_iterations= 20;
0139 inv2d.R_prior= 'prior_TV';
0140 inv2d.solve= 'inv_solve_TV_irls';
0141 inv2d.parameters.keep_iterations=1;
0142
0143 otherwise,
0144 error('action unknown');
0145 end
0146
0147
0148
0149
0150 imgr= inv_solve( inv2d, vh, vi);
0151
0152 figure(1); show_slices(imgr);