diff options
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/felix.c | 176 | ||||
-rw-r--r-- | libcrystfel/src/felix.h | 17 | ||||
-rw-r--r-- | libcrystfel/src/taketwo.c | 104 | ||||
-rw-r--r-- | libcrystfel/src/taketwo.h | 12 | ||||
-rw-r--r-- | libcrystfel/src/utils.c | 2 | ||||
-rw-r--r-- | libcrystfel/src/xgandalf.c | 159 | ||||
-rw-r--r-- | libcrystfel/src/xgandalf.h | 12 |
7 files changed, 451 insertions, 31 deletions
diff --git a/libcrystfel/src/felix.c b/libcrystfel/src/felix.c index ea27093a..cac12410 100644 --- a/libcrystfel/src/felix.c +++ b/libcrystfel/src/felix.c @@ -70,6 +70,21 @@ #define FELIX_VERBOSE 0 +struct felix_options +{ + double ttmin; /* radians */ + double ttmax; /* radians */ + int min_visits; + double min_completeness; + double max_uniqueness; + int n_voxels; + double fraction_max_visits; + double sigma; + double domega; + double max_internal_angle; +}; + + /* Global private data, prepared once */ struct felix_private { @@ -789,3 +804,164 @@ const char *felix_probe(UnitCell *cell) if ( ok ) return "felix"; return NULL; } + + +static void show_help() +{ + printf("Parameters for the Felix indexing algorithm:\n" +" --felix-domega Degree range of omega (moscaicity) to consider.\n" +" Default: 2\n" +" --felix-fraction-max-visits\n" +" Cutoff for minimum fraction of the max visits.\n" +" Default: 0.75\n" +" --felix-max-internal-angle\n" +" Cutoff for maximum internal angle between observed\n" +" spots and predicted spots. Default: 0.25\n" +" --felix-max-uniqueness\n" +" Cutoff for maximum fraction of found spots which\n" +" can belong to other crystallites. Default: 0.5\n" +" --felix-min-completeness\n" +" Cutoff for minimum fraction of projected spots\n" +" found in the pattern. Default: 0.001\n" +" --felix-min-visits\n" +" Cutoff for minimum number of voxel visits.\n" +" Default: 15\n" +" --felix-num-voxels Number of voxels for Rodrigues space search\n" +" Default: 100\n" +" --felix-sigma The sigma of the 2theta, eta and omega angles.\n" +" Default: 0.2\n" +" --felix-tthrange-max Maximum 2theta to consider for indexing (degrees)\n" +" Default: 30\n" +" --felix-tthrange-min Minimum 2theta to consider for indexing (degrees)\n" +" Default: 0\n" +); +} + + +static error_t parse_arg(int key, char *arg, struct argp_state *state) +{ + struct felix_options **opts_ptr = state->input; + float tmp; + + switch ( key ) { + + case ARGP_KEY_INIT : + *opts_ptr = malloc(sizeof(struct felix_options)); + if ( *opts_ptr == NULL ) return ENOMEM; + (*opts_ptr)->ttmin = -1.0; + (*opts_ptr)->ttmax = -1.0; + (*opts_ptr)->min_visits = 0; + (*opts_ptr)->min_completeness = -1.0; + (*opts_ptr)->max_uniqueness = -1.0; + (*opts_ptr)->n_voxels = 0; + (*opts_ptr)->fraction_max_visits = -1.0; + (*opts_ptr)->sigma = -1.0; + (*opts_ptr)->domega = -1.0; + (*opts_ptr)->max_internal_angle = -1.0; + break; + + case 1 : + show_help(); + return EINVAL; + + case 2 : + if ( sscanf(arg, "%f", &tmp) != 1 ) { + ERROR("Invalid value for --felix-tthrange-min\n"); + return EINVAL; + } + (*opts_ptr)->ttmin = deg2rad(tmp); + break; + + case 3 : + if ( sscanf(arg, "%f", &tmp) != 1 ) { + ERROR("Invalid value for --felix-tthrange-max\n"); + return EINVAL; + } + (*opts_ptr)->ttmax = deg2rad(tmp); + break; + + case 4 : + if ( sscanf(arg, "%d", &(*opts_ptr)->min_visits) != 1 ) { + ERROR("Invalid value for --felix-min-visits\n"); + return EINVAL; + } + break; + + case 5 : + if ( sscanf(arg, "%lf", &(*opts_ptr)->min_completeness) != 1 ) { + ERROR("Invalid value for --felix-min-completeness\n"); + return EINVAL; + } + break; + + case 6 : + if ( sscanf(arg, "%lf", &(*opts_ptr)->max_uniqueness) != 1 ) { + ERROR("Invalid value for --felix-max-uniqueness\n"); + return EINVAL; + } + break; + + case 7 : + if ( sscanf(arg, "%d", &(*opts_ptr)->n_voxels) != 1 ) { + ERROR("Invalid value for --felix-num-voxels\n"); + return EINVAL; + } + break; + + case 8 : + if ( sscanf(arg, "%lf", &(*opts_ptr)->fraction_max_visits) != 1 ) { + ERROR("Invalid value for --felix-fraction-max-visits\n"); + return EINVAL; + } + break; + + case 9 : + if ( sscanf(arg, "%lf", &(*opts_ptr)->sigma) != 1 ) { + ERROR("Invalid value for --felix-sigma\n"); + return EINVAL; + } + break; + + case 10 : + if ( sscanf(arg, "%lf", &(*opts_ptr)->domega) != 1 ) { + ERROR("Invalid value for --felix-domega\n"); + return EINVAL; + } + break; + + case 11 : + if ( sscanf(arg, "%lf", &(*opts_ptr)->max_internal_angle) != 1 ) { + ERROR("Invalid value for --felix-max-internal-angle\n"); + return EINVAL; + } + break; + + default : + return ARGP_ERR_UNKNOWN; + + } + + return 0; +} + + +static struct argp_option options[] = { + + {"help-felix", 1, NULL, OPTION_NO_USAGE, + "Show options for Felix indexing algorithm", 99}, + {"felix-tthrange-min", 2, "2theta", OPTION_HIDDEN, NULL}, + {"felix-tthrange-max", 3, "2theta", OPTION_HIDDEN, NULL}, + {"felix-min-visits", 4, "n", OPTION_HIDDEN, NULL}, + {"felix-min-completeness", 5, "frac", OPTION_HIDDEN, NULL}, + {"felix-max-uniqueness", 6, "n", OPTION_HIDDEN, NULL}, + {"felix-num-voxels", 7, "n", OPTION_HIDDEN, NULL}, + {"felix-fraction-max-visits", 8, "n", OPTION_HIDDEN, NULL}, + {"felix-sigma", 9, "n", OPTION_HIDDEN, NULL}, + {"felix-domega", 10, "n", OPTION_HIDDEN, NULL}, + {"felix-max-internal-angle", 11, "ang", OPTION_HIDDEN, NULL}, + + {0} +}; + + +struct argp felix_argp = { options, parse_arg, NULL, NULL, NULL, NULL, NULL }; diff --git a/libcrystfel/src/felix.h b/libcrystfel/src/felix.h index 645adaeb..8cec9754 100644 --- a/libcrystfel/src/felix.h +++ b/libcrystfel/src/felix.h @@ -34,6 +34,8 @@ #include <config.h> #endif +#include <argp.h> + #include "cell.h" /** @@ -41,19 +43,8 @@ * Felix indexer interface */ -struct felix_options -{ - double ttmin; /* radians */ - double ttmax; /* radians */ - int min_visits; - double min_completeness; - double max_uniqueness; - int n_voxels; - double fraction_max_visits; - double sigma; - double domega; - double max_internal_angle; -}; +typedef struct felix_options FelixOptions; +extern struct argp felix_argp; extern void *felix_prepare(IndexingMethod *indm, UnitCell *cell, struct felix_options *opts); diff --git a/libcrystfel/src/taketwo.c b/libcrystfel/src/taketwo.c index ddbfe173..893791e4 100644 --- a/libcrystfel/src/taketwo.c +++ b/libcrystfel/src/taketwo.c @@ -100,6 +100,14 @@ #include "peaks.h" #include "symmetry.h" +struct taketwo_options +{ + int member_thresh; + double len_tol; + double angle_tol; + double trace_tol; +}; + /** * \param obsvec an observed vector between two spots * \param matches array of matching theoretical vectors from unit cell @@ -2241,6 +2249,7 @@ void *taketwo_prepare(IndexingMethod *indm, UnitCell *cell) return tp; } + void taketwo_cleanup(IndexingPrivate *pp) { struct taketwo_private *tp = (struct taketwo_private *)pp; @@ -2257,3 +2266,98 @@ const char *taketwo_probe(UnitCell *cell) if ( cell_has_parameters(cell) ) return "taketwo"; return NULL; } + + +static void show_help() +{ + printf("Parameters for the TakeTwo indexing algorithm:\n" +" --taketwo-member-threshold\n" +" Minimum number of members in network\n" +" --taketwo-len-tolerance\n" +" Reciprocal space length tolerance (1/A)\n" +" --taketwo-angle-tolerance\n" +" Reciprocal space angle tolerance (in degrees)\n" +" --taketwo-trace-tolerance\n" +" Rotation matrix equivalence tolerance (in degrees)\n" +); +} + + +static error_t parse_arg(int key, char *arg, struct argp_state *state) +{ + struct taketwo_options **opts_ptr = state->input; + float tmp; + + switch ( key ) { + + case ARGP_KEY_INIT : + *opts_ptr = malloc(sizeof(struct taketwo_options)); + if ( *opts_ptr == NULL ) return ENOMEM; + (*opts_ptr)->member_thresh = -1.0; + (*opts_ptr)->len_tol = -1.0; + (*opts_ptr)->angle_tol = -1.0; + (*opts_ptr)->trace_tol = -1.0; + break; + + case 1 : + show_help(); + return EINVAL; + + case 2 : + if ( sscanf(arg, "%i", &(*opts_ptr)->member_thresh) != 1 ) + { + ERROR("Invalid value for --taketwo-member-threshold\n"); + return EINVAL; + } + break; + + case 3 : + if ( sscanf(arg, "%f", &tmp) != 1 ) + { + ERROR("Invalid value for --taketwo-len-tol\n"); + return EINVAL; + } + (*opts_ptr)->len_tol = tmp * 1e10; /* Convert to m^-1 */ + break; + + case 4 : + if ( sscanf(arg, "%f", &tmp) != 1 ) + { + ERROR("Invalid value for --taketwo-angle-tol\n"); + return EINVAL; + } + (*opts_ptr)->angle_tol = deg2rad(tmp); + break; + + case 5 : + if ( sscanf(arg, "%f", &tmp) != 1 ) + { + ERROR("Invalid value for --taketwo-trace-tol\n"); + return EINVAL; + } + (*opts_ptr)->trace_tol = deg2rad(tmp); + break; + + default : + return ARGP_ERR_UNKNOWN; + + } + + return 0; +} + + +static struct argp_option options[] = { + + {"help-taketwo", 1, NULL, OPTION_NO_USAGE, + "Show options for TakeTwo indexing algorithm", 99}, + + {"taketwo-member-threshold", 2, "n", OPTION_HIDDEN, NULL}, + {"taketwo-len-tolerance", 3, "one_over_A", OPTION_HIDDEN, NULL}, + {"taketwo-angle-tolerance", 4, "deg", OPTION_HIDDEN, NULL}, + {"taketwo-trace-tolerance", 5, "deg", OPTION_HIDDEN, NULL}, + {0} +}; + + +struct argp taketwo_argp = { options, parse_arg, NULL, NULL, NULL, NULL, NULL }; diff --git a/libcrystfel/src/taketwo.h b/libcrystfel/src/taketwo.h index 6960446d..c489228f 100644 --- a/libcrystfel/src/taketwo.h +++ b/libcrystfel/src/taketwo.h @@ -31,19 +31,15 @@ #ifndef TAKETWO_H #define TAKETWO_H +#include <argp.h> + #include "cell.h" #include "index.h" /** \file taketwo.h */ -struct taketwo_options -{ - int member_thresh; - double len_tol; - double angle_tol; - double trace_tol; -}; - +typedef struct taketwo_options TakeTwoOptions; +extern struct argp taketwo_argp; extern void *taketwo_prepare(IndexingMethod *indm, UnitCell *cell); extern const char *taketwo_probe(UnitCell *cell); diff --git a/libcrystfel/src/utils.c b/libcrystfel/src/utils.c index a2ba2c60..ba6f44c3 100644 --- a/libcrystfel/src/utils.c +++ b/libcrystfel/src/utils.c @@ -469,6 +469,8 @@ char *check_prefix(char *prefix) char *new; size_t len; + if ( prefix[0] == '\0' ) return prefix; + /* Is "prefix" a directory? */ r = stat(prefix, &statbuf); if ( r != 0 ) { diff --git a/libcrystfel/src/xgandalf.c b/libcrystfel/src/xgandalf.c index 6a8ba4d5..2b5bd512 100644 --- a/libcrystfel/src/xgandalf.c +++ b/libcrystfel/src/xgandalf.c @@ -28,19 +28,32 @@ #include "xgandalf.h" -#ifdef HAVE_XGANDALF #include <stdlib.h> #include "utils.h" #include "cell-utils.h" #include "peaks.h" +#ifdef HAVE_XGANDALF #include "xgandalf/adaptions/crystfel/Lattice.h" #include "xgandalf/adaptions/crystfel/ExperimentSettings.h" #include "xgandalf/adaptions/crystfel/IndexerPlain.h" +#endif /** \file xgandalf.h */ +struct xgandalf_options { + unsigned int sampling_pitch; + unsigned int grad_desc_iterations; + float tolerance; + unsigned int no_deviation_from_provided_cell; + float minLatticeVectorLength_A; + float maxLatticeVectorLength_A; + int maxPeaksForIndexing; +}; + +#ifdef HAVE_XGANDALF + struct xgandalf_private_data { IndexerPlain *indexer; reciprocalPeaks_1_per_A_t reciprocalPeaks_1_per_A; @@ -332,3 +345,147 @@ const char *xgandalf_probe(UnitCell *cell) } #endif // HAVE_XGANDALF + +static void show_help() +{ + printf("Parameters for the TakeTwo indexing algorithm:\n" +" --xgandalf-sampling-pitch\n" +" Sampling pitch: 0 (loosest) to 4 (most dense)\n" +" or with secondary Miller indices: 5 (loosest) to\n" +" 7 (most dense). Default: 6\n" +" --xgandalf-grad-desc-iterations\n" +" Gradient descent iterations: 0 (few) to 5 (many)\n" +" Default: 4\n" +" --xgandalf-fast-execution Shortcut to set\n" +" --xgandalf-sampling-pitch=2\n" +" --xgandalf-grad-desc-iterations=3\n" +" --xgandalf-tolerance Relative tolerance of the lattice vectors.\n" +" Default is 0.02\n" +" --xgandalf-no-deviation-from-provided-cell\n" +" Force the fitted cell to have the same lattice\n" +" parameters as the provided one\n" +" --xgandalf-min-lattice-vector-length\n" +" Minimum possible lattice vector length in A.\n" +" Default: 30 A\n" +" --xgandalf-max-lattice-vector-length\n" +" Maximum possible lattice vector length in A.\n" +" Default: 250 A\n" +" --xgandalf-max-peaks\n" +" Maximum number of peaks used for indexing.\n" +" All peaks are used for refinement.\n" +" Default: 250\n" +); +} + + +static error_t parse_arg(int key, char *arg, struct argp_state *state) +{ + struct xgandalf_options **opts_ptr = state->input; + + switch ( key ) { + + case ARGP_KEY_INIT : + *opts_ptr = malloc(sizeof(struct xgandalf_options)); + if ( *opts_ptr == NULL ) return ENOMEM; + (*opts_ptr)->sampling_pitch = 6; + (*opts_ptr)->grad_desc_iterations = 4; + (*opts_ptr)->tolerance = 0.02; + (*opts_ptr)->no_deviation_from_provided_cell = 0; + (*opts_ptr)->minLatticeVectorLength_A = 30; + (*opts_ptr)->maxLatticeVectorLength_A = 250; + (*opts_ptr)->maxPeaksForIndexing = 250; + break; + + case 1 : + show_help(); + return EINVAL; + + case 2 : + if (sscanf(arg, "%u", &(*opts_ptr)->sampling_pitch) != 1) { + ERROR("Invalid value for --xgandalf-sampling-pitch\n"); + return EINVAL; + } + break; + + case 3 : + if (sscanf(arg, "%u", &(*opts_ptr)->grad_desc_iterations) != 1) { + ERROR("Invalid value for --xgandalf-grad-desc-iterations\n"); + return EINVAL; + } + break; + + case 4 : + if (sscanf(arg, "%f", &(*opts_ptr)->tolerance) != 1) { + ERROR("Invalid value for --xgandalf-tolerance\n"); + return EINVAL; + } + break; + + case 5 : + (*opts_ptr)->no_deviation_from_provided_cell = 1; + break; + + case 6 : + if (sscanf(arg, "%f", &(*opts_ptr)->minLatticeVectorLength_A) != 1) { + ERROR("Invalid value for --xgandalf-min-lattice-vector-length\n"); + return EINVAL; + } + break; + + case 7 : + if (sscanf(arg, "%f", &(*opts_ptr)->maxLatticeVectorLength_A) != 1) { + ERROR("Invalid value for --xgandalf-max-lattice-vector-length\n"); + return EINVAL; + } + break; + + case 8 : + (*opts_ptr)->sampling_pitch = 2; + (*opts_ptr)->grad_desc_iterations = 3; + break; + + case 9 : + if (sscanf(arg, "%i", &(*opts_ptr)->maxPeaksForIndexing) != 1) { + ERROR("Invalid value for --xgandalf-max-peaks\n"); + return EINVAL; + } + break; + + } + + return 0; +} + + +static struct argp_option options[] = { + + {"help-xgandalf", 1, NULL, OPTION_NO_USAGE, + "Show options for XGANDALF indexing algorithm", 99}, + + {"xgandalf-sampling-pitch", 2, "pitch", OPTION_HIDDEN, NULL}, + {"xgandalf-sps", 2, "pitch", OPTION_HIDDEN, NULL}, + + {"xgandalf-grad-desc-iterations", 3, "n", OPTION_HIDDEN, NULL}, + {"xgandalf-gdis", 3, "n", OPTION_HIDDEN, NULL}, + + {"xgandalf-tolerance", 4, "t", OPTION_HIDDEN, NULL}, + {"xgandalf-tol", 4, "t", OPTION_HIDDEN, NULL}, + + {"xgandalf-no-deviation-from-provided-cell", 5, NULL, OPTION_HIDDEN, NULL}, + {"xgandalf-ndfpc", 5, NULL, OPTION_HIDDEN, NULL}, + + {"xgandalf-min-lattice-vector-length", 6, "len", OPTION_HIDDEN, NULL}, + {"xgandalf-min-lvl", 6, "len", OPTION_HIDDEN, NULL}, + + {"xgandalf-max-lattice-vector-length", 7, "len", OPTION_HIDDEN, NULL}, + {"xgandalf-max-lvl", 7, "len", OPTION_HIDDEN, NULL}, + + {"xgandalf-fast-execution", 8, NULL, OPTION_HIDDEN, NULL}, + + {"xgandalf-max-peaks", 9, "n", OPTION_HIDDEN, NULL}, + + {0} +}; + + +struct argp xgandalf_argp = { options, parse_arg, NULL, NULL, NULL, NULL, NULL }; diff --git a/libcrystfel/src/xgandalf.h b/libcrystfel/src/xgandalf.h index 23c5c1b0..7cc85388 100644 --- a/libcrystfel/src/xgandalf.h +++ b/libcrystfel/src/xgandalf.h @@ -34,21 +34,15 @@ #endif #include <stddef.h> +#include <argp.h> /** * \file xgandalf.h * XGANDALF indexer interface */ -struct xgandalf_options { - unsigned int sampling_pitch; - unsigned int grad_desc_iterations; - float tolerance; - unsigned int no_deviation_from_provided_cell; - float minLatticeVectorLength_A; - float maxLatticeVectorLength_A; - int maxPeaksForIndexing; -}; +typedef struct xgandalf_options XGandalfOptions; +extern struct argp xgandalf_argp; #include "index.h" |