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

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 % (C) 2006 Bill Lionheart. License: GPL version 2 or version 3
0010 % $Id: calc_transferimpedance.html 2819 2011-09-07 16:43:11Z aadler $
0011 
0012 % create new stim patterns
0013 % stimulate with one ref electrode and then each in turn
0014 % make an equiv set of measurements
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    %[stim_pat, meas_pat]= trigonometric( n_elecs );
0033    %[stim_pat, meas_pat]= electrode_wise( n_elecs );
0034    %[stim_pat, meas_pat]= monopolar( n_elecs );
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

Generated on Tue 09-Aug-2011 11:38:31 by m2html © 2005