Index: branches/eam_branches/psphot.stack.20100120/src/psphotSourceFreePixels.c
===================================================================
--- branches/eam_branches/psphot.stack.20100120/src/psphotSourceFreePixels.c	(revision 26642)
+++ branches/eam_branches/psphot.stack.20100120/src/psphotSourceFreePixels.c	(revision 26688)
@@ -1,7 +1,35 @@
 # include "psphotInternal.h"
 
-void psphotSourceFreePixels (psArray *sources) {
+bool psphotSourceFreePixels (pmConfig *config, const pmFPAview *view)
+{
+    bool status = true;
 
-    if (!sources) return;
+    int num = psMetadataAddS32 (&status, config->arguments, "PSPHOT.INPUT.NUM");
+    psAssert (status, "programming error: must define PSPHOT.INPUT.NUM");
+
+    // loop over the available readouts
+    for (int i = 0; i < num; i++) {
+	if (!psphotSourceFreePixelsReadout (config, view, "PSPHOT.INPUT", i)) {
+            psError (PSPHOT_ERR_CONFIG, false, "failed on saturated star deblend analysis for PSPHOT.INPUT entry %d", i);
+	    return false;
+	}
+    }
+    return true;
+}
+
+bool psphotSourceFreePixelsReadout(pmConfig *config, const pmFPAview *view, const char *filename, int index) {
+
+    // find the currently selected readout
+    pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest
+    psAssert (readout, "missing file?");
+
+    pmReadout *readout = pmFPAviewThisReadout(view, file->fpa);
+    psAssert (readout, "missing readout?");
+
+    pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
+    psAssert (detections, "missing detections?");
+
+    psArray *sources = detections->allSources;
+    psAssert (sources, "missing sources?");
 
     for (int i = 0; i < sources->n; i++) {
@@ -9,4 +37,4 @@
 	pmSourceFreePixels (source);
     }
-    return;
+    return true;
 }
