aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-05-24 10:30:14 +0200
committerThomas White <taw@physics.org>2018-05-24 15:21:18 +0200
commitc1be9fab0693fb4e51755ea83954e6cf4c65f7f0 (patch)
tree7c2ccb89ba2b4bbaad4925b4adbfa6db205930c0 /libcrystfel
parent8f99dad3c42ab08d631b1ac02b195b33944c7240 (diff)
Formatting
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/peaks.c174
-rw-r--r--libcrystfel/src/peaks.h10
2 files changed, 95 insertions, 89 deletions
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c
index 7f6e0ba7..571f79ae 100644
--- a/libcrystfel/src/peaks.c
+++ b/libcrystfel/src/peaks.c
@@ -575,97 +575,101 @@ int search_peaks_peakfinder8(struct image *image, int max_n_peaks,
#include "fastDiffractionImageProcessing/detectorRawFormat.h" //debug, only for eclipse
int search_peaks_peakfinder9(struct image *image, float sig_fac_biggest_pix,
- float sig_fac_peak_pix, float sig_fac_whole_peak, float min_sig,
- float min_peak_over_neighbour, int window_radius)
+ float sig_fac_peak_pix, float sig_fac_whole_peak,
+ float min_sig, float min_peak_over_neighbour,
+ int window_radius)
{
- if (image->features != NULL) {
- image_feature_list_free(image->features);
- }
- image->features = image_feature_list_new();
- image->num_peaks = 0;
- image->num_saturated_peaks = 0;
-
- peakFinder9_accuracyConstants_t accuracy_consts;
- accuracy_consts.sigmaFactorBiggestPixel = sig_fac_biggest_pix;
- accuracy_consts.sigmaFactorPeakPixel = sig_fac_peak_pix;
- accuracy_consts.sigmaFactorWholePeak = sig_fac_whole_peak;
- accuracy_consts.minimumSigma = min_sig;
- accuracy_consts.minimumPeakOversizeOverNeighbours =
- min_peak_over_neighbour;
- accuracy_consts.windowRadius = (unsigned int) window_radius;
-
- long NpeaksMax = 10000; //more peaks per panel should not appear
-
- float *data_copy = NULL, *data_copy_new;
- peakList_t peakList;
- if (allocatePeakList(&peakList, NpeaksMax)) {
- return 1;
- }
-
- for (int panel_number = 0; panel_number < image->det->n_panels;
- panel_number++) {
-
- if (image->det->panels[panel_number].no_index)
- continue;
-
- int w = image->det->panels[panel_number].w;
- int h = image->det->panels[panel_number].h;
-
- detectorRawFormat_t det_size_one_panel;
- det_size_one_panel.asic_nx = w;
- det_size_one_panel.asic_ny = h;
- det_size_one_panel.nasics_x = 1;
- det_size_one_panel.nasics_y = 1;
- det_size_one_panel.pix_nx = w;
- det_size_one_panel.pix_ny = h;
- det_size_one_panel.pix_nn = w * h;
-
- data_copy_new = (float*) realloc(data_copy,
- w * h * sizeof(*data_copy));
- if (data_copy_new == NULL) {
- if (data_copy != NULL)
- free(data_copy);
- freePeakList(peakList);
- return 1;
- }
- else {
- data_copy = data_copy_new;
- }
-
- mergeMaskAndDataIntoDataCopy(image->dp[panel_number], data_copy,
- image->bad[panel_number],
- &det_size_one_panel);
-
- peakList.peakCount = 0;
- image->num_peaks += peakFinder9_onePanel_noSlab(data_copy,
- &accuracy_consts,
- &det_size_one_panel, &peakList);
-
- for (int peak_number = 0; peak_number < peakList.peakCount;
- peak_number++) {
- image_add_feature(image->features,
- peakList.centerOfMass_rawX[peak_number],
- peakList.centerOfMass_rawY[peak_number],
- &image->det->panels[panel_number],
- image,
- peakList.totalIntensity[peak_number],
- NULL);
- }
-
- }
-
- freePeakList(peakList);
- free(data_copy);
- return 0;
+ peakFinder9_accuracyConstants_t accuracy_consts;
+ peakList_t peakList;
+ long NpeaksMax = 10000; //more peaks per panel should not appear
+ float *data_copy = NULL;
+ float *data_copy_new;
+ int panel_number;
+
+ if ( image->features != NULL ) {
+ image_feature_list_free(image->features);
+ }
+ image->features = image_feature_list_new();
+ image->num_peaks = 0;
+ image->num_saturated_peaks = 0;
+
+ accuracy_consts.sigmaFactorBiggestPixel = sig_fac_biggest_pix;
+ accuracy_consts.sigmaFactorPeakPixel = sig_fac_peak_pix;
+ accuracy_consts.sigmaFactorWholePeak = sig_fac_whole_peak;
+ accuracy_consts.minimumSigma = min_sig;
+ accuracy_consts.minimumPeakOversizeOverNeighbours = min_peak_over_neighbour;
+ accuracy_consts.windowRadius = window_radius;
+
+ if ( allocatePeakList(&peakList, NpeaksMax) ) return 1;
+
+ for ( panel_number=0; panel_number<image->det->n_panels; panel_number++ ) {
+
+ int w, h;
+ int peak_number;
+ detectorRawFormat_t det_size_one_panel;
+
+ if ( image->det->panels[panel_number].no_index ) continue;
+
+ w = image->det->panels[panel_number].w;
+ h = image->det->panels[panel_number].h;
+
+ det_size_one_panel.asic_nx = w;
+ det_size_one_panel.asic_ny = h;
+ det_size_one_panel.nasics_x = 1;
+ det_size_one_panel.nasics_y = 1;
+ det_size_one_panel.pix_nx = w;
+ det_size_one_panel.pix_ny = h;
+ det_size_one_panel.pix_nn = w * h;
+
+ data_copy_new = realloc(data_copy, w*h*sizeof(*data_copy));
+ if ( data_copy_new == NULL ) {
+ if ( data_copy != NULL ) {
+ free(data_copy);
+ }
+ freePeakList(peakList);
+ return 1;
+ } else {
+ data_copy = data_copy_new;
+ }
+
+ mergeMaskAndDataIntoDataCopy(image->dp[panel_number], data_copy,
+ image->bad[panel_number],
+ &det_size_one_panel);
+
+ peakList.peakCount = 0;
+ image->num_peaks += peakFinder9_onePanel_noSlab(data_copy,
+ &accuracy_consts,
+ &det_size_one_panel,
+ &peakList);
+
+ for ( peak_number=0; peak_number<peakList.peakCount; peak_number++) {
+ image_add_feature(image->features,
+ peakList.centerOfMass_rawX[peak_number],
+ peakList.centerOfMass_rawY[peak_number],
+ &image->det->panels[panel_number],
+ image,
+ peakList.totalIntensity[peak_number],
+ NULL);
+ }
+
+ }
+
+ freePeakList(peakList);
+ free(data_copy);
+ return 0;
}
+
#else
+
int search_peaks_peakfinder9(struct image *image, float sig_fac_biggest_pix,
- float sig_fac_peak_pix, float sig_fac_whole_peak, float min_sig,
- float min_peak_over_neighbour, int window_radius)
+ float sig_fac_peak_pix, float sig_fac_whole_peak,
+ float min_sig, float min_peak_over_neighbour,
+ int window_radius)
{
- ERROR("This copy of CrystFEL was compiled without peakfinder9 support.\n");
- return 0;
+ ERROR("This copy of CrystFEL was compiled without peakfinder9 support.\n");
+ return 0;
}
+
#endif // HAVE_FDIP
diff --git a/libcrystfel/src/peaks.h b/libcrystfel/src/peaks.h
index e63287d4..04957143 100644
--- a/libcrystfel/src/peaks.h
+++ b/libcrystfel/src/peaks.h
@@ -56,10 +56,12 @@ extern int search_peaks_peakfinder8(struct image *image, int max_n_peaks,
int local_bg_radius, int min_res,
int max_res, int use_saturated);
-extern int search_peaks_peakfinder9(struct image *image, float sig_fac_biggest_pix,
- float sig_fac_peak_pix, float sig_fac_whole_peak, float min_sig,
- float min_peak_over_neighbour, int window_radius);
-
+extern int search_peaks_peakfinder9(struct image *image,
+ float sig_fac_biggest_pix,
+ float sig_fac_peak_pix,
+ float sig_fac_whole_peak, float min_sig,
+ float min_peak_over_neighbour,
+ int window_radius);
extern int peak_sanity_check(struct image *image, Crystal **crystals,
int n_cryst);