Index: /trunk/ppImage/src/Makefile.am
===================================================================
--- /trunk/ppImage/src/Makefile.am	(revision 24228)
+++ /trunk/ppImage/src/Makefile.am	(revision 24229)
@@ -54,4 +54,5 @@
 	ppImageDefineFile.c \
 	ppImageSetMaskBits.c \
+	ppImageParityFlip.c \
 	ppImageCheckCTE.c \
 	ppImageFileCheck.c \
Index: /trunk/ppImage/src/ppImage.h
===================================================================
--- /trunk/ppImage/src/ppImage.h	(revision 24228)
+++ /trunk/ppImage/src/ppImage.h	(revision 24229)
@@ -43,4 +43,5 @@
     bool doStats;                       // call ppStats on the image
     bool checkCTE;                      // measure pixel-based variance
+    bool applyParity;			// Apply Cell parities
 
     bool doCrosstalkMeasure;            // measure crosstalk signal
@@ -118,4 +119,7 @@
 bool ppImageSetMaskBits (pmConfig *config, ppImageOptions *options);
 
+// apply the cell flips to the input data before analysis
+bool ppImageParityFlip (pmConfig *config, const ppImageOptions *options, const pmFPAview *view);
+
 // Loop over the input
 bool ppImageLoop(pmConfig *config, ppImageOptions *options);
Index: /trunk/ppImage/src/ppImageLoop.c
===================================================================
--- /trunk/ppImage/src/ppImageLoop.c	(revision 24228)
+++ /trunk/ppImage/src/ppImageLoop.c	(revision 24229)
@@ -98,4 +98,12 @@
                     continue;
                 }
+
+                // perform the detrend analysis
+                if (!ppImageParityFlip(config, options, view)) {
+                    ESCAPE("Unable to detrend readout");
+                }
+
+		// XXX TEST:
+		// psphotSaveImage (NULL, readout->image, "test.image.fits");
 
                 // XXX set the options->*Mask values here (after the mask images have been loaded
Index: /trunk/ppImage/src/ppImageOptions.c
===================================================================
--- /trunk/ppImage/src/ppImageOptions.c	(revision 24228)
+++ /trunk/ppImage/src/ppImageOptions.c	(revision 24229)
@@ -36,4 +36,5 @@
     options->doStats         = false;   // Measure and save image statistics
     options->checkCTE        = false;   // Measure pixel-based variance
+    options->applyParity     = false;   // Apply Cell parities
 
     // output files requested
@@ -229,4 +230,6 @@
     }
 
+    options->applyParity = psMetadataLookupBool(NULL, recipe, "APPLY.CELL.PARITY");
+
     // binned image options
     options->xBin1 = psMetadataLookupS32(&status, recipe, "BIN1.XBIN");
