Index: trunk/psphot/src/psphotSourceStats.c
===================================================================
--- trunk/psphot/src/psphotSourceStats.c	(revision 15405)
+++ trunk/psphot/src/psphotSourceStats.c	(revision 16820)
@@ -1,5 +1,5 @@
 # include "psphotInternal.h"
 
-psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *peaks, psMaskType maskVal, psMaskType mark)
+psArray *psphotSourceStats (pmReadout *readout, psMetadata *recipe, pmDetections *detections)
 {
     bool     status  = false;
@@ -8,4 +8,12 @@
 
     psTimerStart ("psphot");
+
+    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
+    psMaskType maskVal = psMetadataLookupU8(&status, recipe, "MASK.PSPHOT"); // Mask value for bad pixels
+    assert (maskVal);
+
+    // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)
+    psMaskType mark = psMetadataLookupU8(&status, recipe, "MASK.MARK"); // Mask value for bad pixels
+    assert (mark);
 
     // determine properties (sky, moments) of initial sources
@@ -20,4 +28,6 @@
     char *breakPt  = psMetadataLookupStr (&status, recipe, "BREAK_POINT");
     if (!status) return NULL;
+
+    psArray *peaks = detections->peaks;
 
     sources = psArrayAllocEmpty (peaks->n);
