0001 function param= mv_fwd_parameters( fwd_model )
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
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);
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