0001 function img= ab_tv_diff_solve( inv_model, data1, data2)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 p= get_params(inv_model);
0024
0025 dva = calc_difference_data( data1, data2, inv_model.fwd_model);
0026
0027 back_val = get_good_background(inv_model, data1);
0028 inv_model.jacobian_bkgnd.value= back_val;
0029
0030 sol= [];
0031 for i=1:size(dva,2)
0032 [soln,dual_x]=primaldual_tvrecon_lsearch(inv_model, dva(:,i), ...
0033 p.maxiter,p.alpha1,p.alpha2, p.tol, p.beta, p.min_change);
0034
0035 if ~p.keepiters
0036 soln=soln(:,end);
0037 end
0038
0039 sol=[sol, soln];
0040 end
0041
0042 img.name= 'solved by ab_tv_diff_solve';
0043 img.elem_data = sol;
0044 img.fwd_model= inv_model.fwd_model;
0045 try if inv_model.ab_tv_diff_solve.want_dual_variable
0046 img.dual_data = dual_x;
0047 end; end
0048
0049 function p = get_params(inv_model);
0050
0051 try p.alpha1= inv_model.ab_tv_diff_solve.alpha1;
0052 catch p.alpha1= 1e-2;
0053 end
0054
0055 try p.beta= inv_model.ab_tv_diff_solve.beta;
0056 catch p.beta= 1e-4;
0057 end
0058
0059 p.alpha2= calc_hyperparameter( inv_model);
0060
0061 try p.min_change = inv_model.parameters.min_change;
0062 catch p.min_change = 0;
0063 end
0064
0065 try p.maxiter = inv_model.parameters.max_iterations;
0066 catch p.maxiter= 10;
0067 end
0068
0069 try p.keepiters = inv_model.parameters.keep_iterations;
0070 catch p.keepiters= 0;
0071 end
0072
0073 p.tol = 0;
0074
0075 function back_val = get_good_background(inv_mdl, data1);
0076
0077
0078 IM= eidors_obj('image','');
0079 IM.fwd_model= inv_mdl.fwd_model;
0080 s= ones(size(IM.fwd_model.elems,1),1);
0081 IM.elem_data= s;
0082
0083 vsim= fwd_solve( IM);
0084 back_val=abs( data1\vsim.meas );
0085 back_val=1;
0086