Commit 4417dabb authored by Thomas White's avatar Thomas White
Browse files

indexamajig: Prepare for other indexing methods which need initial setup

parent 64d06800
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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:
......
/*
* 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 */
......@@ -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");
......
......@@ -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 */
......@@ -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;
......
/*
* 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)
{
}
/*
* 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 */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment