From 772ed44b99c2429ac9bcaab327583e92464e2fd5 Mon Sep 17 00:00:00 2001 From: Valerio Mariani Date: Fri, 10 Mar 2017 14:29:55 +0100 Subject: Peakfinder8 in CrystFEL. Same results as Anton's Cheetah implementation --- src/indexamajig.c | 87 ++++++++++++++++++++++++++++++++++++++++++----------- src/process_image.c | 23 +++++++++++++- src/process_image.h | 12 ++++++-- 3 files changed, 102 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/indexamajig.c b/src/indexamajig.c index a1997b9e..ed66f803 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -13,6 +13,7 @@ * 2011 Richard Kirian * 2012 Lorenzo Galli * 2012 Chunhong Yoon + * 2017 Valerio Mariani * * This file is part of CrystFEL. * @@ -88,6 +89,7 @@ static void show_help(const char *s) " --peaks= Use 'method' for finding peaks. Choose from:\n" " zaef : Use Zaefferer (2000) gradient detection.\n" " This is the default method.\n" +" peakfinder8: Use Peakfinder8 algorithm.\n" " hdf5 : Get from a table in HDF5 file.\n" " cxi : Get from CXI format HDF5 file.\n" " --hdf5-peaks=

Find peaks table in HDF5 file here.\n" @@ -95,23 +97,42 @@ static void show_help(const char *s) " --integration= Perform final pattern integration using .\n" "\n\n" "For more control over the process, you might need:\n\n" -" --tolerance= Set the tolerances for cell comparison.\n" -" Default: 5,5,5,1.5.\n" -" --filter-noise Apply an aggressive noise filter which sets all\n" -" pixels in each 3x3 region to zero if any of them\n" -" have negative values. Intensity measurement will\n" -" be performed on the image as it was before this.\n" -" --median-filter= Apply a median filter to the image data. Intensity\n" -" measurement will be performed on the image as it\n" -" was before this. The side length of the median\n" -" filter box will be 2+1. Default: 0 (no filter).\n" -" --no-sat-corr Don't correct values of saturated peaks using a\n" -" table included in the HDF5 file.\n" -" --threshold= Only accept peaks above ADU. Default: 800.\n" -" --min-gradient= Minimum squared gradient for Zaefferer peak search.\n" -" Default: 100,000.\n" -" --min-snr= Minimum signal-to-noise ratio for peaks.\n" -" Default: 5.\n" +" --tolerance= Set the tolerances for cell comparison.\n" +" Default: 5,5,5,1.5.\n" +" --filter-noise Apply an aggressive noise filter which sets all\n" +" pixels in each 3x3 region to zero if any of them\n" +" have negative values. Intensity measurement will\n" +" be performed on the image as it was before this.\n" +" --median-filter= Apply a median filter to the image data. Intensity\n" +" measurement will be performed on the image as it\n" +" was before this. The side length of the median\n" +" filter box will be 2+1.\n" +" Default: 0 (no filter).\n" +" --no-sat-corr Don't correct values of saturated peaks using a\n" +" table included in the HDF5 file.\n" +" --threshold= Only accept peaks above ADU in both the\n" +" Zaefferer and Peakfinder8 algorithms." +" Default: 800.\n" +" --min-gradient= Minimum squared gradient for Zaefferer peak\n" +" search. Default: 100,000.\n" +" --min-snr= Minimum signal-to-noise ratio for peaks, with both" +" Zaefferer and Peakfinder8 algorithms.\n" +" Default: 5.\n" +" --min-pix-count= Only accept peaks if they include more than " +" pixels, in the Peakfinder8 algorithm." +" Default: 2.\n" +" --max-pix-count= Only accept peaks if they include less than " +" pixels, in the Peakfinder8 algorithm." +" Default: 200.\n" +" --local-bg-radius= Radius (in pixels) to use for the estimation of\n" +" local background in the Peakfinder8 algorithm.\n" +" Default: 3.\n" +" --min-res= Only accept peaks if they lay at more than \n" +" pixels from the center of the detector, int the\n" +" peakfinder8 algorithm. Default: 0.\n" +" --max-res= Only accept peaks if they lay at less than \n" +" pixels from the center of the detector, int the\n" +" peakfinder8 algorithm. Default: 1200.\n" " --check-hdf5-snr Check SNR for peaks from --peaks=hdf5.\n" " --peak-radius= Integration radii for peak search.\n" " --int-radius= Set the integration radii. Default: 4,5,7.\n" @@ -214,6 +235,11 @@ int main(int argc, char *argv[]) iargs.threshold = 800.0; iargs.min_gradient = 100000.0; iargs.min_snr = 5.0; + iargs.min_pix_count = 2; + iargs.min_pix_count = 200; + iargs.min_res = 0; + iargs.max_res = 1200; + iargs.local_bg_radius = 3; iargs.check_hdf5_snr = 0; iargs.det = NULL; iargs.peaks = PEAK_ZAEF; @@ -306,6 +332,11 @@ int main(int argc, char *argv[]) {"fix-bandwidth", 1, NULL, 23}, {"fix-divergence", 1, NULL, 24}, {"felix-options", 1, NULL, 25}, + {"min-pix-count", 1, NULL, 26}, + {"max-pix-count", 1, NULL, 27}, + {"local-bg-radius", 1, NULL, 28}, + {"min-res", 1, NULL, 29}, + {"max-res", 1, NULL, 30}, {0, 0, NULL, 0} }; @@ -489,6 +520,26 @@ int main(int argc, char *argv[]) } break; + case 26: + iargs.min_pix_count = atoi(optarg); + break; + + case 27: + iargs.max_pix_count = atoi(optarg); + break; + + case 28: + iargs.local_bg_radius = atoi(optarg); + break; + + case 29: + iargs.min_res = atoi(optarg); + break; + + case 30: + iargs.max_res = atoi(optarg); + break; + case 0 : break; @@ -541,6 +592,8 @@ int main(int argc, char *argv[]) } if ( strcmp(speaks, "zaef") == 0 ) { iargs.peaks = PEAK_ZAEF; + } else if ( strcmp(speaks, "peakfinder8") == 0 ) { + iargs.peaks = PEAK_PEAKFINDER8; } else if ( strcmp(speaks, "hdf5") == 0 ) { iargs.peaks = PEAK_HDF5; } else if ( strcmp(speaks, "cxi") == 0 ) { diff --git a/src/process_image.c b/src/process_image.c index bcaee543..1d7b82e4 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -8,7 +8,7 @@ * * Authors: * 2010-2017 Thomas White - * 2014 Valerio Mariani + * 2014-2017 Valerio Mariani * * This file is part of CrystFEL. * @@ -191,6 +191,27 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, iargs->use_saturated); break; + case PEAK_PEAKFINDER8: + if ( search_peaks_peakfinder8(&image, 2048, + iargs->threshold, + iargs->min_snr, + iargs->min_pix_count, + iargs->max_pix_count, + iargs->local_bg_radius, + iargs->min_res, + iargs->max_res) ) { + if ( image.event != NULL ) { + ERROR("Failed to find peaks in image %s" + "(event %s).\n", image.filename, + get_event_string(image.event)); + } else { + ERROR("Failed to find peaks in image %s.", + image.filename); + } + + } + break; + } restore_image_data(image.dp, image.det, prefilter); diff --git a/src/process_image.h b/src/process_image.h index d41c23f5..4c5c5a96 100644 --- a/src/process_image.h +++ b/src/process_image.h @@ -3,12 +3,12 @@ * * The processing pipeline for one image * - * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY, + * Copyright © 2012-2017 Deutsches Elektronen-Synchrotron DESY, * a research centre of the Helmholtz Association. * * Authors: * 2010-2016 Thomas White - * 2014 Valerio Mariani + * 2014-2017 Valerio Mariani * * This file is part of CrystFEL. * @@ -42,6 +42,7 @@ struct index_args; enum { + PEAK_PEAKFINDER8, PEAK_ZAEF, PEAK_HDF5, PEAK_CXI, @@ -73,6 +74,13 @@ struct index_args float ir_inn; float ir_mid; float ir_out; + int iterations; + int min_res; + int max_res; + int max_n_peaks; + int min_pix_count; + int max_pix_count; + int local_bg_radius; struct copy_hdf5_field *copyme; int integrate_saturated; int use_saturated; -- cgit v1.2.3 From de2237fc3f193e4f4916e3bc9268e52378fad939 Mon Sep 17 00:00:00 2001 From: Valerio Mariani Date: Fri, 10 Mar 2017 20:04:25 +0100 Subject: Fixed a couple of bugs reported by Tom --- src/indexamajig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/indexamajig.c b/src/indexamajig.c index ed66f803..ef803931 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -236,7 +236,7 @@ int main(int argc, char *argv[]) iargs.min_gradient = 100000.0; iargs.min_snr = 5.0; iargs.min_pix_count = 2; - iargs.min_pix_count = 200; + iargs.max_pix_count = 200; iargs.min_res = 0; iargs.max_res = 1200; iargs.local_bg_radius = 3; -- cgit v1.2.3 From 173fe22faba8c101e723b5c865fa0c5dd822ce78 Mon Sep 17 00:00:00 2001 From: Valerio Mariani Date: Sat, 11 Mar 2017 02:00:56 +0100 Subject: Removed unused iarg --- src/process_image.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/process_image.h b/src/process_image.h index 4c5c5a96..2ac48b83 100644 --- a/src/process_image.h +++ b/src/process_image.h @@ -74,7 +74,6 @@ struct index_args float ir_inn; float ir_mid; float ir_out; - int iterations; int min_res; int max_res; int max_n_peaks; -- cgit v1.2.3 From b2de09452e8edf050a8679e726f5075abd37e961 Mon Sep 17 00:00:00 2001 From: Valerio Mariani Date: Mon, 13 Mar 2017 11:17:57 +0100 Subject: Added saturated peak management to peakfinder8 --- src/process_image.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/process_image.c b/src/process_image.c index 1d7b82e4..d54e5a79 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -199,7 +199,8 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, iargs->max_pix_count, iargs->local_bg_radius, iargs->min_res, - iargs->max_res) ) { + iargs->max_res, + iargs->use_saturated) ) { if ( image.event != NULL ) { ERROR("Failed to find peaks in image %s" "(event %s).\n", image.filename, -- cgit v1.2.3