diff options
author | Thomas White <taw@physics.org> | 2015-12-18 14:00:56 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2015-12-18 14:00:56 +0100 |
commit | d2a2f1928752e518ac7b8798175fd9a010674dd0 (patch) | |
tree | 12cb3ee6d5deba1d0bfd978f4c1e6340aafc5f4e /libcrystfel/src/image.c | |
parent | afbb6c8dcce4cc10292c93c3ef9b7e1321add660 (diff) |
"Retry" mechanism for indexing
This increases the indexing rate a bit in situations where there are
lots of weak peaks which, although they may be real, don't help
indexing. The weakest 10% of peaks get cut out and the indexing re-run.
This also allows multiple hits to be indexed, using the "inelegant peak
subtraction method", by retrying indexing in the same way after deleting
peaks which are accounted for by the lattice just found.
Diffstat (limited to 'libcrystfel/src/image.c')
-rw-r--r-- | libcrystfel/src/image.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c index 3dfccea3..cd7047dd 100644 --- a/libcrystfel/src/image.c +++ b/libcrystfel/src/image.c @@ -95,6 +95,45 @@ ImageFeatureList *image_feature_list_new() } +static int comp(const void *a, const void *b) +{ + const struct imagefeature *ap = a; + const struct imagefeature *bp = b; + + return ap->intensity < bp->intensity; +} + + +/* Strongest first. Returned list is guaranteed not to have any holes + * (feature->valid = 0) */ +ImageFeatureList *sort_peaks(ImageFeatureList *flist) +{ + ImageFeatureList *n = image_feature_list_new(); + int nf, i; + + if ( n == NULL ) return NULL; + + n->features = malloc(flist->n_features*sizeof(struct imagefeature)); + if ( n->features == NULL ) { + free(n); + return NULL; + } + + nf = 0; + for ( i=0; i<flist->n_features; i++ ) { + struct imagefeature *f; + f = image_get_feature(flist, i); + if ( f == NULL ) continue; + n->features[nf++] = flist->features[i]; + } + n->n_features = nf; + + qsort(n->features, nf, sizeof(struct imagefeature), comp); + + return n; +} + + void image_feature_list_free(ImageFeatureList *flist) { if ( !flist ) return; |