Index: /trunk/ippTools/src/regtool.c
===================================================================
--- /trunk/ippTools/src/regtool.c	(revision 8014)
+++ /trunk/ippTools/src/regtool.c	(revision 8015)
@@ -73,4 +73,11 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
+    bool status = false;
+    bool detrend = psMetadataLookupBool(&status, config->args, "-detrend");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detrend");
+        return false;
+    }
+
     psArray *new = newFrameSearchPending(config);
     if (!new) {
@@ -80,73 +87,27 @@
 
     // insert 'new' rawScience & detrendframes
-    if (new->n > 0) {
+    if (psArrayLength(new) > 0) {
         for (long i = 0; i < new->n; i++) {
             newFrame *newFrame = new->data[i];
-            if (strcmp(newFrame->exposure->exp_type, "object") == 0) {
+            if (detrend) {
+                // it's a detrend frame
+                rawDetrendFrame *frame = newToRawDetrendFrame(newFrame); 
+                if (!frame) {
+                }
+                if (!rawDetrendFrameInsert(config, frame)) {
+                    // error
+                }
+            } else {
                 // it's a science frame
-                rawScienceFrame *rawScienceFrame = newToRawScienceFrame(newFrame);
-                if (!rawScienceFrameInsert(config, rawScienceFrame)) {
+                rawScienceFrame *frame = newToRawDetrendFrame(newFrame); 
+                if (!frame) {
+                }
+                if (!rawScienceFrameInsert(config, frame)) {
                     // error
                 }
-            } else {
-                // it's a detrend frame
-                rawDetrendFrame *rawDetrendFrame = newToRawDetrendFrame(newFrame); 
-                if (!rawDetrendFrameInsert(config, rawDetrendFrame)) {
-                    // error
-                }
             }
-            
-            /*
-            // lookup camera name in p0CameraConfig
-            psMetadata *where = psMetadataAlloc();
-            //bool status = false;
-            psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, NULL,
-                newFrame->exposure->camera);
-            psArray *configs = p0CameraConfigSelectRowObjects(config->dbh, where, MAX_ROWS);
-            psFree(where);
-            // if there is no match then we default to sending into into p2
-            if (!configs) {
-                // convert newFrame->exposure to p2PendingExp 
-                p2PendingExpRow *p2PendingExp = newToP2PendingExp(
-                    newFrame->exposure
-                );
-                p2PendingExpInsertObject(config->dbh, p2PendingExp);
-                psFree(p2PendingExp);
-                continue;
-            }
-
-            // only use the first match
-            int pX = ((p0CameraConfigRow *)configs->data[0])->phase;
-            switch (pX) {
-                case 1:
-                    // convert newFrame->exposure to p1PendingExp 
-                {
-                    p1PendingExpRow *p1PendingExp = newToP1PendingExp(
-                        newFrame->exposure
-                    );
-                    p1PendingExpInsertObject(config->dbh, p1PendingExp);
-                    psFree(p1PendingExp);
-                }
-                    break;
-                case 2:
-                    // convert newFrame->exposure to p2PendingExp 
-                {
-                    p2PendingExpRow *p2PendingExp = newToP2PendingExp(
-                        newFrame->exposure
-                    );
-                    p2PendingExpInsertObject(config->dbh, p2PendingExp);
-                    psFree(p2PendingExp);
-                }
-                    break;
-                default:
-                    // XXX add argv[0] to pxConfig
-                    psAbort("foo", "invalid phase (this should not happen)");
-            }
-
-            psFree(configs);
-            */
         }
-        psFree(new);
-    }
+    }
+    psFree(new);
 
     return true;
Index: /trunk/ippTools/src/regtoolConfig.c
===================================================================
--- /trunk/ippTools/src/regtoolConfig.c	(revision 8014)
+++ /trunk/ippTools/src/regtoolConfig.c	(revision 8015)
@@ -39,4 +39,6 @@
     psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-exp_id",  0,
         "define class", NULL); 
+    psMetadataAddBool(updateArgs, PS_LIST_TAIL, "-detrend",  0,
+        "declare this as detrend data", false);
     psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-filter",  0,
         "define filter of interest", NULL);
