0001 function PSF= GREIT_desired_img_FEMmesh(xyc, radius, opt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if ischar(xyc) && strcmp(xyc,'UNIT_TEST'); do_unit_test; return; end
0023
0024 copt.fstr = 'GREIT_desired_img_FEMmesh';
0025 copt.cache_obj = {xyc, radius, opt};
0026 PSF = eidors_cache(@desired_soln,{xyc, radius, opt},copt);
0027 end
0028
0029 function PSF = desired_soln(xyc,radius,opt)
0030
0031 opt.inside = opt.rec_model.inside;
0032 mxyc = interp_mesh(opt.rec_model); x=mxyc(:,1); y=mxyc(:,2);
0033 xmin = opt.meshsz(1); xmax = opt.meshsz(2);
0034 ymin = opt.meshsz(3); ymax = opt.meshsz(4);
0035
0036 radius = radius * 0.5 * max(xmax-xmin, ymax-ymin);
0037 PSF = zeros(size(x,1),size(xyc,2));
0038 x_spc = (xmax-xmin)/(opt.imgsz(1)-1) * 0.5;
0039 y_spc = (ymax-ymin)/(opt.imgsz(2)-1) * 0.5;
0040 for i=1:size(xyc,2);
0041 for dx = linspace(-x_spc, x_spc, 5)
0042 for dy = linspace(-y_spc, y_spc, 5)
0043 PSF(:,i) = PSF(:,i) + 1/25*( ...
0044 (dx+x(:)-xyc(1,i)).^2 + (dy+y(:)-xyc(2,i)).^2 ...
0045 < radius^2 );
0046 end
0047 end
0048
0049 end
0050 PSF = PSF(opt.inside,:);
0051 end
0052
0053 function do_unit_test
0054 img=mk_image(mk_common_model('d2c2',32)); vh=fwd_solve(img);
0055 img.elem_data(206)=1.1; vi=fwd_solve(img);
0056
0057 fm = ng_mk_cyl_models(0.2,[32,0.1],[0.05]);
0058 fm.stimulation = mk_stim_patterns(32,1,[0,1],[0,1],{},1);
0059 imdl= eidors_obj('inv_model','','fwd_model',fm);
0060 imdl.jacobian_bkgnd.value = 1;
0061 opt.desired_solution_fn = @GREIT_desired_img_original;
0062 imdl = mk_GREIT_model(imdl,0.20,1e1,opt);
0063 imgr = inv_solve(imdl,vh,vi); subplot(121); show_fem(imgr);
0064 disp(calc_noise_figure(imdl,vh,vi))
0065
0066 [~,idx] = sort(-imgr.elem_data);
0067 unit_test_cmp('[...]_img_original',idx(1:10), ...
0068 [365 366 333 334 398 397 364 367 332 399]');
0069
0070 imdl.rec_model = img.fwd_model;
0071 imdl.rec_model.inside = true(num_elems(img),1);
0072 opt.desired_solution_fn = @GREIT_desired_img_FEMmesh;
0073 imdl = mk_GREIT_model(imdl,0.20,1e1,opt);
0074 imgr = inv_solve(imdl,vh,vi); subplot(122); show_fem(imgr);
0075 disp(calc_noise_figure(imdl,vh,vi))
0076
0077 [~,idx] = sort(-imgr.elem_data);
0078 unit_test_cmp('[...]_img_FEMmesh',idx(1:10), ...
0079 [235 206 267 236 178 301 205 268 152 300]');
0080
0081 end