aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/Makefile.in9
-rw-r--r--src/index-priv.h29
-rw-r--r--src/index.c41
-rw-r--r--src/index.h12
-rw-r--r--src/indexamajig.c27
-rw-r--r--src/templates.c41
-rw-r--r--src/templates.h30
10 files changed, 180 insertions, 15 deletions
diff --git a/Makefile.am b/Makefile.am
index b3905371..e8cc6ffd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,5 +6,5 @@ EXTRA_DIST = configure src/cell.h src/hdf5-file.h src/image.h \
src/filters.h src/diffraction-gpu.h src/cl-utils.h \
data/defs.h src/parameters-lcls.tmp \
data/diffraction.cl data/sfac src/likelihood.h src/symmetry.h \
- src/povray.h
+ src/povray.h src/index-priv.h
SUBDIRS = src data
diff --git a/Makefile.in b/Makefile.in
index 6d42920d..55a85578 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -203,7 +203,7 @@ EXTRA_DIST = configure src/cell.h src/hdf5-file.h src/image.h \
src/filters.h src/diffraction-gpu.h src/cl-utils.h \
data/defs.h src/parameters-lcls.tmp \
data/diffraction.cl data/sfac src/likelihood.h src/symmetry.h \
- src/povray.h
+ src/povray.h src/index-priv.h
SUBDIRS = src data
all: config.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 34f8a9a0..81089265 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,7 +22,7 @@ process_hkl_LDADD = @LIBS@
indexamajig_SOURCES = indexamajig.c hdf5-file.c utils.c cell.c image.c \
peaks.c index.c filters.c diffraction.c detector.c \
- sfac.c dirax.c reflections.c
+ sfac.c dirax.c reflections.c templates.c
indexamajig_LDADD = @LIBS@
if HAVE_OPENCL
indexamajig_SOURCES += diffraction-gpu.c cl-utils.c
diff --git a/src/Makefile.in b/src/Makefile.in
index 4716d60e..23079835 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -88,15 +88,15 @@ hdfsee_OBJECTS = $(am_hdfsee_OBJECTS)
hdfsee_DEPENDENCIES =
am__indexamajig_SOURCES_DIST = indexamajig.c hdf5-file.c utils.c \
cell.c image.c peaks.c index.c filters.c diffraction.c \
- detector.c sfac.c dirax.c reflections.c diffraction-gpu.c \
- cl-utils.c
+ detector.c sfac.c dirax.c reflections.c templates.c \
+ diffraction-gpu.c cl-utils.c
@HAVE_OPENCL_TRUE@am__objects_1 = diffraction-gpu.$(OBJEXT) \
@HAVE_OPENCL_TRUE@ cl-utils.$(OBJEXT)
am_indexamajig_OBJECTS = indexamajig.$(OBJEXT) hdf5-file.$(OBJEXT) \
utils.$(OBJEXT) cell.$(OBJEXT) image.$(OBJEXT) peaks.$(OBJEXT) \
index.$(OBJEXT) filters.$(OBJEXT) diffraction.$(OBJEXT) \
detector.$(OBJEXT) sfac.$(OBJEXT) dirax.$(OBJEXT) \
- reflections.$(OBJEXT) $(am__objects_1)
+ reflections.$(OBJEXT) templates.$(OBJEXT) $(am__objects_1)
indexamajig_OBJECTS = $(am_indexamajig_OBJECTS)
indexamajig_DEPENDENCIES =
am__pattern_sim_SOURCES_DIST = pattern_sim.c diffraction.c utils.c \
@@ -259,7 +259,7 @@ process_hkl_SOURCES = process_hkl.c sfac.c statistics.c cell.c utils.c \
process_hkl_LDADD = @LIBS@
indexamajig_SOURCES = indexamajig.c hdf5-file.c utils.c cell.c image.c \
peaks.c index.c filters.c diffraction.c detector.c sfac.c \
- dirax.c reflections.c $(am__append_3)
+ dirax.c reflections.c templates.c $(am__append_3)
indexamajig_LDADD = @LIBS@
@HAVE_GTK_TRUE@hdfsee_SOURCES = hdfsee.c displaywindow.c render.c hdf5-file.c utils.c image.c \
@HAVE_GTK_TRUE@ filters.c
@@ -432,6 +432,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfac.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/statistics.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symmetry.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/templates.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@
.c.o:
diff --git a/src/index-priv.h b/src/index-priv.h
new file mode 100644
index 00000000..3d8c8a22
--- /dev/null
+++ b/src/index-priv.h
@@ -0,0 +1,29 @@
+/*
+ * index-priv.h
+ *
+ * Indexing private data
+ *
+ * (c) 2006-2010 Thomas White <taw@physics.org>
+ *
+ * Part of CrystFEL - crystallography with a FEL
+ *
+ */
+
+
+#ifndef INDEXPRIV_H
+#define INDEXPRIV_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "index.h"
+
+struct _indexingprivate
+{
+ IndexingMethod indm;
+};
+
+
+#endif /* INDEXPRIV_H */
diff --git a/src/index.c b/src/index.c
index 70b23640..7273d64b 100644
--- a/src/index.c
+++ b/src/index.c
@@ -27,6 +27,33 @@
#include "sfac.h"
#include "detector.h"
#include "index.h"
+#include "index-priv.h"
+#include "templates.h"
+
+
+/* Base class constructor for unspecialised indexing private data */
+static IndexingPrivate *indexing_private(IndexingMethod indm)
+{
+ struct _indexingprivate *priv;
+ priv = calloc(1, sizeof(struct _indexingprivate));
+ priv->indm = indm;
+ return priv;
+}
+
+
+IndexingPrivate *prepare_indexing(IndexingMethod indm, UnitCell *cell,
+ const char *filename)
+{
+ switch ( indm ) {
+ case INDEXING_NONE :
+ return indexing_private(indm);
+ case INDEXING_DIRAX :
+ return indexing_private(indm);
+ case INDEXING_TEMPLATE :
+ return generate_templates(cell, filename);
+ }
+ return 0;
+}
static void write_drx(struct image *image)
@@ -60,7 +87,7 @@ static void write_drx(struct image *image)
void index_pattern(struct image *image, UnitCell *cell, IndexingMethod indm,
- int no_match, int verbose)
+ int no_match, int verbose, IndexingPrivate *ipriv)
{
int i;
int nc = 0;
@@ -87,8 +114,16 @@ void index_pattern(struct image *image, UnitCell *cell, IndexingMethod indm,
image->ncells = 0;
/* Index (or not) as appropriate */
- if ( indm == INDEXING_NONE ) return;
- if ( indm == INDEXING_DIRAX ) run_dirax(image);
+ switch ( indm ) {
+ case INDEXING_NONE :
+ return;
+ case INDEXING_DIRAX :
+ run_dirax(image);
+ break;
+ case INDEXING_TEMPLATE :
+ match_templates(image, ipriv);
+ break;
+ }
if ( image->ncells == 0 ) {
STATUS("No candidate cells found.\n");
diff --git a/src/index.h b/src/index.h
index b30db837..1c637f47 100644
--- a/src/index.h
+++ b/src/index.h
@@ -19,16 +19,22 @@
#include "cell.h"
-
+#include "image.h"
typedef enum {
INDEXING_NONE,
INDEXING_DIRAX,
- INDEXING_MATCH
+ INDEXING_TEMPLATE
} IndexingMethod;
+typedef struct _indexingprivate IndexingPrivate;
+
+extern IndexingPrivate *prepare_indexing(IndexingMethod indm, UnitCell *cell,
+ const char *filename);
+
extern void index_pattern(struct image *image, UnitCell *cell,
- IndexingMethod indm, int no_match, int verbose);
+ IndexingMethod indm, int no_match, int verbose,
+ IndexingPrivate *priv);
#endif /* INDEX_H */
diff --git a/src/indexamajig.c b/src/indexamajig.c
index f7eef166..ec4e18c4 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -64,6 +64,7 @@ struct process_args
int config_sa;
struct detector *det;
IndexingMethod indm;
+ IndexingPrivate *ipriv;
const double *intensities;
struct gpu_context *gctx;
@@ -98,6 +99,7 @@ static void show_help(const char *s)
" --indexing=<method> Use 'method' for indexing. Choose from:\n"
" none : no indexing\n"
" dirax : invoke DirAx\n"
+" template : index by template matching\n"
" -g. --geometry=<file> Get detector geometry from file.\n"
"\n\nWith just the above options, this program does not do much of practical "
"use.\nYou should also enable some of the following:\n\n"
@@ -339,7 +341,7 @@ static struct process_result process_image(struct process_args *pargs)
/* Calculate orientation matrix (by magic) */
if ( config_writedrx || (indm != INDEXING_NONE) ) {
index_pattern(&image, cell, indm, config_nomatch,
- config_verbose);
+ config_verbose, pargs->ipriv);
}
/* No cell at this point? Then we're done. */
@@ -478,6 +480,9 @@ int main(int argc, char *argv[])
int i;
pthread_mutex_t output_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t gpu_mutex = PTHREAD_MUTEX_INITIALIZER;
+ char prepare_line[1024];
+ char prepare_filename[1024];
+ IndexingPrivate *ipriv;
/* Long options */
const struct option longopts[] = {
@@ -597,6 +602,8 @@ int main(int argc, char *argv[])
indm = INDEXING_NONE;
} else if ( strcmp(indm_str, "dirax") == 0) {
indm = INDEXING_DIRAX;
+ } else if ( strcmp(indm_str, "template") == 0) {
+ indm = INDEXING_TEMPLATE;
} else {
ERROR("Unrecognised indexing method '%s'\n", indm_str);
return 1;
@@ -615,7 +622,7 @@ int main(int argc, char *argv[])
}
free(geometry);
- if ( !config_nomatch ) {
+ if ( (!config_nomatch) || (indm == INDEXING_TEMPLATE) ) {
cell = load_cell_from_pdb(pdb);
if ( cell == NULL ) {
ERROR("Couldn't read unit cell (from %s)\n", pdb);
@@ -627,6 +634,21 @@ int main(int argc, char *argv[])
}
free(pdb);
+ /* Get first filename and use it to set up the indexing */
+ rval = fgets(prepare_line, 1023, fh);
+ if ( rval == NULL ) {
+ ERROR("Failed to get filename to prepare indexing.\n");
+ return 1;
+ }
+ chomp(prepare_line);
+ snprintf(prepare_filename, 1023, "%s%s", prefix, prepare_line);
+ ipriv = prepare_indexing(indm, cell, prepare_filename);
+ if ( ipriv == NULL ) {
+ ERROR("Failed to prepare indexing.\n");
+ return 1;
+ }
+ rewind(fh);
+
gsl_set_error_handler_off();
n_images = 0;
n_hits = 0;
@@ -673,6 +695,7 @@ int main(int argc, char *argv[])
pargs->config_sa = config_sa;
pargs->cell = cell;
pargs->det = det;
+ pargs->ipriv = ipriv;
pargs->indm = indm;
pargs->intensities = intensities;
pargs->gctx = gctx;
diff --git a/src/templates.c b/src/templates.c
new file mode 100644
index 00000000..db28b9b9
--- /dev/null
+++ b/src/templates.c
@@ -0,0 +1,41 @@
+/*
+ * templates.c
+ *
+ * Indexing by template matching
+ *
+ * (c) 2006-2010 Thomas White <taw@physics.org>
+ *
+ * Part of CrystFEL - crystallography with a FEL
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "index.h"
+#include "index-priv.h"
+
+
+/* Private data for template indexing */
+struct _indexingprivate_template
+{
+ struct _indexingprivate base;
+};
+
+
+IndexingPrivate *generate_templates(UnitCell *cell, const char *filename)
+{
+ struct _indexingprivate_template *priv;
+
+ priv = calloc(1, sizeof(struct _indexingprivate_template));
+ priv->base.indm = INDEXING_TEMPLATE;
+
+ return (struct _indexingprivate *)priv;
+}
+
+
+void match_templates(struct image *image, IndexingPrivate *ipriv)
+{
+}
diff --git a/src/templates.h b/src/templates.h
new file mode 100644
index 00000000..dad46843
--- /dev/null
+++ b/src/templates.h
@@ -0,0 +1,30 @@
+/*
+ * templates.h
+ *
+ * Indexing by template matching
+ *
+ * (c) 2006-2010 Thomas White <taw@physics.org>
+ *
+ * Part of CrystFEL - crystallography with a FEL
+ *
+ */
+
+#ifndef TEMPLATES_H
+#define TEMPLATES_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "index.h"
+#include "image.h"
+#include "cell.h"
+
+extern IndexingPrivate *generate_templates(UnitCell *cell,
+ const char *filename);
+
+
+extern void match_templates(struct image *image, IndexingPrivate *ipriv);
+
+#endif /* TEMPLATES_H */