aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-02-08 16:19:35 -0800
committerThomas White <taw@physics.org>2013-02-08 16:19:35 -0800
commit0ad51536eb7a4d4bf13909cf50382cebb043f7a8 (patch)
tree82aa41e0e7c200296df9a8b01c0bfcbe6a1debf7
parent13116e93b01faee7826b5ba95a1dbf5fc3d64b45 (diff)
Count saturated peaks and record in the file
-rw-r--r--libcrystfel/src/image.h4
-rw-r--r--libcrystfel/src/peaks.c27
-rw-r--r--libcrystfel/src/stream.c2
3 files changed, 20 insertions, 13 deletions
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 8f9e296f..91950e76 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -94,6 +94,8 @@ typedef struct _imagefeaturelist ImageFeatureList;
* int width;
* int height;
*
+ * long long int num_peaks;
+ * long long int num_saturated_peaks;
* ImageFeatureList *features;
* };
* </programlisting>
@@ -144,6 +146,8 @@ struct image {
int height;
/* Detected peaks */
+ long long int num_peaks;
+ long long int num_saturated_peaks;
ImageFeatureList *features;
};
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c
index 54ba6468..cfd00d58 100644
--- a/libcrystfel/src/peaks.c
+++ b/libcrystfel/src/peaks.c
@@ -413,7 +413,7 @@ static void search_peaks_in_panel(struct image *image, float threshold,
int nrej_dis = 0;
int nrej_pro = 0;
int nrej_fra = 0;
- int nrej_bad = 0;
+ int nrej_fail = 0;
int nrej_snr = 0;
int nrej_sat = 0;
int nacc = 0;
@@ -438,9 +438,6 @@ static void search_peaks_in_panel(struct image *image, float threshold,
/* Overall threshold */
if ( data[fs+stride*ss] < threshold ) continue;
- /* Immediate rejection of pixels above max_adu */
- if ( data[fs+stride*ss] > p->max_adu ) continue;
-
/* Get gradients */
dx1 = data[fs+stride*ss] - data[(fs+1)+stride*ss];
dx2 = data[(fs-1)+stride*ss] - data[fs+stride*ss];
@@ -506,12 +503,11 @@ static void search_peaks_in_panel(struct image *image, float threshold,
/* Centroid peak and get better coordinates. */
r = integrate_peak(image, mask_fs, mask_ss,
&f_fs, &f_ss, &intensity, &sigma,
- ir_inn, ir_mid, ir_out, 0, NULL, &saturated);
+ ir_inn, ir_mid, ir_out, 1, NULL, &saturated);
- if ( r ) {
- /* Bad region - don't detect peak */
- nrej_bad++;
- continue;
+ if ( saturated ) {
+ image->num_saturated_peaks++;
+ if ( !use_saturated ) continue;
}
/* It is possible for the centroid to fall outside the image */
@@ -533,8 +529,9 @@ static void search_peaks_in_panel(struct image *image, float threshold,
continue;
}
- if ( saturated && !use_saturated ) {
- nrej_sat++;
+ if ( r ) {
+ /* Bad region - don't detect peak */
+ nrej_fail++;
continue;
}
@@ -555,10 +552,12 @@ 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 in bad regions, %i with SNR < %g, %i badrow culled, "
+ // "%i failed integration, %i with SNR < %g, %i badrow culled, "
// "%i saturated.\n",
- // nacc, nrej_dis, nrej_pro, nrej_fra, nrej_bad,
+ // nacc, nrej_dis, nrej_pro, nrej_fra, nrej_fail,
// nrej_snr, min_snr, ncull, nrej_sat);
if ( ncull != 0 ) {
@@ -579,6 +578,8 @@ void search_peaks(struct image *image, float threshold, float min_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++ ) {
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index a9e6a441..842c90b9 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -213,6 +213,8 @@ void write_chunk(Stream *st, struct image *i, struct hdfile *hdfile,
copy_hdf5_fields(hdfile, i->copyme, st->fh);
+ fprintf(st->fh, "num_peaks = %lli\n", i->num_peaks);
+ fprintf(st->fh, "num_saturated_peaks = %lli\n", i->num_saturated_peaks);
if ( include_peaks ) {
write_peaks(i, st->fh);
}