Index: branches/eam_branches/ipp-20220316/ppImage/src/ppImageDetrendPattern.c
===================================================================
--- branches/eam_branches/ipp-20220316/ppImage/src/ppImageDetrendPattern.c	(revision 42161)
+++ branches/eam_branches/ipp-20220316/ppImage/src/ppImageDetrendPattern.c	(revision 42166)
@@ -327,2 +327,26 @@
 }
 
+psVector *ppImageDetrendPatternCellFailures(pmFPAfile *input, const pmFPAview *inputView) {
+    
+    bool status = false;
+    pmCell *cell = NULL;
+    
+    pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
+    *view = *inputView;
+
+    // extract the MEDIAN_CELL_BACKGROUND values to check for problems
+    psVector *cellBackground = psVectorAllocEmpty (64, PS_DATA_F32);
+    while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
+	if (!cell->process || !cell->file_exists || !cell->data_exists) {
+	    psVectorAppend (cellBackground, NAN);
+	    continue;
+	}
+	
+	// select the HDU for this cell
+	pmHDU *hdu = pmHDUFromCell(cell);  // HDU of interest
+	
+	psF32 value = psMetadataLookupF32(&status, hdu->header, "BACK_VAL");
+	psVectorAppend (cellBackground, value);
+    }
+    return cellBackground;
+}
Index: branches/eam_branches/ipp-20220316/ppImage/src/ppImageLoop.c
===================================================================
--- branches/eam_branches/ipp-20220316/ppImage/src/ppImageLoop.c	(revision 42161)
+++ branches/eam_branches/ipp-20220316/ppImage/src/ppImageLoop.c	(revision 42166)
@@ -170,4 +170,12 @@
             ESCAPE("Unable to free detrend images");
         }
+
+        // Apply the pattern correction
+        // XX if (options->checkCellFailures) {
+        // XX   if (!ppImageDetrendPatternCellFailures(config,chip,view,options)) {
+        // XX     ESCAPE("Unable to apply pattern corrections");
+        // XX   }
+        // XX }
+
 
         // Apply the fringe correction
