meas_icov_rm_elecs

PURPOSE ^

MEAS_ICOV_RM_ELECS: remove electrodes from consideration

SYNOPSIS ^

function meas_icov = meas_icov_rm_elecs( imdl, elec_list)

DESCRIPTION ^

 MEAS_ICOV_RM_ELECS: remove electrodes from consideration
 meas_icov = meas_icov_rm_elecs( inv_model, elec_list )

 PARAMETERS:
 - elec_list = numbers of elecs to remove
     or as imdl.meas_icov_rm_elecs.elec_list

 - imdl.meas_icov_rm_elecs.exponent - exponent
 - imdl.meas_icov_rm_elecs.SNR      - SNR to add (default inf)
 - imdl.meas_icov_rm_elecs.replace_value (default 0)
      Default is to modify the current meas_icov value, if replace_value==1,
      then a new value is calculated without reference to the current

 meas_icov_rm_elecs can also accept a fwd_model parameter
 
 meas_icov_rm_elecs returns the inverse noise covariance matrix, with 
 zeros at positions corresponding to the removed electrodes. Set 
 exponent = -1 and a large SNR to get the noise covariance matrix, with 
 large values at those positions instead. 

 Reference Accounting for erroneous electrode data in EIT
 A. Adler Physiological Measurement, 25(1):227-238, 2004.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function meas_icov = meas_icov_rm_elecs( imdl, elec_list)
0002 % MEAS_ICOV_RM_ELECS: remove electrodes from consideration
0003 % meas_icov = meas_icov_rm_elecs( inv_model, elec_list )
0004 %
0005 % PARAMETERS:
0006 % - elec_list = numbers of elecs to remove
0007 %     or as imdl.meas_icov_rm_elecs.elec_list
0008 %
0009 % - imdl.meas_icov_rm_elecs.exponent - exponent
0010 % - imdl.meas_icov_rm_elecs.SNR      - SNR to add (default inf)
0011 % - imdl.meas_icov_rm_elecs.replace_value (default 0)
0012 %      Default is to modify the current meas_icov value, if replace_value==1,
0013 %      then a new value is calculated without reference to the current
0014 %
0015 % meas_icov_rm_elecs can also accept a fwd_model parameter
0016 %
0017 % meas_icov_rm_elecs returns the inverse noise covariance matrix, with
0018 % zeros at positions corresponding to the removed electrodes. Set
0019 % exponent = -1 and a large SNR to get the noise covariance matrix, with
0020 % large values at those positions instead.
0021 %
0022 % Reference Accounting for erroneous electrode data in EIT
0023 % A. Adler Physiological Measurement, 25(1):227-238, 2004.
0024 
0025 % (C) 2008 Andy Adler. License: GPL version 2 or version 3
0026 % $Id: meas_icov_rm_elecs.m 6252 2022-03-25 21:50:49Z bgrychtol $
0027 
0028 if ischar(imdl) && strcmp(imdl,'UNIT_TEST'); do_unit_test; return; end
0029 
0030 switch imdl.type,
0031   case 'inv_model'; fmdl = imdl.fwd_model;
0032   case 'fwd_model'; fmdl = imdl;
0033                     imdl.meas_icov_rm_elecs.replace_value = 1;
0034   otherwise;        error('meas_icov_rm_elecs: require inv- or fwd-model');
0035 end
0036 
0037 if nargin< 2
0038    elec_list = imdl.meas_icov_rm_elecs.elec_list;
0039 end
0040 
0041      NSR = 0;
0042 try; NSR = (imdl.meas_icov_rm_elecs.SNR)^(-1);
0043 end
0044 
0045     exponent = 1;
0046 try;exponent = imdl.meas_icov_rm_elecs.exponent;
0047 end
0048 
0049     replace_value = 0;
0050 try;replace_value = imdl.meas_icov_rm_elecs.replace_value;
0051 end
0052  
0053 
0054 meas_icov = [];
0055 for stim = fmdl.stimulation(:)'
0056    mp = stim.meas_pattern;
0057    sp = stim.stim_pattern;
0058    icovi = ones(size(mp,1),1);
0059    if any(sp(elec_list) ~= 0)
0060       icovi = 0*icovi;
0061    else
0062       icovi = ~any( mp(:,elec_list) ~= 0, 2);
0063    end
0064 
0065    meas_icov = [meas_icov; icovi];
0066 end
0067 
0068 n = length(meas_icov);
0069 
0070 meas_icov(meas_icov == 0) = NSR;
0071 meas_icov = spdiags( meas_icov.^exponent, 0, n,n );
0072 
0073 if replace_value == 0
0074    meas_icov = calc_meas_icov(imdl)*meas_icov;
0075 end
0076 
0077 function do_unit_test
0078    imdl = mk_common_model('a2c0',4);
0079    covar = meas_icov_rm_elecs(imdl,1);
0080    unit_test_cmp('ire # 1', covar, zeros(size(covar))); 
0081 
0082    imdl = mk_common_model('a2c0',8);
0083    covar = meas_icov_rm_elecs(imdl,1);
0084    ff =    find( diag(covar)~= 1);
0085    ffcmp = [1;2;3;4;5;10;11;15;16;20;21;25;26;30;31;36;37;38;39;40];
0086    unit_test_cmp('ire # 2', ff,ffcmp);
0087 
0088    covar = meas_icov_rm_elecs(imdl.fwd_model,1);
0089    unit_test_cmp('ire # 3', ff,ffcmp);
0090 
0091    imdl.meas_icov_rm_elecs.elec_list = 1;
0092    covar = meas_icov_rm_elecs(imdl);
0093    unit_test_cmp('ire # 4', ff,ffcmp);
0094    ff =    find( diag(covar)~= 1);
0095 
0096    
0097    covar = meas_icov_rm_elecs(imdl,[1,2]);
0098    ff =    find( diag(covar)==1);
0099    ffcmp = [12;13;14;18;19;23;24;28;29;33;34;35];
0100    unit_test_cmp('ire # 5', ff,ffcmp);
0101 
0102    covar = meas_icov_rm_elecs(imdl,[1,2,3]);
0103    ff =    find( diag(covar)==1);
0104    ffcmp = [18;19;24;29;34;35];
0105    unit_test_cmp('ire # 6', ff,ffcmp);
0106 
0107    covar = meas_icov_rm_elecs(imdl,[1,2,3,4]);
0108    ff =    find( diag(covar)==1);
0109    ffcmp = [24;35];
0110    unit_test_cmp('ire # 7', ff,ffcmp);
0111 
0112 % NOW CHECK OTHER MODES
0113    imdl.meas_icov_rm_elecs.elec_list = 1:4;
0114    imdl.meas_icov_rm_elecs.exponent = 1;
0115    imdl.meas_icov_rm_elecs.SNR      = 0;
0116    covar=  diag( meas_icov_rm_elecs(imdl) );
0117    ffcmp = [24;35];
0118    unit_test_cmp('ire # 8', find(covar==1),ffcmp);
0119 
0120    imdl.meas_icov_rm_elecs.SNR      = 100;
0121    covar=  diag( meas_icov_rm_elecs(imdl) );
0122    unit_test_cmp('ire # 9', find(covar==1),ffcmp);
0123    ff =    find( covar~=1);
0124    unit_test_cmp('ire #10', covar(ff),1/100);
0125 
0126    imdl.meas_icov_rm_elecs.exponent = -1;
0127    covar=  diag( meas_icov_rm_elecs(imdl) );
0128    unit_test_cmp('ire #11', find(covar==1),ffcmp);
0129    ff =    find( covar~=1);
0130    unit_test_cmp('ire #12', covar(ff),100);
0131 
0132    imdl = mk_common_model('a2c0',8);
0133    imdl.meas_icov = spdiag((1:40)');
0134    covar=  diag( meas_icov_rm_elecs(imdl,[]) );
0135    unit_test_cmp('ire #13', covar,(1:40)');
0136 
0137    imdl.meas_icov_rm_elecs.replace_value = 0;
0138    covar=  diag( meas_icov_rm_elecs(imdl,[]) );
0139    unit_test_cmp('ire #14', covar,(1:40)');
0140 
0141    imdl.meas_icov_rm_elecs.replace_value = 1;
0142    covar=  diag( meas_icov_rm_elecs(imdl,[]) );
0143    unit_test_cmp('ire #15', covar,1);
0144

Generated on Fri 30-Dec-2022 19:44:54 by m2html © 2005