aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2016-01-29 18:23:48 +0100
committerThomas White <taw@physics.org>2016-01-29 21:05:03 +0100
commitc9c756db807f3ea22dcf2d01401a4ce69f73f4df (patch)
tree2d53d2355512a29976ce3ebbdd83f9a602d5bf60 /libcrystfel
parentf2bf00dd32e79a06410b7a95fedaa2ee3bf33ef3 (diff)
Perform prediction refinement straight after indexing
This allows indexing to be attempted again (either a new method or with "retry") if the prediction refinement fails, increasing overall indexing rate. Side-effect: there are some hoops which would need to be jumped through to store the profile radius before refinement and hence enable scripts/plot-predict-refine to work. For now, we'll ignore this as it's clear that the prediction refinement is working.
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/image.c20
-rw-r--r--libcrystfel/src/image.h1
-rw-r--r--libcrystfel/src/index.c42
3 files changed, 55 insertions, 8 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index cd7047dd..82ad8f7e 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -280,6 +280,26 @@ void image_add_crystal(struct image *image, Crystal *cryst)
}
+void remove_flagged_crystals(struct image *image)
+{
+ int i;
+
+ for ( i=0; i<image->n_crystals; i++ ) {
+ if ( crystal_get_user_flag(image->crystals[i]) ) {
+ int j;
+ Crystal *deleteme = image->crystals[i];
+ cell_free(crystal_get_cell(deleteme));
+ crystal_free(deleteme);
+ for ( j=i; j<image->n_crystals-1; j++ ) {
+ image->crystals[j] = image->crystals[j+1];
+ }
+ image->n_crystals--;
+ }
+ }
+
+}
+
+
/* Free all crystals, including their RefLists and UnitCells */
void free_all_crystals(struct image *image)
{
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index e9cd76fc..ddbfc9dc 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -227,6 +227,7 @@ extern struct imagefeature *image_get_feature(ImageFeatureList *flist, int idx);
extern ImageFeatureList *sort_peaks(ImageFeatureList *flist);
extern void image_add_crystal(struct image *image, Crystal *cryst);
+extern void remove_flagged_crystals(struct image *image);
extern void free_all_crystals(struct image *image);
#ifdef __cplusplus
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index 2b84a621..6a74a958 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -55,6 +55,7 @@
#include "geometry.h"
#include "cell-utils.h"
#include "felix.h"
+#include "predict-refine.h"
static int debug_index(struct image *image)
@@ -234,36 +235,61 @@ void map_all_peaks(struct image *image)
static int try_indexer(struct image *image, IndexingMethod indm,
IndexingPrivate *ipriv)
{
+ int i, r, n_bad;
+
switch ( indm & INDEXING_METHOD_MASK ) {
case INDEXING_NONE :
return 0;
case INDEXING_DIRAX :
- return run_dirax(image, ipriv);
+ r = run_dirax(image, ipriv);
+ break;
case INDEXING_ASDF :
- return run_asdf(image, ipriv);
+ r = run_asdf(image, ipriv);
+ break;
case INDEXING_MOSFLM :
- return run_mosflm(image, ipriv);
+ r = run_mosflm(image, ipriv);
+ break;
case INDEXING_XDS :
- return run_xds(image, ipriv);
+ r = run_xds(image, ipriv);
+ break;
case INDEXING_DEBUG :
- return debug_index(image);
+ r = debug_index(image);
+ break;
case INDEXING_FELIX :
- return felix_index(image, ipriv);
+ r = felix_index(image, ipriv);
+ break;
default :
ERROR("Unrecognised indexing method: %i\n", indm);
- break;
+ return 0;
}
- return 0;
+ /* Attempt prediction refinement */
+ n_bad = 0;
+ for ( i=0; i<r; i++ ) {
+ Crystal *cr = image->crystals[image->n_crystals-i-1];
+ crystal_set_image(cr, image);
+ crystal_set_user_flag(cr, 0);
+ crystal_set_profile_radius(cr, 0.02e9);
+ crystal_set_mosaicity(cr, 0.0);
+ if ( refine_prediction(image, cr) != 0 ) {
+ crystal_set_user_flag(cr, 1);
+ n_bad++;
+ }
+ }
+
+ remove_flagged_crystals(image);
+
+ if ( n_bad == r ) return 0;
+ return r;
}