num_elecs

PURPOSE ^

NUM_ELECS: number of electrodes attached to model

SYNOPSIS ^

function num = num_elecs( mdl );

DESCRIPTION ^

 NUM_ELECS: number of electrodes attached to model
 num_elecs = num_elecs( mdl );

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function num = num_elecs( mdl );
0002 % NUM_ELECS: number of electrodes attached to model
0003 % num_elecs = num_elecs( mdl );
0004 
0005 % $Id: num_elecs.m 5112 2015-06-14 13:00:41Z aadler $
0006 
0007 if ischar(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0008 
0009 if ~isfield(mdl,'type') && isfield(mdl,'elems') % Set default for this case
0010    mdl.type = 'fwd_model';
0011 end
0012 
0013 switch mdl.type
0014   case 'image';      fmdl = mdl.fwd_model;
0015   case 'inv_model';  fmdl = mdl.fwd_model;
0016   case 'fwd_model';  fmdl = mdl;
0017   otherwise;
0018       error('can''t process model of type %s', mdl.type );
0019 end
0020 
0021 if isfield(fmdl,'electrode')
0022    num = length(fmdl.electrode);
0023 else 
0024    num = 0;
0025 end
0026 
0027 
0028 function do_unit_test
0029    mdl = mk_common_model('a2c2',8);
0030    ne = num_elecs( mdl );
0031    unit_test_cmp('test1', ne, 8);
0032 
0033    ne = num_elecs( mdl.fwd_model );
0034    unit_test_cmp('test2', ne, 8);
0035 
0036    ne = num_elecs( mk_image( mdl ));
0037    unit_test_cmp('test3', ne, 8);
0038 
0039    mdl.fwd_model.electrode = struct([]);
0040    ne = num_elecs( mdl );
0041    unit_test_cmp('test4', ne, 0);
0042 
0043    mdl.fwd_model = rmfield(mdl.fwd_model,'electrode');
0044    ne = num_elecs( mdl );
0045    unit_test_cmp('test5', ne, 0);
0046 
0047    mdl = mk_common_model('n3r2',[16,2]);
0048    ne = num_elecs( mk_image( mdl ));
0049    unit_test_cmp('test6', ne, 32);

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005