aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-08-29 17:41:06 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-08-29 17:41:06 +0000
commit9852df6e6d82a75d52b7269ceeebeca7ee02ead3 (patch)
tree08b76e19834f2131bd997ed2dfc40f910881f9d8
parent57645119798cd7db0d64807d8b617e13ac5e65c8 (diff)
Give image centres in qdrp.rc if desired
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@90 bf6ca9ba-c028-0410-8290-897cf20841d1
-rw-r--r--src/control.c17
-rw-r--r--src/control.h4
-rw-r--r--src/ipr.c7
-rw-r--r--src/main.c19
-rw-r--r--src/prealign.c5
-rw-r--r--src/qdrp.c15
6 files changed, 45 insertions, 22 deletions
diff --git a/src/control.c b/src/control.c
index c79ca17..ac3de0b 100644
--- a/src/control.c
+++ b/src/control.c
@@ -10,6 +10,7 @@
*/
#include <inttypes.h>
+#include <stdlib.h>
#include "control.h"
@@ -22,6 +23,8 @@ int control_add_image(ControlContext *ctx, uint16_t *image, int width, int heigh
ctx->images[ctx->n_images].height = height;
ctx->images[ctx->n_images].lambda = ctx->lambda;
ctx->images[ctx->n_images].fmode = ctx->fmode;
+ ctx->images[ctx->n_images].x_centre = ctx->x_centre;
+ ctx->images[ctx->n_images].y_centre = ctx->y_centre;
if ( ctx->fmode == FORMULATION_PIXELSIZE ) {
ctx->images[ctx->n_images].pixel_size = ctx->pixel_size;
@@ -39,3 +42,17 @@ int control_add_image(ControlContext *ctx, uint16_t *image, int width, int heigh
}
+ControlContext *control_ctx_new() {
+
+ ControlContext *ctx;
+
+ ctx = malloc(sizeof(ControlContext));
+
+ ctx->x_centre = 0;
+ ctx->y_centre = 0;
+ ctx->have_centres = 0;
+
+ return ctx;
+
+}
+
diff --git a/src/control.h b/src/control.h
index 5ab8efd..bae9f4b 100644
--- a/src/control.h
+++ b/src/control.h
@@ -81,6 +81,7 @@ typedef struct cctx_struct {
PeakSearchMode psmode;
unsigned int prealign;
unsigned int savecache;
+ unsigned int have_centres;
/* Input filename */
char *filename;
@@ -92,6 +93,8 @@ typedef struct cctx_struct {
double resolution;
double lambda;
double pixel_size;
+ double x_centre;
+ double y_centre;
/* QDRP Parser flags */
unsigned int started;
@@ -116,6 +119,7 @@ typedef struct cctx_struct {
} ControlContext;
extern int control_add_image(ControlContext *ctx, uint16_t *image, int width, int height, double tilt);
+extern ControlContext *control_ctx_new(void);
#endif /* CONTROL_H */
diff --git a/src/ipr.c b/src/ipr.c
index 0043eec..6df83c3 100644
--- a/src/ipr.c
+++ b/src/ipr.c
@@ -205,9 +205,9 @@ static ReflectionContext *ipr_generate(ControlContext *ctx, Basis *basis) {
}
ordered = reflection_init();
- //basis->a.x = 5e9; basis->a.y = 0.0; basis->a.z = 0.0;
- //basis->b.x = 0.0; basis->b.y = 5e9; basis->b.z = 0.0;
- //basis->c.x = 0.0; basis->c.y = 0.0; basis->c.z = 3e9;
+ basis->a.x = 5e9; basis->a.y = 0.0; basis->a.z = 0.0;
+ basis->b.x = 0.0; basis->b.y = 5e9; basis->b.z = 0.0;
+ basis->c.x = 0.0; basis->c.y = 0.0; basis->c.z = 3e9;
for ( h=-30; h<=30; h++ ) {
for ( k=-30; k<=30; k++ ) {
for ( l=-30; l<=30; l++ ) {
@@ -263,6 +263,7 @@ int ipr_refine(ControlContext *ctx) {
/* Select an image */
i = ipr_random_image(ctx);
+ i = 45; /* Temporary! */
cur = imagedisplay_open(ctx->images[i], "Current Image", IMAGEDISPLAY_SHOW_CENTRE | IMAGEDISPLAY_SHOW_TILT_AXIS);
refl = reproject_get_reflections(ctx->images[i], &n, lat, ctx);
diff --git a/src/main.c b/src/main.c
index f957eb3..0750f14 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,6 +32,7 @@
#include "cache.h"
#include "mapping.h"
#include "prealign.h"
+#include "control.h"
void main_do_reconstruction(ControlContext *ctx) {
@@ -212,7 +213,7 @@ int main(int argc, char *argv[]) {
}
filename = basename(argv[1]);
- ctx = malloc(sizeof(ControlContext));
+ ctx = control_ctx_new();
type = INPUT_NONE;
if ( qdrp_is_qdrprc(filename) ) {
@@ -229,22 +230,6 @@ int main(int argc, char *argv[]) {
return 1;
}
- #if 0
- if ( strcmp(filename, "qdrp.rc") == 0 ) {
- printf("QDRP input file detected.\n");
- ctx->inputfiletype = INPUT_QDRP;
- } else if ( strcmp(filename+(strlen(filename)-4), ".mrc") == 0 ) {
- printf("MRC tomography file detected.\n");
- ctx->inputfiletype = INPUT_MRC;
- } else if ( strcmp(filename, "reflect.cache") == 0 ) {
- printf("reflect.cache detected.\n");
- ctx->inputfiletype = INPUT_CACHE;
- } else {
- fprintf(stderr, "Unrecognised input file type\n");
- return 1;
- }
- #endif
-
ctx->filename = strdup(argv[1]);
ctx->n_images = 0;
diff --git a/src/prealign.c b/src/prealign.c
index a89b8de..b72943c 100644
--- a/src/prealign.c
+++ b/src/prealign.c
@@ -61,6 +61,7 @@ void prealign_do_series(ControlContext *ctx) {
PreAlignBlock *pb;
+ ctx->have_centres = 1; /* Inhibit "centre-finding by stacking" */
pb = malloc(sizeof(PreAlignBlock));
pb->n = 0;
pb->ctx = ctx;
@@ -94,7 +95,7 @@ void prealign_sum_stack(ControlContext *ctx) {
memset(image_total, 0, twidth * theight * sizeof(uint16_t));
/* Add the image stack together */
- if ( !ctx->prealign ) {
+ if ( !ctx->have_centres ) {
int max_x, max_y;
uint16_t max_val;
@@ -135,7 +136,7 @@ void prealign_sum_stack(ControlContext *ctx) {
total_record.y_centre = max_y;
} else {
-
+
for ( i=0; i<ctx->n_images; i++ ) {
int xoffs, yoffs;
diff --git a/src/qdrp.c b/src/qdrp.c
index c46c1ae..86384bd 100644
--- a/src/qdrp.c
+++ b/src/qdrp.c
@@ -182,6 +182,21 @@ static int qdrp_parseline(ControlContext *ctx, const char *line) {
}
+ if ( strncasecmp(line+pos, "centre", 6) == 0 ) {
+
+ float xc, yc;
+
+ if ( sscanf(line+pos, "centre %f %f", &xc, &yc) != 2 ) {
+ fprintf(stderr, "Couldn't parse 'centre' line\n");
+ return 1;
+ }
+ ctx->x_centre = xc;
+ ctx->y_centre = yc;
+ ctx->have_centres = 1;
+ printf("QD: centre %.2f, %.2f px\n", ctx->x_centre, ctx->y_centre);
+
+ }
+
}
return 0;