Index: trunk/ppMerge/src/ppMergeOptions.c
===================================================================
--- trunk/ppMerge/src/ppMergeOptions.c	(revision 5860)
+++ trunk/ppMerge/src/ppMergeOptions.c	(revision 5862)
@@ -1,3 +1,3 @@
-# include "ppImage.h"
+# include "ppMerge.h"
 
 // XXX EAM : optionally choose the mask image based on the detrend database
@@ -26,17 +26,6 @@
     }
 
-    // how do we calculate the merge stack?
-    options->mergeStats = NULL;
-    psString stat = psMetadataLookupStr(NULL, config->recipe, "MERGE.STAT");
-    if (! strcasecmp(stat, "MEAN")) {
-      options->mergeStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
-    } else if (! strcasecmp(stat, "MEDIAN")) {
-      options->mergeStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
-    } else {
-      psErrorStackPrint(stderr, "MERGE.STAT (%s) is not one of MEAN, MEDIAN: assuming MEAN\n", stat);
-      options->mergeStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
-    }
-
-    // mask - recipe options
+    // global pixel mask
+    options->doMask = false;
     if (psMetadataLookupBool(NULL, config->recipe, "MASK")) {
 	data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask");
@@ -49,4 +38,41 @@
     }
 
+    // how do we calculate the merge stack?
+    psStatsOptions mergeStats = 0;
+    psString stat = psMetadataLookupStr(NULL, config->recipe, "MERGE.STAT");
+    if (! strcasecmp(stat, "MEAN")) {
+	mergeStats = PS_STAT_SAMPLE_MEAN;
+    } else if (! strcasecmp(stat, "MEDIAN")) {
+	mergeStats = PS_STAT_SAMPLE_MEDIAN;
+    } else {
+	psAbort ("merge", "MERGE.STAT (%s) is not one of MEAN, MEDIAN\n", stat);
+    }
+    options->combineParams = pmCombineParamsAlloc (mergeStats);
+
+    // other merge stack options
+    options->applyZeroScale = psMetadataLookupBool(NULL, config->recipe, "MERGE.RESCALE");
+
+    int nKeep = psMetadataLookupS32(&status, config->recipe, "MERGE.NKEEP");
+    if (status && nKeep > 0) {
+	options->combineParams->nKeep = nKeep;
+    }
+
+    float fracHigh = psMetadataLookupF32(&status, config->recipe, "MERGE.FRAC.HIGH");
+    if (status) {
+	options->combineParams->fracHigh = fracHigh;
+    }
+
+    float fracLow = psMetadataLookupF32(&status, config->recipe, "MERGE.FRAC.LOW");
+    if (status) {
+	options->combineParams->fracLow = fracLow;
+    }
+
+    // XXX need to set the masking value somehow...
+
+    // gain and readnoise come from camera parameters and depend on chip/cell
+    // XXX drop these from the options structure?
+    options->gain = 1.0;
+    options->readnoise = 0.0;
+
     return true;
 }
