2 ***********************************************************
3 $SNARK_Header: S N A R K 1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4 $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/read_eval_recon3.c $
5 $LastChangedRevision: 92 $
6 $Date: 2014-07-02 17:46:48 -0400 (Wed, 02 Jul 2014) $
8 ***********************************************************
10 Previously part of SuperSNARK
16 #include "experimenter.h"
18 #include "read_eval_recon3.h"
20 /* ----------------------------- read_eval_recon1.c ----------------------
22 This function reads from the eval file the variance for
23 all the structures in a reconstruction.
26 iter - iteration number
27 keywrd - keyword which defines the algorithm whose reconstruction is
29 numstr - number of structures in reconstruction.
32 recon - array of length numstr containing the variance for each
33 structure in the reconstruction.
36 void read_eval_recon3(int iter, char* keywrd, int numstr, double* recon)
39 double average, dist, rel_err, variance;
40 char string[MAXLINESIZE], iter_text[MAXLINESIZE], test[MAXLINESIZE];
43 /* convert iteration number to a string */
44 sprintf(iter_text, "%d", iter);
46 if ((evalfile = fopen("eval", "r")) == NULL)
48 errorc("in read_eval_recon1.c: error in opening file ", "eval");
53 /* Read eval file until a line which contains the string
54 'execution name' is reached. If this line contains the
55 keyword break out of the while loop. If end of file is
56 reached then keyword was not found so terminate program. */
58 fgets(string, sizeof(string), evalfile);
59 if (strstr(string, "execution name") != NULL)
61 sscanf(string, "%*s%*s %s", test);
62 if (strncasecmp(test, keywrd, 4) == 0)
69 sprintf(string, "Error in read_eval_recon1.c: keyword %s not found in file", keywrd);
70 errorc(string, " eval");
76 /* Continue reading eval file until a line which contains
77 the string 'Metrics for algorithm' is reached. If this
78 line contains the string 'iteration' and the required
79 iteration number break out of the while loop. If end
80 of file is reached then the appropriate string was
81 not found so print error message and exit */
83 fgets(string, sizeof(string), evalfile);
84 if ((strstr(string, "metrics for algorithm") != NULL)
85 && // changed "m" in "metrics for algorithm" to lowercase. Lajos, Dec 16, 2004
86 (strstr(string, iter_text) != NULL)
87 && (strstr(string, "iteration") != NULL))
94 sprintf(string, "Error in read_eval_recon1.c: %s ---> iteration %d not found in", keywrd, iter);
95 errorc(string, " eval");
101 /* Continue reading eval file until a line of numbers is
102 reached then break out of while loop. Terminate program
103 if end of file is reached */
105 fgets(string, sizeof(string), evalfile);
106 if (sscanf(string, "%d %d %lf %lf %lf %lf", ®, &area, &average, &dist, &rel_err, &variance) == 6)
114 errorc("Error in read_eval_recon1.c: end of file reached in file ", "eval");
117 /* this is the variance of the first structure
118 in the reconstruction */
121 /* now read in the abnormality index for the remaining
124 for (i = 1; i < numstr; i++)
126 fgets(string, sizeof(string), evalfile);
127 sscanf(string, "%d %d %lf %lf %lf %lf", ®, &area, &average, &dist, &rel_err, &variance);
131 fclose(evalfile); /* close eval file */