mv_fwd_parameters

PURPOSE ^

MV_FWD_PARAMETERS: data= mv_fwd_solve( fwd_model )

SYNOPSIS ^

function param= mv_fwd_parameters( fwd_model )

DESCRIPTION ^

 MV_FWD_PARAMETERS: data= mv_fwd_solve( fwd_model )
 Extract parameters from a 'fwd_model' struct which are 
 appropriate for Marco Vauhkonen Polydorides EIDORS2D code
   param.n_elem   => number of elements
   param.n_elec   => number of electrodes
   param.n_node   => number of nodes (vertices)
   param.n_stim   => number of current stimulation patterns
   param.Element  => Element structure (with Topology and Faces)
   param.z_contact=> column vector of contact impedances
   param.sigma    => column vector of contact impedances
   param.T        => current into each electrode
   param.C        => Measurement configuration

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function param= mv_fwd_parameters( fwd_model )
0002 % MV_FWD_PARAMETERS: data= mv_fwd_solve( fwd_model )
0003 % Extract parameters from a 'fwd_model' struct which are
0004 % appropriate for Marco Vauhkonen Polydorides EIDORS2D code
0005 %   param.n_elem   => number of elements
0006 %   param.n_elec   => number of electrodes
0007 %   param.n_node   => number of nodes (vertices)
0008 %   param.n_stim   => number of current stimulation patterns
0009 %   param.Element  => Element structure (with Topology and Faces)
0010 %   param.z_contact=> column vector of contact impedances
0011 %   param.sigma    => column vector of contact impedances
0012 %   param.T        => current into each electrode
0013 %   param.C        => Measurement configuration
0014 
0015 % (C) 2009 Andy Adler. License: GPL version 2 or version 3
0016 % $Id: mv_fwd_parameters.html 2819 2011-09-07 16:43:11Z aadler $
0017 
0018 
0019 param = eidors_obj('get-cache', fwd_model, 'mv_fwd_parameters');
0020 
0021 if ~isempty(param)
0022    eidors_msg('mv_fwd_parameters: using cached value', 3);
0023    return
0024 end
0025 
0026 param = calc_param( fwd_model );
0027 
0028 eidors_obj('set-cache', fwd_model, 'mv_fwd_parameters', param);
0029 eidors_msg('mv_fwd_parameters: setting cached value', 3);
0030 
0031 function p= calc_param( fmdl );
0032 
0033 p.n_elem = size(fmdl.elems,1);
0034 p.n_elec = length(fmdl.electrode);
0035 p.n_node = size(fmdl.nodes,1);
0036 p.n_stim = length(fmdl.stimulation);
0037 for i=1:p.n_elem
0038    elem = fmdl.elems(i,:);
0039    p.Element(i).Topology = elem;
0040    p.Element(i).Face =  cell(3,3); % Middle column isn't used
0041    j=1;for choose = [[1,2];[2,3];[3,1]]'
0042       ch_face = elem(choose);
0043       p.Element(i).Face{j,1} = ch_face;
0044       p.Element(i).Face{j,3} = in_electrode(ch_face, fmdl);
0045       j=j+1;
0046    end
0047 end
0048        
0049 for i=1:p.n_node
0050    nn.Coordinate = fmdl.nodes(i,:);
0051    nn.ElementConnection = find(any( fmdl.elems == i, 2))';
0052    Nodes = fmdl.elems( nn.ElementConnection,: );
0053    Nodes = unique(Nodes(:))';
0054    Nodes( Nodes == i ) = [];
0055    nn.NodeConnection = Nodes;
0056    p.Node(i)= nn;
0057 end
0058 
0059 p.z_contact = vertcat([fmdl.electrode(:).z_contact]);
0060 
0061 p.T = horzcat(fmdl.stimulation(:).stim_pattern);
0062 
0063 p.C = fmdl.stimulation(1).meas_pattern';
0064 for i=2:length(fmdl.stimulation);
0065    if all(all( p.C ~= fmdl.stimulation(i).meas_pattern'))
0066       error(['Meas_patterns differ for each stimulation.' ...
0067             'This is not compatible with eidors2d' ]);
0068    end
0069 end
0070 
0071 
0072 function eno=in_electrode(face, fmdl)
0073    eno= 0;
0074    for i=1:length(fmdl.electrode)
0075       is = intersect(face(:), fmdl.electrode(i).nodes(:) );
0076       if length(is)==2; eno=i; end
0077    end
0078

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