From 170391d34095b8a0439f987dd08fda7cb8213aba Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 6 Sep 2019 11:02:48 +0200 Subject: Use new peak check only when doing multi-lattice indexing --- libcrystfel/src/index.c | 3 ++- libcrystfel/src/peaks.c | 35 +++++++++++++++++++++++++++++++---- libcrystfel/src/peaks.h | 3 +++ 3 files changed, 36 insertions(+), 5 deletions(-) (limited to 'libcrystfel/src') diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 36d7b84b..4c82e868 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -663,7 +663,8 @@ static int try_indexer(struct image *image, IndexingMethod indm, /* Peak alignment check if requested */ if ( ipriv->flags & INDEXING_CHECK_PEAKS ) { - if ( !peak_sanity_check(image, &cr, 1) ) { + int mm = ipriv->flags & INDEXING_MULTI; + if ( !indexing_peak_check(image, &cr, 1, mm) ) { crystal_set_user_flag(cr, 1); continue; } diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c index 989f2e72..ea524210 100644 --- a/libcrystfel/src/peaks.c +++ b/libcrystfel/src/peaks.c @@ -675,7 +675,20 @@ int search_peaks_peakfinder9(struct image *image, float min_snr_biggest_pix, #endif // HAVE_FDIP -int peak_sanity_check(struct image *image, Crystal **crystals, int n_cryst) +/** + * \param image An \ref image structure + * \param crystals Pointer to array of pointers to crystals + * \param n_cryst The number of crystals + * \param multi_mode Whether the thresholds should be set for multi-lattice indexing + * + * Checks whether the peaks in \p image appear to be explained by the crystals + * provided. + * + * Returns 1 if the peaks appear to be well-explained by the crystals. + * Otherwise, if the indexing solutions appear to be "bad", returns 0. + */ +int indexing_peak_check(struct image *image, Crystal **crystals, int n_cryst, + int multi_mode) { int n_feat = 0; int n_sane = 0; @@ -733,9 +746,23 @@ int peak_sanity_check(struct image *image, Crystal **crystals, int n_cryst) } /* 0 means failed test, 1 means passed test */ - return (n_sane > 70) - || ((n_sane > 25) && (n_sane > 0.3*n_feat)) - || (n_sane > 0.4*n_feat); + + if ( multi_mode ) { + return (n_sane > 70) + || ((n_sane > 25) && (n_sane > 0.3*n_feat)) + || (n_sane > 0.4*n_feat); + } else { + return ((double)n_sane / n_feat) >= 0.5; + } +} + + +/** + * Deprecated: use indexing_peak_check instead + */ +int peak_sanity_check(struct image *image, Crystal **crystals, int n_cryst) +{ + return indexing_peak_check(image, crystals, n_cryst, 1); } diff --git a/libcrystfel/src/peaks.h b/libcrystfel/src/peaks.h index b08defcd..65c3a1ef 100644 --- a/libcrystfel/src/peaks.h +++ b/libcrystfel/src/peaks.h @@ -68,6 +68,9 @@ extern int search_peaks_peakfinder9(struct image *image, float min_peak_over_neighbour, int window_radius); +extern int indexing_peak_check(struct image *image, Crystal **crystals, + int n_cryst, int multi_mode); + extern int peak_sanity_check(struct image *image, Crystal **crystals, int n_cryst); -- cgit v1.2.3