From 71659b553db6b4edda325bbfd2b39a59fd0fff0f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 7 Mar 2017 13:03:06 +0100 Subject: Use compare_cells() for multi-lattice indexing --- libcrystfel/src/index.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index 644ea31f..36f99995 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -354,9 +354,15 @@ static int try_indexer(struct image *image, IndexingMethod indm, } + /* For all the crystals found this time ... */ for ( i=0; icrystals[image->n_crystals-i-1]; + int j; + int this_crystal = image->n_crystals - i - 1; + + /* ... starting at the end of the (complete) list ... */ + Crystal *cr = image->crystals[this_crystal]; + crystal_set_image(cr, image); crystal_set_user_flag(cr, 0); crystal_set_profile_radius(cr, 0.02e9); @@ -385,7 +391,6 @@ static int try_indexer(struct image *image, IndexingMethod indm, if ( out == NULL ) { crystal_set_user_flag(cr, 1); - n_bad++; } cell_free(out); @@ -394,13 +399,32 @@ static int try_indexer(struct image *image, IndexingMethod indm, } - } + /* Don't do similarity check if this crystal is bad */ + if ( crystal_get_user_flag(cr) ) continue; + + /* Check if cell is too similar to existing ones */ + for ( j=0; jcrystals[j]; + + /* Don't do similarity check against bad crystals */ + if ( crystal_get_user_flag(that_cr) ) continue; - remove_flagged_crystals(image); + if ( compare_cells(crystal_get_cell(cr), + crystal_get_cell(that_cr), + 0.1, deg2rad(5.0), NULL) ) + { + crystal_set_user_flag(cr, 1); + ERROR("Excluding duplicate cell\n"); + } + } - if ( n_bad == r ) return 0; + } + + n_bad = remove_flagged_crystals(image); + assert(r >= n_bad); - return r; + return r - n_bad; } @@ -511,12 +535,9 @@ static int finished_retry(IndexingMethod indm, int r, struct image *image) * after deleting the explained peaks */ if ( indm & INDEXING_MULTI ) { - /* Remove "used" spots and try for - * another lattice */ + /* Remove "used" spots and try for another lattice */ Crystal *cr; cr = image->crystals[image->n_crystals-1]; - STATUS("WARNING: Multi-lattice indexing does not work" - " well in this version.\n"); return delete_explained_peaks(image, cr); } else { return 1; @@ -525,6 +546,7 @@ static int finished_retry(IndexingMethod indm, int r, struct image *image) } } + void index_pattern(struct image *image, IndexingPrivate *ipriv) { index_pattern_2(image, ipriv, NULL); -- cgit v1.2.3