calc_transferimpedance

PURPOSE ^

CALC_TRANSFERIMPEDANCE: Calculates transfer impedance matrix

SYNOPSIS ^

function transfimp = calc_transferimpedance( img)

DESCRIPTION ^

 CALC_TRANSFERIMPEDANCE: Calculates transfer impedance matrix
 
   transfimp = calc_transferimpedance( img)

 fwd_model is a fwd_model structure
 img       is an image structure

 transfimp calculates electrode voltages based on electrode currents as
     V = transfimp*I
 For example, for 4 electrodes, the voltage across [1,2] when 3A is across [3,4]
    is given by [1,-1,0,0] * transfimp * [0;0;3;-3];

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function transfimp = calc_transferimpedance( img)
0002 % CALC_TRANSFERIMPEDANCE: Calculates transfer impedance matrix
0003 %
0004 %   transfimp = calc_transferimpedance( img)
0005 %
0006 % fwd_model is a fwd_model structure
0007 % img       is an image structure
0008 %
0009 % transfimp calculates electrode voltages based on electrode currents as
0010 %     V = transfimp*I
0011 % For example, for 4 electrodes, the voltage across [1,2] when 3A is across [3,4]
0012 %    is given by [1,-1,0,0] * transfimp * [0;0;3;-3];
0013 
0014 % (C) 2006 Bill Lionheart. License: GPL version 2 or version 3
0015 % $Id: calc_transferimpedance.m 5234 2016-08-03 11:13:29Z aadler $
0016 
0017 % create new stim patterns
0018 % stimulate with one ref electrode and then each in turn
0019 % make an equiv set of measurements
0020 
0021 copt.cache_obj = {img.fwd_model, img.elem_data};
0022 copt.fstr = 'calc_transferimpedance';
0023 transfimp = eidors_cache(@calc_T, img, copt);
0024 
0025 
0026 function transfimp = calc_T( img);
0027    n_elecs= length( img.fwd_model.electrode );
0028 
0029    %[stim_pat, meas_pat]= trigonometric( n_elecs );
0030    %[stim_pat, meas_pat]= electrode_wise( n_elecs );
0031    %[stim_pat, meas_pat]= monopolar( n_elecs );
0032     [stim_pat, meas_pat]= monopolar_even( n_elecs );
0033    img.fwd_model.stimulation = stim_pat;
0034 
0035    imeas_pat= pinv(meas_pat);
0036 
0037    data = fwd_solve(img);
0038 
0039    sz= length(img.fwd_model.stimulation);
0040    transfimp = reshape( data.meas, sz, sz);
0041    transfimp = imeas_pat * transfimp * imeas_pat';
0042 
0043 function [stim_pat, meas_pat] = trigonometric( n_elecs )
0044     stim_pat = struct;
0045     idx= linspace(0,2*pi,n_elecs+1)'; idx(end)= [];
0046     omega= idx*[1:n_elecs/2];
0047     meas_pat= [cos(omega), sin(omega) ]';
0048     for i=1:n_elecs
0049         stim_pat(i).stimulation='Amp';
0050         stim_pat(i).stim_pattern= meas_pat(i,:)';
0051         stim_pat(i).meas_pattern= meas_pat;
0052     end
0053 
0054 function [stim_pat, meas_pat] = electrode_wise( n_elecs)
0055     stim_pat = struct;
0056     meas_pat= [-ones(n_elecs-1,1), speye(n_elecs-1)];
0057     for i=2:n_elecs
0058         stim_pat(i-1).stimulation='Amp';
0059         stim_pat(i-1).stim_pattern= sparse([1,i],1,[-1,1],n_elecs,1);
0060         stim_pat(i-1).meas_pattern= meas_pat;
0061     end
0062 
0063 function [stim_pat, meas_pat] = monopolar( n_elecs)
0064     stim_pat = struct;
0065     meas_pat= speye(n_elecs);
0066     for i=1:n_elecs
0067         stim_pat(i).stimulation='Amp';
0068         stim_pat(i).stim_pattern= sparse(i,1,1,n_elecs,1);
0069         stim_pat(i).meas_pattern= meas_pat;
0070     end
0071 
0072 function [stim_pat, meas_pat] = monopolar_even( n_elecs)
0073     stim_pat = struct;
0074     meas_pat= eye(n_elecs) - ones(n_elecs)/n_elecs;
0075     for i=1:n_elecs
0076         stim_pat(i).stimulation='Amp';
0077         stim_pat(i).stim_pattern= meas_pat(i,:)';
0078         stim_pat(i).meas_pattern= meas_pat;
0079     end

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005