Index: trunk/ppImage/src/ppImageDetrendPattern.c
===================================================================
--- trunk/ppImage/src/ppImageDetrendPattern.c	(revision 25930)
+++ trunk/ppImage/src/ppImageDetrendPattern.c	(revision 26682)
@@ -5,65 +5,78 @@
 #include "ppImage.h"
 
-#define ESCAPE(MESSAGE) { \
-  psError(PS_ERR_UNKNOWN, false, MESSAGE); \
-  psFree(view); \
-  return false; \
+#define ESCAPE(MESSAGE) {                               \
+        psError(PS_ERR_UNKNOWN, false, MESSAGE);        \
+        psFree(view);                                   \
+        return false;                                   \
+    }
+
+bool ppImageDetrendPatternApply(pmConfig *config, pmChip *chip, const pmFPAview *inputView,
+                                const ppImageOptions *options)
+{
+    pmCell *cell = NULL;
+
+    assert (options->doPattern); // do not call if not needed
+    assert (inputView->chip != -1);
+    assert (inputView->cell == -1);
+    assert (inputView->readout == -1);
+    bool status;
+    pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT");
+
+    pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
+    *view = *inputView;
+
+    while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
+        if (!cell->process || !cell->file_exists) {
+            continue;
+        }
+        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
+            ESCAPE("load failure for Cell");
+        }
+
+        if (!cell->data_exists) {
+            continue;
+        }
+
+        if (cell->readouts->n > 1) {
+            psWarning ("Skipping Video Cell for ppImageDetrendPatternApply");
+            continue;
+        }
+
+        psMetadataItem *doPattern = pmConfigRecipeValueByView(config, RECIPE_NAME, "PATTERN.SUBSET",
+                                                              chip->parent, view); // Do we do pattern sub?
+        if (!doPattern || doPattern->type != PS_DATA_BOOL) {
+            ESCAPE("Unable to determine whether pattern matching should be applied.");
+        }
+        if (!doPattern->data.B) {
+            fprintf(stderr, "*NOT* DOING PATTERN SUBTRACTION FOR %d,%d\n", view->chip, view->cell);
+            continue;
+        }
+
+        fprintf(stderr, "DOING PATTERN SUBTRACTION FOR %d,%d\n", view->chip, view->cell);
+        continue;
+
+        // process each of the readouts
+        pmReadout *readout;         // Readout from cell
+        while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
+            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
+                ESCAPE("load failure for Readout");
+            }
+            if (!readout->data_exists) {
+                continue;
+            }
+
+            // perfore pattern correction
+            if (!pmPatternRow(readout, options->patternOrder, options->patternIter, options->patternRej,
+                              options->patternThresh, options->patternMean, options->patternStdev,
+                              options->maskValue, options->darkMask)) {
+                psFree(view);
+                return(false);
+            }
+        }
+    }
+
+    psFree(view);
+    return(true);
 }
 
-bool ppImageDetrendPatternApply(pmConfig *config, pmChip *chip, const pmFPAview *inputView, const ppImageOptions *options) {
 
-  
-  pmCell *cell = NULL;
-
-  assert (options->doPattern); // do not call if not needed
-  assert (inputView->chip != -1);
-  assert (inputView->cell == -1);
-  assert (inputView->readout == -1);
-  bool status;
-  pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPIMAGE.INPUT");
-  
-  pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
-  *view = *inputView;
-
-  while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
-    if (!cell->process || !cell->file_exists) {
-      continue;
-    }
-    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
-      ESCAPE("load failure for Cell");
-    }
-
-    if (!cell->data_exists) {
-      continue;
-    }
-    
-    if (cell->readouts->n > 1) {
-      psWarning ("Skipping Video Cell for ppImageDetrendPatternApply");
-      continue;
-    }
-    
-    // process each of the readouts
-    pmReadout *readout;         // Readout from cell
-    while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
-      if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
-	ESCAPE("load failure for Readout");
-      }
-      if (!readout->data_exists) {
-	continue;
-      }
-
-      // perfore pattern correction
-      if (!pmPatternRow(readout, options->patternOrder, options->patternIter, options->patternRej,
-			options->patternThresh, options->patternMean, options->patternStdev,
-			options->maskValue, options->darkMask)) {
-	psFree(view);
-	return(false);
-      }
-    }
-  }
-
-  psFree(view);
-  return(true);
-}
-  
-    
