


meas_icov = calc_meas_icov( inv_model )
CALC_MEAS_ICOV: calculate inverse covariance of measurements
The meas_icov is a matrix n_meas x n_meas of the
inverse of measurement covariances. Normally measurements
are assumed to be independant, so the meas_icov is
a diagonal matrix of 1/var(meas)
calc_meas_icov can be called as
meas_icov= calc_meas_icov( inv_model )
meas_icov is the calculated data prior
inv_model is an inv_model structure
if:
inv_model.meas_icov is a function
-> call it to calculate meas_icov
inv_model.meas_icov is a matrix
-> return it as meas_icov
inv_model.meas_icov does not exist
-> use I, or 1./homg (for normalized difference)


0001 function meas_icov = calc_meas_icov( inv_model ) 0002 % meas_icov = calc_meas_icov( inv_model ) 0003 % CALC_MEAS_ICOV: calculate inverse covariance of measurements 0004 % The meas_icov is a matrix n_meas x n_meas of the 0005 % inverse of measurement covariances. Normally measurements 0006 % are assumed to be independant, so the meas_icov is 0007 % a diagonal matrix of 1/var(meas) 0008 % 0009 % calc_meas_icov can be called as 0010 % meas_icov= calc_meas_icov( inv_model ) 0011 % 0012 % meas_icov is the calculated data prior 0013 % inv_model is an inv_model structure 0014 % 0015 % if: 0016 % inv_model.meas_icov is a function 0017 % -> call it to calculate meas_icov 0018 % inv_model.meas_icov is a matrix 0019 % -> return it as meas_icov 0020 % inv_model.meas_icov does not exist 0021 % -> use I, or 1./homg (for normalized difference) 0022 0023 % (C) 2005 Andy Adler. License: GPL version 2 or version 3 0024 % $Id: calc_meas_icov.html 2819 2011-09-07 16:43:11Z aadler $ 0025 0026 meas_icov = eidors_obj('get-cache', inv_model, 'meas_icov'); 0027 0028 if ~isempty(meas_icov) 0029 eidors_msg('calc_meas_icov: using cached value', 3); 0030 return 0031 end 0032 0033 if isfield(inv_model,'meas_icov') 0034 if isnumeric(inv_model.meas_icov); 0035 meas_icov = inv_model.meas_icov; 0036 else 0037 meas_icov= feval( inv_model.meas_icov, inv_model); 0038 end 0039 else 0040 meas_icov= default_meas_icov( inv_model ); 0041 end 0042 0043 eidors_obj('set-cache', inv_model, 'meas_icov', meas_icov); 0044 eidors_msg('calc_meas_icov: setting cached value', 3); 0045 0046 % Calculate a data prior for an assumption of uniform noise 0047 % on each channel 0048 % 0049 function meas_icov = default_meas_icov( inv_model ) 0050 0051 fwd_model= inv_model.fwd_model; 0052 if isfield(fwd_model,'normalize_measurements') 0053 normalize = fwd_model.normalize_measurements; 0054 else 0055 normalize = 0; 0056 end 0057 0058 n = calc_n_meas( fwd_model ); 0059 0060 if ~normalize 0061 meas_icov= speye( n ); 0062 else 0063 homg_data= solve_homg_image( fwd_model ); 0064 % sig = k/h -> std = k/h -> 1/std = kh 0065 meas_icov = sparse(1:n, 1:n, ( homg_data.meas ).^2 ); 0066 end 0067 0068 function n_meas = calc_n_meas( fwd_model ) 0069 0070 n_meas = 0; 0071 for i= 1:length(fwd_model.stimulation ); 0072 n_meas = n_meas + size(fwd_model.stimulation(i).meas_pattern,1); 0073 end 0074 0075 % create homogeneous image + simulate data 0076 function homg_data = solve_homg_image( fwd_mdl ) 0077 n_elems= size( fwd_mdl.elems , 1); 0078 mat= ones( n_elems, 1); 0079 homg_img= eidors_obj('image', 'homogeneous image', ... 0080 'elem_data', mat, 'fwd_model', fwd_mdl ); 0081 homg_data=fwd_solve( homg_img);