0001 function num = mdl_dim( mdl );
0002
0003
0004
0005
0006
0007
0008
0009
0010 if ischar(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0011
0012 if ~isfield(mdl,'type') && isfield(mdl,'nodes')
0013 mdl.type = 'fwd_model';
0014 end
0015
0016 switch mdl(1).type
0017 case 'image'; fmdl = mdl.fwd_model;
0018 case 'inv_model'; fmdl = mdl.fwd_model;
0019 case 'fwd_model'; fmdl = mdl;
0020 otherwise;
0021 error('can''t process model of type %s', mdl.type );
0022 end
0023
0024 num = size(fmdl.nodes,2);
0025
0026 function do_unit_test
0027 mdl = mk_common_model('a2c2',8);
0028 ne = mdl_dim( mdl );
0029 unit_test_cmp('test1', ne, 2);
0030
0031 mdl = mk_common_model('n3r2',[16,2]);
0032 ne = mdl_dim( mk_image( mdl ));
0033 unit_test_cmp('test1', ne, 3);
0034