Index: /trunk/ppMerge/src/ppMergeMask.c
===================================================================
--- /trunk/ppMerge/src/ppMergeMask.c	(revision 15861)
+++ /trunk/ppMerge/src/ppMergeMask.c	(revision 15862)
@@ -110,5 +110,5 @@
 
             pmReadout *roOut = pmReadoutAlloc(cellOut); // Output readout
-            roOut->mask = pmMaskIdentifyBadPixels(suspect, options->maskBad, options->combine->maskVal);
+            roOut->mask = pmMaskIdentifyBadPixels(suspect, options->combine->maskVal, filenames->n, options->maskBad, options->maskMode);
             roOut->data_exists = cellOut->data_exists = chipOut->data_exists = true;
 
Index: /trunk/ppMerge/src/ppMergeOptions.c
===================================================================
--- /trunk/ppMerge/src/ppMergeOptions.c	(revision 15861)
+++ /trunk/ppMerge/src/ppMergeOptions.c	(revision 15862)
@@ -50,4 +50,5 @@
     options->maskSuspect = 5.0;
     options->maskBad = 10.0;
+    options->maskMode = PM_MASK_ID_VALUE;
     options->onOff = 0;
     options->combine = pmCombineParamsAlloc(PS_STAT_SAMPLE_MEAN);
@@ -235,4 +236,18 @@
     }
 
+    const char *maskMode = psMetadataLookupStr(NULL, recipe, "MASK.MODE"); // The type of calibration frame
+    if (!maskMode) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "No mask mode specified in recipe.");
+        psFree(options);
+        return NULL;
+    }
+
+    options->maskMode = pmMaskIdentifyModeFromString (maskMode);
+    if (options->maskMode == PM_MASK_ID_NONE) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "invalid mask mode %s.", maskMode);
+        psFree(options);
+        return NULL;
+    }
+
 #if 0
     // Or you can set them individually
Index: /trunk/ppMerge/src/ppMergeOptions.h
===================================================================
--- /trunk/ppMerge/src/ppMergeOptions.h	(revision 15861)
+++ /trunk/ppMerge/src/ppMergeOptions.h	(revision 15862)
@@ -37,4 +37,5 @@
     float maskSuspect;                  // Threshold for identifying suspect pixels
     float maskBad;                      // Threshold for identifying bad pixels
+    pmMaskIdentifyMode maskMode;	// how to set the limit based on the threshold value above?
     ppOnOff onOff;                      // On/off pairs?
     pmCombineParams *combine;           // Combination parameters
