From 636eb6116961296791bae35c40fd9438aa946827 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 8 May 2019 14:37:27 +0200 Subject: 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. --- libcrystfel/src/hdf5-file.c | 6 ------ libcrystfel/src/image.h | 6 +----- libcrystfel/src/integration.c | 3 --- libcrystfel/src/peakfinder8.c | 2 -- libcrystfel/src/peaks.c | 17 +++-------------- libcrystfel/src/stream.c | 8 +------- 6 files changed, 5 insertions(+), 37 deletions(-) (limited to 'libcrystfel') 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; pkorig_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; ifeatures, 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; idet->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; } -- cgit v1.2.3