Index: trunk/psModules/src/detrend/pmMaskBadPixels.c
===================================================================
--- trunk/psModules/src/detrend/pmMaskBadPixels.c	(revision 15898)
+++ trunk/psModules/src/detrend/pmMaskBadPixels.c	(revision 15910)
@@ -82,9 +82,8 @@
 
 psImage *pmMaskFlagSuspectPixels(psImage *out, const pmReadout *readout, float rej,
-                                 psMaskType maskVal, float frac, psRandom *rng)
+                                 psMaskType maskVal)
 {
     PS_ASSERT_PTR_NON_NULL(readout, NULL);
     PS_ASSERT_FLOAT_LARGER_THAN(rej, 0.0, NULL);
-    PS_ASSERT_FLOAT_WITHIN_RANGE(frac, 0.0, 1.0, NULL);
     PS_ASSERT_IMAGE_NON_NULL(readout->image, NULL);
     PS_ASSERT_IMAGE_NON_EMPTY(readout->image, NULL);
@@ -101,28 +100,19 @@
     }
 
+    bool status;
     psImage *image = readout->image;    // Image of interest
     psImage *mask = readout->mask;      // Corresponding mask
 
-    if (rng) {
-        psMemIncrRefCounter(rng);
-    } else {
-        rng = psRandomAlloc(PS_RANDOM_TAUS, 0);
-    }
-
-    // XXX note that this now will accept any of several stats options
-    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV);
-    stats->nSubsample = frac * image->numCols * image->numRows;
-    if (!psImageBackground(stats, NULL, image, mask, maskVal, rng) ||
-            !isfinite(stats->robustMedian) || !isfinite(stats->robustUQ) || !isfinite(stats->robustLQ)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to measure image statistics.\n");
-        psFree(stats);
-        psFree(rng);
-        return NULL;
-    }
-    psFree(rng);
-
-    float median = stats->robustMedian; // Median value
-    float stdev = stats->robustStdev; // Estimate of the standard deviation
-    psFree(stats);
+    float median = psMetadataLookupF32 (&status, readout->analysis, "READOUT.MEDIAN");
+    if (!status) {
+	psError(PS_ERR_PROGRAMMING, true, "Missing READOUT.MEDIAN from readout analysis data");
+	return NULL;
+    }
+
+    float stdev  = psMetadataLookupF32 (&status, readout->analysis, "READOUT.STDEV");
+    if (!status) {
+	psError(PS_ERR_PROGRAMMING, true, "Missing READOUT.STDEV from readout analysis data");
+	return NULL;
+    }
 
     psTrace ("psModules.detrend", 3, "suspect: %f +/- %f\n", median, stdev);
Index: trunk/psModules/src/detrend/pmMaskBadPixels.h
===================================================================
--- trunk/psModules/src/detrend/pmMaskBadPixels.h	(revision 15898)
+++ trunk/psModules/src/detrend/pmMaskBadPixels.h	(revision 15910)
@@ -5,6 +5,6 @@
  * @author Eugene Magnier, IfA
  *
- * @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-12-16 22:22:06 $
+ * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-12-24 21:10:28 $
  * Copyright 2004 Institute for Astronomy, University of Hawaii
  */
@@ -42,13 +42,13 @@
 ///
 /// Pixels more than "rej" standard deviations from the background level (in flat-fielded,
-/// background-subtracted images) have the corresponding pixel in the "suspect pixels" image incremented.
-/// After accumulating over a suitable sample of images, bad pixels should have a high value in the suspect
-/// pixels image, allowing them to be identified.  The suspect pixels image is of type S32.
+/// background-subtracted images) have the corresponding pixel in the "suspect pixels" image
+/// incremented.  After accumulating over a suitable sample of images, bad pixels should have a
+/// high value in the suspect pixels image, allowing them to be identified.  The suspect pixels
+/// image is of type S32.  The relevant median and standard deviation must be supplied in the
+/// readout->analysis metadata as READOUT.MEDIAN, READOUT.STDEVe
 psImage *pmMaskFlagSuspectPixels(psImage *out, ///< Suspected bad pixels image, or NULL
                                  const pmReadout *readout, ///< Readout to inspect
                                  float rej, ///< Rejection threshold (standard deviations)
-                                 psMaskType maskVal, ///< Mask value for statistics
-                                 float frac, ///< Fraction of pixels to consider
-                                 psRandom *rng ///< Random number generator
+                                 psMaskType maskVal ///< Mask value for statistics
                                 );
 
