diff options
-rw-r--r-- | examples/lcls-dec.geom | 2 | ||||
-rw-r--r-- | examples/lcls-june.geom | 2 | ||||
-rw-r--r-- | src/detector.c | 8 | ||||
-rw-r--r-- | src/detector.h | 1 | ||||
-rw-r--r-- | src/peaks.c | 67 |
5 files changed, 68 insertions, 12 deletions
diff --git a/examples/lcls-dec.geom b/examples/lcls-dec.geom index 398ba66f..7403f004 100644 --- a/examples/lcls-dec.geom +++ b/examples/lcls-dec.geom @@ -9,6 +9,7 @@ n_panels = 2 0/cy = 440.7 0/clen = 67.8e-3 0/res = 13333.3 ; 75 micron pixel size +0/badrow_direction = y ; Lower panel 1/min_x = 0 @@ -19,3 +20,4 @@ n_panels = 2 1/cy = 779.7 1/clen = 70.8e-3 1/res = 13333.3 ; 75 micron pixel size +1/badrow_direction = y diff --git a/examples/lcls-june.geom b/examples/lcls-june.geom index f4ac79af..315fb504 100644 --- a/examples/lcls-june.geom +++ b/examples/lcls-june.geom @@ -9,6 +9,7 @@ n_panels = 2 0/cy = 512.0 0/clen = 66.0e-3 0/res = 13333.3 ; 75 micron pixel size +0/badrow_direction = x ; Lower panel (found to the "left" in the HDF5, furthest from the beam) 1/min_x = 0 @@ -19,3 +20,4 @@ n_panels = 2 1/cy = 512.0 1/clen = 69.0e-3 1/res = 13333.3 ; 75 micron pixel size +1/badrow_direction = x diff --git a/src/detector.c b/src/detector.c index 55e9ec87..dcc5830d 100644 --- a/src/detector.c +++ b/src/detector.c @@ -248,6 +248,14 @@ struct detector *get_detector_geometry(const char *filename) det->panels[np].clen = atof(bits[2]); } else if ( strcmp(path[1], "res") == 0 ) { det->panels[np].res = atof(bits[2]); + } else if ( strcmp(path[1], "badrow_direction") == 0 ) { + det->panels[np].badrow = bits[2][0]; + if ( (det->panels[np].badrow != 'x') + && (det->panels[np].badrow != 'y') ) { + ERROR("badrow_direction must be 'x' or 'y'\n"); + ERROR("Assuming 'x'\n."); + det->panels[np].badrow = 'x'; + } } else { ERROR("Unrecognised field '%s'\n", path[1]); } diff --git a/src/detector.h b/src/detector.h index 057b70a8..92e10458 100644 --- a/src/detector.h +++ b/src/detector.h @@ -30,6 +30,7 @@ struct panel float cy; float clen; /* Camera length */ float res; /* Resolution */ + char badrow; /* 'x' or 'y' */ }; struct detector diff --git a/src/peaks.c b/src/peaks.c index a2ebeee7..161179df 100644 --- a/src/peaks.c +++ b/src/peaks.c @@ -82,8 +82,7 @@ static int is_hot_pixel(struct image *image, int x, int y) } -/* Post-processing of the peak list to remove noise */ -static void cull_peaks(struct image *image) +static int cull_peaks_in_panel(struct image *image, struct panel *p) { int i, n; int nelim = 0; @@ -98,7 +97,12 @@ static void cull_peaks(struct image *image) f = image_get_feature(image->features, i); if ( f == NULL ) continue; - /* How many peaks are in exactly the same column? */ + if ( f->x < p->min_x ) continue; + if ( f->x > p->max_x ) continue; + if ( f->y < p->min_y ) continue; + if ( f->y > p->max_y ) continue; + + /* How many peaks are in the same column? */ ncol = 0; for ( j=0; j<n; j++ ) { @@ -108,7 +112,15 @@ static void cull_peaks(struct image *image) g = image_get_feature(image->features, j); if ( g == NULL ) continue; - if ( fabs(f->y - g->y) < 2.0 ) ncol++; + + if ( p->badrow == 'x' ) { + if ( fabs(f->y - g->y) < 2.0 ) ncol++; + } else if ( p->badrow == 'y' ) { + if ( fabs(f->x - g->x) < 2.0 ) ncol++; + } else { + ERROR("Invalid badrow direction.\n"); + abort(); + } } @@ -121,15 +133,44 @@ static void cull_peaks(struct image *image) struct imagefeature *g; g = image_get_feature(image->features, j); if ( g == NULL ) continue; - if ( fabs(f->y - g->y) < 2.0 ) { - image_remove_feature(image->features, j); - nelim++; + if ( p->badrow == 'x' ) { + if ( fabs(f->y - g->y) < 2.0 ) { + image_remove_feature(image->features, + j); + nelim++; + } + } else if ( p->badrow == 'y' ) { + if ( fabs(f->x - g->x) < 2.0 ) { + image_remove_feature(image->features, + j); + nelim++; + } + } else { + ERROR("Invalid badrow direction.\n"); + abort(); } + } } - //STATUS("%i peaks eliminated\n", nelim); + return nelim; +} + + +/* Post-processing of the peak list to remove noise */ +static int cull_peaks(struct image *image) +{ + int nelim = 0; + struct panel *p; + int i; + + for ( i=0; i<image->det->n_panels; i++ ) { + p = &image->det->panels[i]; + nelim += cull_peaks_in_panel(image, p); + } + + return nelim; } @@ -247,6 +288,7 @@ void search_peaks(struct image *image) int nrej_fra = 0; int nrej_bad = 0; int nacc = 0; + int ncull; data = image->data; width = image->width; @@ -371,11 +413,12 @@ void search_peaks(struct image *image) } } - STATUS("%i accepted, %i box, %i hot, %i proximity, %i outside frame, " - "%i in bad regions.\n", - nacc, nrej_dis, nrej_hot, nrej_pro, nrej_fra, nrej_bad); + ncull = cull_peaks(image); + nacc -= ncull; - cull_peaks(image); + STATUS("%i accepted, %i box, %i hot, %i proximity, %i outside frame, " + "%i in bad regions, %i badrow culled.\n", + nacc, nrej_dis, nrej_hot, nrej_pro, nrej_fra, nrej_bad, ncull); } |