0001 function num = num_nodes( mdl );
0002
0003
0004
0005
0006
0007 if isstr(mdl) && strcmp(mdl,'UNIT_TEST'); do_unit_test; return; end
0008
0009 switch mdl.type
0010 case 'image'; fmdl = mdl.fwd_model;
0011 case 'inv_model'; fmdl = mdl.fwd_model;
0012 case 'fwd_model'; fmdl = mdl;
0013 otherwise;
0014 error('can''t process model of type %s', mdl.type );
0015 end
0016
0017 num = size(fmdl.nodes,1);
0018
0019 function do_unit_test
0020 mdl = mk_common_model('a2c2',8);
0021 ne = num_nodes( mdl );
0022 ok='fail'; if ne==41; ok='ok'; end; fprintf('test1: %10s\n',ok);
0023
0024 ne = num_nodes( mdl.fwd_model );
0025 ok='fail'; if ne==41; ok='ok'; end; fprintf('test2: %10s\n',ok);
0026
0027 ne = num_nodes( mk_image( mdl ));
0028 ok='fail'; if ne==41; ok='ok'; end; fprintf('test3: %10s\n',ok);
0029
0030 mdl = mk_common_model('n3r2',16);
0031 ne = num_nodes( mk_image( mdl ));
0032 ok='fail'; if ne==252; ok='ok'; end; fprintf('test4: %10s\n',ok);