0001 function transfimp = calc_transferimpedance( img)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 cacheobj = {img.fwd_model, img.elem_data};
0017 transfimp = eidors_obj('get-cache', cacheobj, 'calc_transferimpedance');
0018
0019 if ~isempty(transfimp)
0020 eidors_msg('calc_transferimpedance: using cached value', 3);
0021 return
0022 end
0023
0024 transfimp = calc_T( img );
0025
0026 eidors_obj('set-cache', cacheobj, 'calc_transferimpedance', transfimp);
0027 eidors_msg('calc_transferimpedance: setting cached value', 3);
0028
0029 function transfimp = calc_T( img);
0030 n_elecs= length( img.fwd_model.electrode );
0031
0032
0033
0034
0035 [stim_pat, meas_pat]= monopolar_even( n_elecs );
0036 img.fwd_model.stimulation = stim_pat;
0037
0038 imeas_pat= pinv(meas_pat);
0039
0040 data = fwd_solve(img);
0041
0042 sz= length(img.fwd_model.stimulation);
0043 transfimp = reshape( data.meas, sz, sz);
0044 transfimp = imeas_pat * transfimp * imeas_pat';
0045
0046 function [stim_pat, meas_pat] = trigonometric( n_elecs )
0047 stim_pat = struct;
0048 idx= linspace(0,2*pi,n_elecs+1)'; idx(end)= [];
0049 omega= idx*[1:n_elecs/2];
0050 meas_pat= [cos(omega), sin(omega) ]';
0051 for i=1:n_elecs
0052 stim_pat(i).stimulation='mA';
0053 stim_pat(i).stim_pattern= meas_pat(i,:)';
0054 stim_pat(i).meas_pattern= meas_pat;
0055 end
0056
0057 function [stim_pat, meas_pat] = electrode_wise( n_elecs)
0058 stim_pat = struct;
0059 meas_pat= [-ones(n_elecs-1,1), speye(n_elecs-1)];
0060 for i=2:n_elecs
0061 stim_pat(i-1).stimulation='mA';
0062 stim_pat(i-1).stim_pattern= sparse([1,i],1,[-1,1],n_elecs,1);
0063 stim_pat(i-1).meas_pattern= meas_pat;
0064 end
0065
0066 function [stim_pat, meas_pat] = monopolar( n_elecs)
0067 stim_pat = struct;
0068 meas_pat= speye(n_elecs);
0069 for i=1:n_elecs
0070 stim_pat(i).stimulation='mA';
0071 stim_pat(i).stim_pattern= sparse(i,1,1,n_elecs,1);
0072 stim_pat(i).meas_pattern= meas_pat;
0073 end
0074
0075 function [stim_pat, meas_pat] = monopolar_even( n_elecs)
0076 stim_pat = struct;
0077 meas_pat= eye(n_elecs) - ones(n_elecs)/n_elecs;
0078 for i=1:n_elecs
0079 stim_pat(i).stimulation='mA';
0080 stim_pat(i).stim_pattern= meas_pat(i,:)';
0081 stim_pat(i).meas_pattern= meas_pat;
0082 end