Index: trunk/psModules/src/detrend/pmFringeStats.c
===================================================================
--- trunk/psModules/src/detrend/pmFringeStats.c	(revision 9541)
+++ trunk/psModules/src/detrend/pmFringeStats.c	(revision 9615)
@@ -1,12 +1,2 @@
-/** @file  pmFringeStats.c
- *
- *  @author Eugene Magnier, IfA
- *
- *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-13 22:11:02 $
- *
- *  Copyright 2004 IfA
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -130,5 +120,5 @@
     // We need to write:
     // Scalars: dX, dY, nX, nY
-    // Vectors: x, y
+    // Vectors: x, y, mask
 
     psMetadata *scalars = psMetadataAlloc(); // Metadata to hold the scalars; will be the header
@@ -149,4 +139,9 @@
         psMetadataAddF32(row, PS_LIST_TAIL, "x", PS_META_REPLACE, "Fringe position in x", x->data.F32[i]);
         psMetadataAddF32(row, PS_LIST_TAIL, "y", PS_META_REPLACE, "Fringe position in y", y->data.F32[i]);
+        psU8 maskValue = 0;
+        if (mask && mask->data.U8[i]) {
+            maskValue = 0xff;
+        }
+        psMetadataAddU8(row, PS_LIST_TAIL, "mask", PS_META_REPLACE, "Mask", maskValue);
         table->data[i] = row;
     }
@@ -202,5 +197,5 @@
     psFree(headerCopy);
 
-    // Now the vectors: x, y
+    // Now the vectors: x, y, mask
     psArray *table = psFitsReadTable(fits); // The table
     long numRows = table->n;            // Number of rows
@@ -209,7 +204,9 @@
     psVector *x = psVectorAlloc(numRows, PS_TYPE_F32); // x position
     psVector *y = psVectorAlloc(numRows, PS_TYPE_F32); // y position
-    x->n = y->n = numRows;
+    psVector *mask = psVectorAlloc(numRows, PS_TYPE_U8); // mask
+    x->n = y->n = mask->n = numRows;
     regions->x = x;
     regions->y = y;
+    regions->mask = mask;
 
     #define READ_REGIONS_ROW(VECTOR, TYPE, NAME, DESCRIPTION) \
@@ -227,4 +224,5 @@
         READ_REGIONS_ROW(x, F32, "x", "x position");
         READ_REGIONS_ROW(y, F32, "y", "y position");
+        READ_REGIONS_ROW(mask, U8, "mask", "mask");
     }
     psFree(table);
@@ -260,5 +258,5 @@
 }
 
-pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, pmReadout *readout, psMaskType maskVal)
+pmFringeStats *pmFringeStatsMeasure(pmFringeRegions *fringe, const pmReadout *readout, psMaskType maskVal)
 {
     PS_ASSERT_PTR_NON_NULL(fringe, NULL);
@@ -762,5 +760,6 @@
         scaleMeasure(scale, science, fringes); // The scales
         psTrace("psModules.detrend", 1, "Fringe scales after iteration %d:\n", iter);
-        psTrace("psModules.detrend", 1, "Background: %f %f\n", scale->coeff->data.F32[0], scale->coeffErr->data.F32[0]);
+        psTrace("psModules.detrend", 1, "Background: %f %f\n", scale->coeff->data.F32[0],
+                scale->coeffErr->data.F32[0]);
         for (int i = 0; i < scale->nFringeFrames; i++) {
             psTrace("psModules.detrend", 1, "%d: %f %f\n", i, scale->coeff->data.F32[i + 1],
@@ -771,5 +770,6 @@
         iterClip = clipRegions(diff, mask, rej); // Number clipped
         numClipped += iterClip;
-        psTrace("psModules.detrend", 9, "Clipped: %d\tFrac: %f\n", iterClip, (float)numClipped/(float)numRegions);
+        psTrace("psModules.detrend", 9, "Clipped: %d\tFrac: %f\n", iterClip,
+                (float)numClipped/(float)numRegions);
     } while (iterClip > 0 && iter < nIter && (float)numClipped/(float)numRegions <= 1.0 - keepFrac);
     psFree(diff);
