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/hit_ratio.c $
5 $LastChangedRevision: 80 $
6 $Date: 2014-07-01 21:01:54 -0400 (Tue, 01 Jul 2014) $
8 ***********************************************************
10 Previously part of SuperSNARK
14 #include "experimenter.h"
15 #include "read_eval_phantom1.h"
16 #include "read_eval_recon1.h"
17 #include "hit_ratio.h"
19 /* ----------------------------- hit_ratio.c -------------------------------
21 This function computes the hit-ratio.
24 itr1 - array of length niters containing the iteration numbers for the
26 itr2 - array of length niters containing the iteration numbers for the
28 niters - number of iterations to be compared.
29 pairs - array of length numpairs containing the indices of the structures
31 numpairs - number of pairs of structures.
32 keywrd1 - string containing the keyword which defines the first algorithm.
33 keywrd2 - string containing the keyword which defines the second algorithm.
36 hit_ratio1 - array of length niters containing the hit ratio for
38 hit_ratio2 - array of length niters containing the hit ratio for
43 void hit_ratio(int* itr1, int* itr2, int niters, int* pairs, int numpairs,
44 char* keywrd1, char* keywrd2, double* hit_ratio1, double* hit_ratio2)
46 double *phantom, *recon1, *recon2;
47 int *regions, numstr, i, j, hit1, hit2, *strarea;
49 /* read in abnormality index for phantom structures */
51 read_eval_phantom1(®ions, &numstr, &phantom, &strarea);
53 /* allocate memory to store abnormality indexes for
54 structures in the reconstructions*/
56 recon1 = (double *) malloc(numstr * sizeof(double));
57 recon2 = (double *) malloc(numstr * sizeof(double));
59 for (i = 0; i < niters; i++)
60 { /* read in abnormality indexes for structures in
61 the reconstructions. Initialize the arrays
62 which will store the structural accuracy */
64 read_eval_recon1(&itr1[i], keywrd1, numstr, recon1);
65 read_eval_recon1(&itr2[i], keywrd2, numstr, recon2);
69 for (j = 0; j < numpairs * 2; j += 2)
70 { /* compute hit-ratio for both algorithms */
72 hit1 = (phantom[pairs[j] - 1] > phantom[pairs[j + 1] - 1])
73 == (recon1[pairs[j] - 1] > recon1[pairs[j + 1] - 1]);
74 hit2 = (phantom[pairs[j] - 1] > phantom[pairs[j + 1] - 1])
75 == (recon2[pairs[j] - 1] > recon2[pairs[j + 1] - 1]);
77 hit_ratio1[i] = hit_ratio1[i] + hit1;
78 hit_ratio2[i] = hit_ratio2[i] + hit2;
80 hit_ratio1[i] = hit_ratio1[i] / numpairs; /* hit */
81 hit_ratio2[i] = hit_ratio2[i] / numpairs; /* ratio */
84 free(phantom); /* free memory for next function call */