0001 function img= inv_solve_abs_GN( inv_model, data1);
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
0030 if isstr(inv_model) && strcmp(inv_model,'UNIT_TEST'); img = do_unit_test; return; end
0031
0032
0033
0034
0035
0036 inv_model = deprecate_imdl_opt(inv_model, 'parameters');
0037 inv_model = deprecate_imdl_opt(inv_model, 'inv_solve');
0038 inv_model = deprecate_imdl_opt(inv_model, 'inv_solve_abs_core');
0039
0040
0041 if isfield(inv_model, 'inv_solve_abs_GN')
0042 if isfield(inv_model, 'inv_solve_abs_core')
0043 error('inv_model.inv_solve_abs_GN replaces inv_model.inv_solve_abs_core, parameters will be lost');
0044 end
0045 inv_model.inv_solve_abs_core = inv_model.inv_solve_abs_GN;
0046 inv_model = rmfield(inv_model, 'inv_solve_abs_GN');
0047 end
0048
0049 img = inv_solve_abs_core(inv_model, data1);
0050
0051 if isfield(img, 'inv_solve_abs_core')
0052 img.inv_solve_abs_GN = img.inv_solve_abs_core;
0053 img=rmfield(img, 'inv_solve_abs_core');
0054 end
0055
0056 function imdl = deprecate_imdl_opt(imdl,opt)
0057 if ~isfield(imdl, opt)
0058 return;
0059 end
0060 if ~isstruct(imdl.(opt))
0061 error(['unexpected inv_model.' opt ' where ' opt ' is not a struct... i do not know what to do']);
0062 end
0063
0064
0065 Af = fieldnames(imdl.(opt));
0066 if ~strcmp(opt, 'inv_solve') || (length(Af(:)) ~= 1) || ~strcmp(Af(:),'calc_solution_error')
0067 disp(imdl)
0068 disp(imdl.(opt))
0069 warning('EIDORS:deprecatedParameters',['INV_SOLVE inv_model.' opt '.* are deprecated in favor of inv_model.inv_solve_abs_GN.* as of 30-Apr-2014.']);
0070 end
0071
0072 if ~isfield(imdl, 'inv_solve_abs_GN')
0073 imdl.inv_solve_abs_GN = imdl.(opt);
0074 else
0075
0076
0077 for i = fieldnames(imdl.(opt))'
0078 imdl.inv_solve_abs_GN.(i{1})=imdl.(opt).(i{1});
0079 end
0080 end
0081 imdl = rmfield(imdl, opt);
0082
0083 function pass = do_unit_test()
0084 pass=1;
0085 imdl=mk_common_model('a2c');
0086 imdl.reconst_type='absolute';
0087 imdl.solve=@inv_solve_abs_GN;
0088 fimg=mk_image(imdl,1);
0089 fimg.elem_data(5:10)=1.1;
0090 vi=fwd_solve(fimg);
0091 img=inv_solve(imdl,vi);
0092 clf; subplot(121); show_fem(fimg,1); title('forward model');
0093 subplot(122); show_fem(img,1); title('reconstruction');
0094 try unit_test_cmp('fwd vs. reconst', fimg.elem_data, img.elem_data, 0.08);
0095 catch me; disp(me.message); pass=0; end
0096