|
@@ -1,4 +1,5 @@
|
|
|
#include <stdlib.h>
|
|
|
+#include <stdio.h>
|
|
|
#include <string.h>
|
|
|
#include <ufo/ufo.h>
|
|
|
#include "reco.h"
|
|
@@ -14,6 +15,8 @@ typedef struct {
|
|
|
UfoTaskNode *ifft;
|
|
|
UfoTaskNode *conv;
|
|
|
UfoTaskNode *reco;
|
|
|
+ UfoTaskNode *slice;
|
|
|
+ UfoTaskNode *stats;
|
|
|
UfoTaskNode *writer;
|
|
|
|
|
|
/* interactive */
|
|
@@ -21,6 +24,9 @@ typedef struct {
|
|
|
UfoTaskNode *output;
|
|
|
UfoTaskNode *input;
|
|
|
Params *params;
|
|
|
+
|
|
|
+ /* stats file */
|
|
|
+ FILE *stats_fp;
|
|
|
} LaminoData;
|
|
|
|
|
|
|
|
@@ -80,12 +86,23 @@ params_okay (Params *params)
|
|
|
params->py < G_MAXDOUBLE;
|
|
|
}
|
|
|
|
|
|
-gboolean
|
|
|
+static gboolean
|
|
|
with_flat_field_correction (Params *params)
|
|
|
{
|
|
|
return params->darks != NULL && params->flats != NULL;
|
|
|
}
|
|
|
|
|
|
+static void
|
|
|
+stats_finished (UfoTaskNode *stats, UfoBuffer *result, LaminoData *user)
|
|
|
+{
|
|
|
+ gfloat *data;
|
|
|
+ gchar buffer[128];
|
|
|
+
|
|
|
+ data = ufo_buffer_get_host_array (result, NULL);
|
|
|
+ g_snprintf (buffer, 128, "%.12f\n", data[0]);
|
|
|
+ fwrite (buffer, 1, strlen (buffer), user->stats_fp);
|
|
|
+}
|
|
|
+
|
|
|
static LaminoData *
|
|
|
reco_graph_new (Params *params)
|
|
|
{
|
|
@@ -96,6 +113,7 @@ reco_graph_new (Params *params)
|
|
|
gdouble theta_rad;
|
|
|
gdouble angle_step;
|
|
|
guint fwidth;
|
|
|
+ gchar *stats_name;
|
|
|
|
|
|
data = g_malloc0 (sizeof (LaminoData));
|
|
|
|
|
@@ -110,6 +128,8 @@ reco_graph_new (Params *params)
|
|
|
data->ifft = make_task (data->pm, "ifft");
|
|
|
data->conv = make_task (data->pm, "lamino-conv");
|
|
|
data->reco = make_task (data->pm, "lamino-bp");
|
|
|
+ data->slice = make_task (data->pm, "slice");
|
|
|
+ data->stats = make_task (data->pm, "measure");
|
|
|
data->writer = make_task (data->pm, "writer");
|
|
|
|
|
|
fwidth = ((guint) params->px) * 2;
|
|
@@ -169,17 +189,30 @@ reco_graph_new (Params *params)
|
|
|
"vol-z-spacing", params->z_spacing,
|
|
|
NULL);
|
|
|
|
|
|
+ g_object_set (data->stats,
|
|
|
+ "pass-through", TRUE,
|
|
|
+ NULL);
|
|
|
+
|
|
|
g_object_set (data->writer,
|
|
|
"filename", params->output,
|
|
|
+ "single-file", TRUE,
|
|
|
NULL);
|
|
|
|
|
|
+ g_signal_connect (data->stats, "result", G_CALLBACK (stats_finished), data);
|
|
|
+
|
|
|
ufo_task_graph_connect_nodes (data->graph, data->pad, data->fft1);
|
|
|
ufo_task_graph_connect_nodes (data->graph, data->ramp, data->fft2);
|
|
|
ufo_task_graph_connect_nodes_full (data->graph, data->fft1, data->conv, 0);
|
|
|
ufo_task_graph_connect_nodes_full (data->graph, data->fft2, data->conv, 1);
|
|
|
ufo_task_graph_connect_nodes (data->graph, data->conv, data->ifft);
|
|
|
ufo_task_graph_connect_nodes (data->graph, data->ifft, data->reco);
|
|
|
- ufo_task_graph_connect_nodes (data->graph, data->reco, data->writer);
|
|
|
+ ufo_task_graph_connect_nodes (data->graph, data->reco, data->slice);
|
|
|
+ ufo_task_graph_connect_nodes (data->graph, data->slice, data->stats);
|
|
|
+ ufo_task_graph_connect_nodes (data->graph, data->stats, data->writer);
|
|
|
+
|
|
|
+ stats_name = g_strdup_printf ("%s.stats", params->output);
|
|
|
+ data->stats_fp = fopen (stats_name, "wb");
|
|
|
+ g_free (stats_name);
|
|
|
|
|
|
return data;
|
|
|
}
|
|
@@ -195,7 +228,11 @@ reco_graph_free (LaminoData *data)
|
|
|
g_object_unref (data->fft2);
|
|
|
/* g_object_unref (conv); */
|
|
|
g_object_unref (data->reco);
|
|
|
+ g_object_unref (data->slice);
|
|
|
+ g_object_unref (data->stats);
|
|
|
g_object_unref (data->writer);
|
|
|
+
|
|
|
+ fclose (data->stats_fp);
|
|
|
}
|
|
|
|
|
|
static void
|