aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2016-01-08 17:58:57 +0100
committerThomas White <taw@physics.org>2016-01-08 18:07:44 +0100
commit3df3322433fd3e4532d90ec2d1771a1be5babd4b (patch)
tree7e9553c375a40926ebb35b8203a23c9000e68c95
parent4ede1c30e188a4734707561350b7c9f074063a92 (diff)
Make indexing "retry" and "multi" optional
-rw-r--r--doc/man/indexamajig.18
-rw-r--r--libcrystfel/src/asdf.c3
-rw-r--r--libcrystfel/src/dirax.c3
-rw-r--r--libcrystfel/src/felix.c3
-rw-r--r--libcrystfel/src/index.c80
-rw-r--r--libcrystfel/src/index.h30
-rw-r--r--libcrystfel/src/mosflm.c3
-rw-r--r--libcrystfel/src/xds.c3
8 files changed, 106 insertions, 27 deletions
diff --git a/doc/man/indexamajig.1 b/doc/man/indexamajig.1
index 54d3a9f5..9eaa8c75 100644
--- a/doc/man/indexamajig.1
+++ b/doc/man/indexamajig.1
@@ -91,6 +91,14 @@ Check permutations of the axes for correspondence with your cell, but do not che
.PD
Check linear combinations of the unit cell basis vectors to see if a cell can be produced which looks like your unit cell. See \fB-raw\fR and \fB-axes\fR.
+.IP \fB-retry\fR
+.PD
+If indexing fails, delete some of the weakest peaks and try again. This increases the indexing yield, but decreases the speed. The opposite is \fB-noretry\fR, which prevents indexing from being retried. \fB-retry\R is the default for all indexing methods.
+
+.IP \fB-multi\fR
+.PD
+If indexing succeeds, delete the peaks which are explained by the lattice and try again to see if another lattice can be found. This allows the possibility of finding multiple crystals per pattern (above and beyond what is already found by multi-crystal indexing methods such as \fBfelix\fR. The opposite is \fB-nomulti\fR, which prevents that further indexing attempts. \fB-multi\fR is the default for all the single-crystal indexing methods (i.e. not \fBfelix\fR).
+
.IP \fB-bad\fR
.PD
Do not check that the cell accounts for the peaks found by the peak search. This might be useful to debug initial indexing problems, but as its name suggests it is usually a bad idea.
diff --git a/libcrystfel/src/asdf.c b/libcrystfel/src/asdf.c
index e5d3466f..87f00716 100644
--- a/libcrystfel/src/asdf.c
+++ b/libcrystfel/src/asdf.c
@@ -1178,7 +1178,8 @@ IndexingPrivate *asdf_prepare(IndexingMethod *indm, UnitCell *cell,
/* Flags that asdf knows about */
*indm &= INDEXING_METHOD_MASK | INDEXING_CHECK_CELL_COMBINATIONS
- | INDEXING_CHECK_CELL_AXES | INDEXING_CHECK_PEAKS;
+ | INDEXING_CHECK_CELL_AXES | INDEXING_CHECK_PEAKS
+ | INDEXING_RETRY | INDEXING_MULTI;
dp = malloc(sizeof(struct asdf_private));
if ( dp == NULL ) return NULL;
diff --git a/libcrystfel/src/dirax.c b/libcrystfel/src/dirax.c
index fb69cece..014a4790 100644
--- a/libcrystfel/src/dirax.c
+++ b/libcrystfel/src/dirax.c
@@ -654,7 +654,8 @@ IndexingPrivate *dirax_prepare(IndexingMethod *indm, UnitCell *cell,
/* Flags that DirAx knows about */
*indm &= INDEXING_METHOD_MASK | INDEXING_CHECK_CELL_COMBINATIONS
- | INDEXING_CHECK_CELL_AXES | INDEXING_CHECK_PEAKS;
+ | INDEXING_CHECK_CELL_AXES | INDEXING_CHECK_PEAKS
+ | INDEXING_RETRY | INDEXING_MULTI;
dp = malloc(sizeof(struct dirax_private));
if ( dp == NULL ) return NULL;
diff --git a/libcrystfel/src/felix.c b/libcrystfel/src/felix.c
index f5bae88a..2a6a0e44 100644
--- a/libcrystfel/src/felix.c
+++ b/libcrystfel/src/felix.c
@@ -676,7 +676,8 @@ IndexingPrivate *felix_prepare(IndexingMethod *indm, UnitCell *cell,
/* Flags that Felix knows about */
*indm &= INDEXING_METHOD_MASK | INDEXING_CHECK_PEAKS
- | INDEXING_USE_LATTICE_TYPE | INDEXING_USE_CELL_PARAMETERS;
+ | INDEXING_USE_LATTICE_TYPE | INDEXING_USE_CELL_PARAMETERS
+ | INDEXING_RETRY | INDEXING_MULTI;
gp->cell = cell;
gp->indm = *indm;
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index 2e54859d..af5b81c7 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -346,6 +346,46 @@ static int delete_explained_peaks(struct image *image, Crystal *cr)
}
+/* indm = the current indexing method
+ * r = the result from try_indexer() on this method just now
+ * image = the image structure
+ *
+ * Returns false for "try again", true for "no, stop now"
+ */
+static int finished_retry(IndexingMethod indm, int r, struct image *image)
+{
+ if ( r == 0 ) {
+
+ /* Indexing failed on the previous attempt. Maybe try again
+ * after poking the peak list a bit */
+
+ if ( indm & INDEXING_RETRY ) {
+ /* Retry with fewer peaks */
+ return delete_weakest_peaks(image->features);
+ } else {
+ /* Indexing failed, opted not to try again */
+ return 1;
+ }
+
+ } else {
+
+ /* Indexing succeeded on previous attempt. Maybe try again
+ * after deleting the explained peaks */
+
+ if ( indm & INDEXING_MULTI ) {
+ /* Remove "used" spots and try for
+ * another lattice */
+ Crystal *cr;
+ cr = image->crystals[image->n_crystals-1];
+ return delete_explained_peaks(image, cr);
+ } else {
+ return 1;
+ }
+
+ }
+}
+
+
void index_pattern(struct image *image,
IndexingMethod *indms, IndexingPrivate **iprivs)
{
@@ -373,18 +413,7 @@ void index_pattern(struct image *image,
r = try_indexer(image, indms[n], iprivs[n]);
ntry++;
-
- if ( r == 0 ) {
- /* Retry with fewer peaks */
- done = delete_weakest_peaks(image->features);
- } else {
- /* Remove "used" spots and try for
- * another lattice */
- Crystal *cr;
- cr = image->crystals[image->n_crystals-1];
- done = delete_explained_peaks(image, cr);
- }
-
+ done = finished_retry(indms[n], r, image);
if ( ntry > 5 ) done = 1;
} while ( !done );
@@ -459,11 +488,12 @@ static IndexingMethod set_cellparams(IndexingMethod a)
return a | INDEXING_USE_CELL_PARAMETERS;
}
+
char *indexer_str(IndexingMethod indm)
{
char *str;
- str = malloc(32);
+ str = malloc(256);
if ( str == NULL ) {
ERROR("Failed to allocate string.\n");
return NULL;
@@ -538,6 +568,18 @@ char *indexer_str(IndexingMethod indm)
strcat(str, "-nocell");
}
+ if ( indm & INDEXING_RETRY ) {
+ strcat(str, "-retry");
+ } else {
+ strcat(str, "-noretry");
+ }
+
+ if ( indm & INDEXING_MULTI ) {
+ strcat(str, "-multi");
+ } else {
+ strcat(str, "-nomulti");
+ }
+
return str;
}
@@ -605,6 +647,18 @@ IndexingMethod *build_indexer_list(const char *str)
} else if ( strcmp(methods[i], "nocell") == 0) {
list[nmeth] = set_nocellparams(list[nmeth]);
+ } else if ( strcmp(methods[i], "retry") == 0) {
+ list[nmeth] |= INDEXING_RETRY;
+
+ } else if ( strcmp(methods[i], "noretry") == 0) {
+ list[nmeth] &= ~INDEXING_RETRY;
+
+ } else if ( strcmp(methods[i], "multi") == 0) {
+ list[nmeth] |= INDEXING_MULTI;
+
+ } else if ( strcmp(methods[i], "nomulti") == 0) {
+ list[nmeth] &= ~INDEXING_MULTI;
+
} else {
ERROR("Bad list of indexing methods: '%s'\n", str);
return NULL;
diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h
index 0ce74e37..855af70d 100644
--- a/libcrystfel/src/index.h
+++ b/libcrystfel/src/index.h
@@ -3,13 +3,13 @@
*
* Perform indexing (somehow)
*
- * Copyright © 2012-2015 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2016 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
* Copyright © 2012 Richard Kirian
* Copyright © 2012 Lorenzo Galli
*
* Authors:
- * 2010-2015 Thomas White <taw@physics.org>
+ * 2010-2016 Thomas White <taw@physics.org>
* 2010 Richard Kirian
* 2012 Lorenzo Galli
* 2015 Kenneth Beyerlein <kenneth.beyerlein@desy.de>
@@ -40,25 +40,31 @@
#define INDEXING_DEFAULTS_DIRAX (INDEXING_DIRAX | INDEXING_CHECK_PEAKS \
- | INDEXING_CHECK_CELL_COMBINATIONS)
+ | INDEXING_CHECK_CELL_COMBINATIONS \
+ | INDEXING_RETRY | INDEXING_MULTI)
-#define INDEXING_DEFAULTS_ASDF (INDEXING_ASDF | INDEXING_CHECK_PEAKS \
- | INDEXING_CHECK_CELL_COMBINATIONS)
+#define INDEXING_DEFAULTS_ASDF (INDEXING_ASDF | INDEXING_CHECK_PEAKS \
+ | INDEXING_CHECK_CELL_COMBINATIONS \
+ | INDEXING_RETRY | INDEXING_MULTI)
#define INDEXING_DEFAULTS_MOSFLM (INDEXING_MOSFLM | INDEXING_CHECK_PEAKS \
| INDEXING_CHECK_CELL_COMBINATIONS \
| INDEXING_USE_LATTICE_TYPE \
- | INDEXING_USE_CELL_PARAMETERS)
+ | INDEXING_USE_CELL_PARAMETERS \
+ | INDEXING_RETRY | INDEXING_MULTI)
-#define INDEXING_DEFAULTS_FELIX (INDEXING_FELIX \
+/* Note: no INDEXING_MULTI because Felix is already multi-crystal */
+#define INDEXING_DEFAULTS_FELIX (INDEXING_FELIX \
| INDEXING_USE_LATTICE_TYPE \
- | INDEXING_USE_CELL_PARAMETERS)
+ | INDEXING_USE_CELL_PARAMETERS \
+ | INDEXING_RETRY)
/* Axis check is needed for XDS, because it likes to permute the axes */
#define INDEXING_DEFAULTS_XDS (INDEXING_XDS | INDEXING_USE_LATTICE_TYPE \
| INDEXING_USE_CELL_PARAMETERS \
| INDEXING_CHECK_CELL_AXES \
- | INDEXING_CHECK_PEAKS)
+ | INDEXING_CHECK_PEAKS \
+ | INDEXING_RETRY | INDEXING_MULTI)
/**
* IndexingMethod:
@@ -80,6 +86,10 @@
* guide the indexing process.
* @INDEXING_USE_CELL_PARAMETERS: Use the unit cell parameters to guide the
* indexingprocess.
+ * @INDEXING_RETRY: If the indexer doesn't succeed, delete the weakest peaks
+ * and try again.
+ * @INDEXING_MULTI: If the indexer succeeds, delete the peaks explained by the
+ * lattice and try again in the hope of finding another crystal.
*
* An enumeration of all the available indexing methods. The dummy value
* @INDEXING_SIMULATION is used by partial_sim to indicate that no indexing was
@@ -105,6 +115,8 @@ typedef enum {
INDEXING_CHECK_PEAKS = 1024,
INDEXING_USE_LATTICE_TYPE = 2048,
INDEXING_USE_CELL_PARAMETERS = 4096,
+ INDEXING_RETRY = 8192,
+ INDEXING_MULTI = 16384
} IndexingMethod;
diff --git a/libcrystfel/src/mosflm.c b/libcrystfel/src/mosflm.c
index fe917d27..5b4b623f 100644
--- a/libcrystfel/src/mosflm.c
+++ b/libcrystfel/src/mosflm.c
@@ -871,7 +871,8 @@ IndexingPrivate *mosflm_prepare(IndexingMethod *indm, UnitCell *cell,
/* Flags that MOSFLM knows about */
*indm &= INDEXING_METHOD_MASK | INDEXING_CHECK_CELL_COMBINATIONS
| INDEXING_CHECK_CELL_AXES | INDEXING_CHECK_PEAKS
- | INDEXING_USE_LATTICE_TYPE| INDEXING_USE_CELL_PARAMETERS;
+ | INDEXING_USE_LATTICE_TYPE| INDEXING_USE_CELL_PARAMETERS
+ | INDEXING_RETRY | INDEXING_MULTI;
if ( (*indm & INDEXING_USE_LATTICE_TYPE)
&& !((*indm & INDEXING_CHECK_CELL_COMBINATIONS)
diff --git a/libcrystfel/src/xds.c b/libcrystfel/src/xds.c
index 36898949..ea0fc836 100644
--- a/libcrystfel/src/xds.c
+++ b/libcrystfel/src/xds.c
@@ -676,7 +676,8 @@ IndexingPrivate *xds_prepare(IndexingMethod *indm, UnitCell *cell,
/* Flags that XDS knows about */
*indm &= INDEXING_METHOD_MASK | INDEXING_CHECK_CELL_COMBINATIONS
| INDEXING_CHECK_CELL_AXES | INDEXING_USE_LATTICE_TYPE
- | INDEXING_CHECK_PEAKS | INDEXING_USE_CELL_PARAMETERS;
+ | INDEXING_CHECK_PEAKS | INDEXING_USE_CELL_PARAMETERS
+ | INDEXING_RETRY | INDEXING_MULTI;
xp->ltl = ltl;
xp->cell = cell;