Index: trunk/psModules/src/detrend/pmOverscan.c
===================================================================
--- trunk/psModules/src/detrend/pmOverscan.c	(revision 19794)
+++ trunk/psModules/src/detrend/pmOverscan.c	(revision 19846)
@@ -293,10 +293,17 @@
     } 
 
+    bool mdok = false;
+
     // We are performing a row-by-row overscan subtraction
-    bool readRows = psMetadataLookupBool(NULL, input->parent->concepts, "CELL.READDIR"); // Read direction
+    int cellreaddir = psMetadataLookupS32(&mdok, input->parent->concepts, "CELL.READDIR"); // Read direction
+    if ((cellreaddir != 1) && (cellreaddir != 2)) {
+	psError(PS_ERR_UNKNOWN, true, "CELL.READDIR must be 1 (rows) or 2 (cols)\n");
+	return false;
+    }
+
     float chi2 = NAN;           // chi^2 from fit
 
     // adjust operation depending on the read direction : need to re-org pixels for columns
-    if (readRows) {
+    if (cellreaddir == 1) {
 	// The read direction is rows
 	psArray *pixels = psArrayAlloc(image->numRows); // Array of vectors containing pixels
@@ -344,5 +351,6 @@
 	}
 	psFree(reduced);
-    } else {
+    } 
+    if (cellreaddir == 2) {
 	// The read direction is columns
 	psArray *pixels = psArrayAlloc(image->numCols); // Array of vectors containing pixels
