aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-05-08 14:37:27 +0200
committerThomas White <taw@physics.org>2019-05-14 10:02:50 +0200
commit636eb6116961296791bae35c40fd9438aa946827 (patch)
treeb195c2c1e897d7d4c778a60bd81bd231819f70a7
parent59770f9bffbd47de5b518244a6dfcfbdfc8dad09 (diff)
Remove image.num_peaks and num_saturated_peaks
These values were inconsistently set by different parts of the code, e.g. different peak search methods. num_saturated_peaks was even set during final integration. Now, the peak count is taken from the ImageFeatureList, so it's authoritative.
-rw-r--r--libcrystfel/src/hdf5-file.c6
-rw-r--r--libcrystfel/src/image.h6
-rw-r--r--libcrystfel/src/integration.c3
-rw-r--r--libcrystfel/src/peakfinder8.c2
-rw-r--r--libcrystfel/src/peaks.c17
-rw-r--r--libcrystfel/src/stream.c8
-rw-r--r--src/partial_sim.c2
7 files changed, 5 insertions, 39 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index 7aa8165d..ff96adb1 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -396,8 +396,6 @@ int get_peaks_cxi_2(struct image *image, struct hdfile *f, const char *p,
}
image->features = image_feature_list_new();
- image->num_peaks = 0;
- image->num_saturated_peaks = 0;
for ( pk=0; pk<num_peaks; pk++ ) {
float fs, ss, val;
@@ -416,7 +414,6 @@ int get_peaks_cxi_2(struct image *image, struct hdfile *f, const char *p,
ss = ss - p->orig_min_ss;
image_add_feature(image->features, fs, ss, p, image, val, NULL);
- image->num_peaks++;
}
@@ -542,8 +539,6 @@ int get_peaks_2(struct image *image, struct hdfile *f, const char *p,
}
image->features = image_feature_list_new();
- image->num_peaks = 0;
- image->num_saturated_peaks = 0;
for ( i=0; i<size[0]; i++ ) {
float fs, ss, val;
@@ -563,7 +558,6 @@ int get_peaks_2(struct image *image, struct hdfile *f, const char *p,
image_add_feature(image->features, fs, ss, p, image, val,
NULL);
- image->num_peaks++;
}
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 98cac12c..56f07132 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -203,12 +203,8 @@ struct image
/** Full-width half-maximum bandwidth as a fraction, applied to wavelength */
double bw;
- /** \name Numbers of peaks. To be deleted.
- * @{ */
- long long num_peaks;
- long long num_saturated_peaks;
+ /** Resolution estimate based on peaks */
double peak_resolution;
- /** @} */
/** List of peaks found in the image */
ImageFeatureList *features;
diff --git a/libcrystfel/src/integration.c b/libcrystfel/src/integration.c
index d9636d9f..5270816b 100644
--- a/libcrystfel/src/integration.c
+++ b/libcrystfel/src/integration.c
@@ -1355,7 +1355,6 @@ static void integrate_prof2d(IntegrationMethod meth,
UnitCell *cell;
struct intcontext ic;
int i;
- int n_saturated = 0;
list = crystal_get_reflections(cr);
cell = crystal_get_cell(cr);
@@ -1397,8 +1396,6 @@ static void integrate_prof2d(IntegrationMethod meth,
}
free_intcontext(&ic);
-
- image->num_saturated_peaks = n_saturated;
}
diff --git a/libcrystfel/src/peakfinder8.c b/libcrystfel/src/peakfinder8.c
index 2c67a484..30082580 100644
--- a/libcrystfel/src/peakfinder8.c
+++ b/libcrystfel/src/peakfinder8.c
@@ -1196,9 +1196,7 @@ int peakfinder8(struct image *img, int max_n_peaks,
p = &img->det->panels[pi];
- img->num_peaks += 1;
if ( pkdata->max_i[pki] > p->max_adu ) {
- img->num_saturated_peaks++;
if ( !use_saturated ) {
continue;
}
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c
index a45a51af..1af901e0 100644
--- a/libcrystfel/src/peaks.c
+++ b/libcrystfel/src/peaks.c
@@ -485,12 +485,9 @@ static void search_peaks_in_panel(struct image *image, float threshold,
continue;
}
- if ( saturated ) {
- image->num_saturated_peaks++;
- if ( !use_saturated ) {
- nrej_sat++;
- continue;
- }
+ if ( saturated && !use_saturated ) {
+ nrej_sat++;
+ continue;
}
/* Add using "better" coordinates */
@@ -510,8 +507,6 @@ static void search_peaks_in_panel(struct image *image, float threshold,
ncull = 0;
}
- image->num_peaks += nacc;
-
//STATUS("%i accepted, %i box, %i proximity, %i outside panel, "
// "%i failed integration, %i with SNR < %g, %i badrow culled, "
// "%i saturated.\n",
@@ -536,8 +531,6 @@ void search_peaks(struct image *image, float threshold, float min_sq_gradient,
image_feature_list_free(image->features);
}
image->features = image_feature_list_new();
- image->num_peaks = 0;
- image->num_saturated_peaks = 0;
for ( i=0; i<image->det->n_panels; i++ ) {
@@ -577,8 +570,6 @@ int search_peaks_peakfinder8(struct image *image, int max_n_peaks,
image_feature_list_free(image->features);
}
image->features = image_feature_list_new();
- image->num_peaks = 0;
- image->num_saturated_peaks = 0;
return peakfinder8(image, max_n_peaks, threshold, min_snr,
min_pix_count, max_pix_count,
@@ -810,8 +801,6 @@ void validate_peaks(struct image *image, double min_snr,
// n, image_feature_count(flist), n_wtf, n_int, n_snr, n_sat);
image_feature_list_free(image->features);
image->features = flist;
- image->num_saturated_peaks = n_sat;
- image->num_peaks = image_feature_count(flist);
}
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index 5aac2eab..6b8f3565 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -897,8 +897,7 @@ int write_chunk(Stream *st, struct image *i, struct imagefile *imfile,
}
- fprintf(st->fh, "num_peaks = %lli\n", i->num_peaks);
- fprintf(st->fh, "num_saturated_peaks = %lli\n", i->num_saturated_peaks);
+ fprintf(st->fh, "num_peaks = %i\n", image_feature_count(i->features));
fprintf(st->fh, "peak_resolution = %f nm^-1 or %f A\n",
i->peak_resolution/1e9, 1e10/i->peak_resolution);
if ( include_peaks ) {
@@ -1218,7 +1217,6 @@ int read_chunk_2(Stream *st, struct image *image, StreamReadFlags srf)
}
do {
- long long num_peaks;
int ser;
float div, bw;
@@ -1263,10 +1261,6 @@ int read_chunk_2(Stream *st, struct image *image, StreamReadFlags srf)
image->bw = bw;
}
- if ( sscanf(line, "num_peaks = %lld", &num_peaks) == 1 ) {
- image->num_peaks = num_peaks;
- }
-
if ( sscanf(line, "Image serial number: %i", &ser) == 1 ) {
image->serial = ser;
}
diff --git a/src/partial_sim.c b/src/partial_sim.c
index 012b0a59..92f9703c 100644
--- a/src/partial_sim.c
+++ b/src/partial_sim.c
@@ -841,8 +841,6 @@ int main(int argc, char *argv[])
image.crystals = NULL;
image.n_crystals = 0;
image.indexed_by = INDEXING_SIMULATION;
- image.num_peaks = 0;
- image.num_saturated_peaks = 0;
image.spectrum_size = 0;
image.spectrum0 = NULL;
image.serial = 0;