Index: trunk/ppImage/src/ppImageDetrendPattern.c
===================================================================
--- trunk/ppImage/src/ppImageDetrendPattern.c	(revision 31066)
+++ trunk/ppImage/src/ppImageDetrendPattern.c	(revision 33243)
@@ -18,5 +18,5 @@
     pmCell *cell = NULL;
 
-    assert(options->doPatternRow || options->doPatternCell); // do not call if not needed
+    assert(options->doPatternRow || options->doPatternCell || options->doPatternContinuity); // do not call if not needed
     assert(inputView->chip != -1);
     assert(inputView->cell == -1);
@@ -40,5 +40,5 @@
 	if (psMetadataLookupBool(NULL,hdu->header,"PTRN_ROW")) {
 	  psLogMsg("ppImage", PS_LOG_INFO, "Not performing row pattern correction as it has already been done.");
-	  goto pattern_cell;
+	  goto pattern_continuity;
 	}
 
@@ -98,8 +98,54 @@
     }
 
+ pattern_continuity:
+
+    // see the comment for PATTERN.ROW; the same rules apply for PATTERN.CELL
+
+    if (options->doPatternContinuity) {
+        int numCells = chip->cells->n;       // Number of cells
+        psVector *tweak = psVectorAlloc(numCells, PS_TYPE_U8); // Tweak cell?
+        pmFPAview *view = pmFPAviewAlloc(0); // View for local processing
+        *view = *inputView;
+
+	pmHDU *hdu = pmHDUFromChip(chip);
+	if (psMetadataLookupBool(NULL,hdu->header,"PTRN_CON")) {
+	  psLogMsg("ppImage", PS_LOG_INFO, "Not performing cell continuity correction as it has already been done.");
+	  goto pattern_cell;
+	}
+
+	for (int i = 0; i < chip->cells->n; i++) {
+            view->cell = i;
+
+            pmCell *cell = chip->cells->data[i]; // Cell of interest
+
+            if (cell->readouts->n > 1) {
+                psLogMsg("ppImage", PS_LOG_INFO, "Not performing cell continuity correction on video cell.");
+                continue;
+            }
+
+            bool doPattern = false;
+            if (!doPatternForView(&doPattern, config, chip, view, RECIPE_NAME, "PATTERN.CONTINUITY.SUBSET")) {
+                ESCAPE(false, "Unable to determine whether row pattern matching should be applied.");
+            }
+            if (doPattern) {
+                tweak->data.U8[i] = 0xFF;
+            }
+	}
+
+	// Tweak the cells
+	if (!pmPatternContinuity(chip, tweak, options->patternCellBG, options->patternCellMean,
+				 options->maskValue, options->darkMask,options->patternContinuityEdgeWidth)) {
+	    psFree(tweak);
+	    psFree(view);
+	    return false;
+	}
+	psFree(tweak);
+	psFree(view);
+
+	psMetadataAddBool(hdu->header, PS_LIST_TAIL, "PTRN_CON",PS_META_REPLACE,"PATTERN.CONTINUITY correction applied",true);
+    }
+
  pattern_cell:
-
-    // see the comment for PATTERN.ROW; the same rules apply for PATTERN.CELL
-
+    
     if (options->doPatternCell) {
         int numCells = chip->cells->n;       // Number of cells
@@ -131,5 +177,4 @@
                 tweak->data.U8[i] = 0xFF;
             }
-
 	}
 
