Index: /trunk/ippTools/src/dettool.c
===================================================================
--- /trunk/ippTools/src/dettool.c	(revision 7420)
+++ /trunk/ippTools/src/dettool.c	(revision 7421)
@@ -31,5 +31,5 @@
 static bool masterMode(pxConfig *config);
 
-static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id);
+static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration);
 static psArray *searchRawImfiles(pxConfig *config, psMetadata *where);
 
@@ -83,8 +83,21 @@
 
     // what type of detRun is this?
+    // det_type & iteration are required
     psString det_type = psMetadataLookupStr(&status, config->args, "-det_type");
-    // this flag is required
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_type");
+        return false;
+    }
     if (!det_type) {
         psError(PS_ERR_UNKNOWN, true, "-det_type is required");
+        return false;
+    }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
         return false;
     }    
@@ -187,5 +200,6 @@
         detInputExpRow *inputExp = rawDetrenTodetInputExpRow(
             rawExps->data[i],
-            det_id
+            det_id,
+            iteration
         );
         psArrayAdd(inputExps, 0, inputExp);
@@ -286,5 +300,5 @@
 }
 
-static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id)
+static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration)
 {
     PS_ASSERT_PTR_NON_NULL(rawExp, NULL);
@@ -292,4 +306,5 @@
     return detInputExpRowAlloc(
         det_id,
+        iteration,
         rawExp->exp_id,
         rawExp->camera,
@@ -765,4 +780,13 @@
         return false;
     }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
+        return false;
+    }    
     psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
     if (!status) {
@@ -835,5 +859,5 @@
     // create a new detStackedImfile object
     detStackedImfileRow *stackedImfile = detStackedImfileRowAlloc(
-        (psS32)atol(det_id), class_id, uri, stats, recipe
+        (psS32)atol(det_id), iteration, class_id, uri, stats, recipe
     );   
 
@@ -1091,4 +1115,13 @@
         return false;
     }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
+        return false;
+    }    
     psString class_id = psMetadataLookupStr(&status, config->args, "-class_id");
     if (!status) {
@@ -1169,5 +1202,5 @@
     // create a new detNormalizedImfile object
     detNormalizedImfileRow *masterImfile = detNormalizedImfileRowAlloc(
-        (psS32)atol(det_id), class_id, uri, stats, recipe
+        (psS32)atol(det_id), iteration, class_id, uri, stats, recipe
     );   
 
@@ -1353,4 +1386,13 @@
         return false;
     }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
+        return false;
+    }    
     psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
     if (!status) {
@@ -1440,4 +1482,5 @@
     detResidImfileAnalysisRow *residImfile = detResidImfileAnalysisRowAlloc(
                 (psS32)atol(det_id),
+                iteration,
                 exp_id,
                 class_id,
@@ -1507,4 +1550,13 @@
         return false;
     }
+    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
+        return false;
+    }
+    if (!iteration) {
+        psError(PS_ERR_UNKNOWN, true, "-iteration is required");
+        return false;
+    }    
     psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
     if (!status) {
@@ -1572,4 +1624,5 @@
     detResidExpAnalysisRow *residExp = detResidExpAnalysisRowAlloc(
                 (psS32)atol(det_id),
+                iteration,
                 exp_id,
                 stats,
@@ -1710,4 +1763,34 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
-    return true;
-}
+
+    // join detMasterFrame & detNormalizedImfile tables
+    // no options are required... use the default where statement
+    psArray *normalizedImfiles = detNormalizedImfileSelectRowObjects(
+            config->dbh, config->where, 0);
+    if (!normalizedImfiles) {
+        psError(PS_ERR_UNKNOWN, false, "no detNormalizedImfile rows found");
+        return false;
+    }
+
+    if (psArrayLength(normalizedImfiles)) {
+        // print imfile list
+        psMetadata *output = psMetadataAlloc();
+        for (long i = 0; i < psArrayLength(normalizedImfiles); i++) {
+            psMetadata *md = detMasterFrameMetadataFromObject(
+                    normalizedImfiles->data[i]);
+            psMetadataAddMetadata(
+                output, PS_LIST_TAIL, "detNormalizedImfile",
+                PS_META_DUPLICATE_OK, NULL, md
+            );
+        }
+
+        psString str = psMetadataConfigFormat(output); 
+        psFree(output);
+        fprintf(stdout, "%s\n", str);
+        psFree(str);
+    }
+
+    psFree(normalizedImfiles);
+
+    return true;
+}
Index: /trunk/ippTools/src/dettoolConfig.c
===================================================================
--- /trunk/ippTools/src/dettoolConfig.c	(revision 7420)
+++ /trunk/ippTools/src/dettoolConfig.c	(revision 7421)
@@ -37,4 +37,6 @@
     psMetadataAddStr(inputArgs, PS_LIST_TAIL, "-det_id", 0,
         "search for detrend ID", NULL);
+    psMetadataAddS32(inputArgs, PS_LIST_TAIL, "-iteration",  0,
+        "define iteration number", 0);
     psMetadataAddStr(inputArgs, PS_LIST_TAIL, "-exp_id",  0,
         "search for exp ID", NULL);
@@ -44,6 +46,4 @@
     psMetadataAddStr(rawArgs, PS_LIST_TAIL, "-det_id",  0,
         "search for detrend ID", NULL);
-    psMetadataAddStr(rawArgs, PS_LIST_TAIL, "-iter",  0,
-        "search for iteration number", NULL);
     psMetadataAddStr(rawArgs, PS_LIST_TAIL, "-exp_id",  0,
         "search for exp ID", NULL);
@@ -55,6 +55,4 @@
     psMetadataAddStr(addprocArgs, PS_LIST_TAIL, "-det_id",  0,
         "define detrend ID (required)", NULL);
-    psMetadataAddStr(addprocArgs, PS_LIST_TAIL, "-iter",  0,
-        "define iteration number", NULL);
     psMetadataAddStr(addprocArgs, PS_LIST_TAIL, "-exp_id",  0,
         "define exp ID (required)", NULL);
@@ -72,6 +70,4 @@
     psMetadataAddStr(procArgs, PS_LIST_TAIL, "-det_id",  0,
         "search for detrend ID", NULL);
-    psMetadataAddStr(procArgs, PS_LIST_TAIL, "-iter",  0,
-        "search for iteration number", NULL);
     psMetadataAddStr(procArgs, PS_LIST_TAIL, "-exp_id",  0,
         "search for exp ID", NULL);
@@ -89,6 +85,6 @@
     psMetadataAddStr(addstacArgs, PS_LIST_TAIL, "-det_id",  0,
         "define detrend ID (required)", NULL);
-    psMetadataAddStr(addstacArgs, PS_LIST_TAIL, "-iter",  0,
-        "define iteration number", NULL);
+    psMetadataAddS32(addstacArgs, PS_LIST_TAIL, "-iteration",  0,
+        "define iteration number", 0);
     psMetadataAddStr(addstacArgs, PS_LIST_TAIL, "-class_id",  0,
         "define class ID (required)", NULL);
@@ -104,6 +100,6 @@
     psMetadataAddStr(stacArgs, PS_LIST_TAIL, "-det_id",  0,
         "search for detrend ID", NULL);
-    psMetadataAddStr(stacArgs, PS_LIST_TAIL, "-iter",  0,
-        "search for iteration number", NULL);
+    psMetadataAddS32(stacArgs, PS_LIST_TAIL, "-iteration",  0,
+        "search for iteration number", 0);
     psMetadataAddStr(stacArgs, PS_LIST_TAIL, "-class_id",  0,
         "search for class ID", NULL);
@@ -117,6 +113,6 @@
     psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-det_id",  0,
         "search for detrend ID (required)", NULL);
-    psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-iter",  0,
-        "search for iteration number", NULL);
+    psMetadataAddS32(stacframeArgs, PS_LIST_TAIL, "-iteration",  0,
+        "search for iteration number", 0);
     psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-class_id",  0,
         "search for class ID", NULL);
@@ -130,6 +126,6 @@
     psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-det_id",  0,
         "define detrend ID (required)", NULL);
-    psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-iter",  0,
-        "define iteration number", NULL);
+    psMetadataAddS32(addnormalizedArgs, PS_LIST_TAIL, "-iteration",  0,
+        "define iteration number", 0);
     psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-class_id",  0,
         "define class ID (required)", NULL);
@@ -145,6 +141,6 @@
     psMetadataAddStr(normalizedArgs, PS_LIST_TAIL, "-det_id",  0,
         "search for detrend ID (required)", NULL);
-    psMetadataAddStr(normalizedArgs, PS_LIST_TAIL, "-iter",  0,
-        "search for iteration number", NULL);
+    psMetadataAddS32(normalizedArgs, PS_LIST_TAIL, "-iteration",  0,
+        "search for iteration number", 0);
     psMetadataAddStr(normalizedArgs, PS_LIST_TAIL, "-class_id",  0,
         "search for class ID", NULL);
@@ -158,6 +154,6 @@
     psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-det_id",  0,
         "search for detrend ID (required)", NULL);
-    psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-iter",  0,
-        "search for iteration number", NULL);
+    psMetadataAddS32(normalizedframeArgs, PS_LIST_TAIL, "-iteration",  0,
+        "search for iteration number", 0);
     psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-class_id",  0,
         "search for class ID", NULL);
@@ -171,6 +167,6 @@
     psMetadataAddStr(addresidArgs, PS_LIST_TAIL, "-det_id",  0,
         "define detrend ID (required)", NULL);
-    psMetadataAddStr(addresidArgs, PS_LIST_TAIL, "-iter",  0,
-        "define iteration number", NULL);
+    psMetadataAddS32(addresidArgs, PS_LIST_TAIL, "-iteration",  0,
+        "define iteration number", 0);
     psMetadataAddStr(addresidArgs, PS_LIST_TAIL, "-exp_id",  0,
         "define detrend ID (required)", NULL);
@@ -186,6 +182,6 @@
     psMetadataAddStr(residArgs, PS_LIST_TAIL, "-det_id",  0,
         "search for detrend ID (required)", NULL);
-    psMetadataAddStr(residArgs, PS_LIST_TAIL, "-iter",  0,
-        "search for iteration number", NULL);
+    psMetadataAddS32(residArgs, PS_LIST_TAIL, "-iteration",  0,
+        "search for iteration number", 0);
     psMetadataAddStr(residArgs, PS_LIST_TAIL, "-exp_id",  0,
         "define detrend ID (required)", NULL);
@@ -201,6 +197,6 @@
     psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-det_id",  0,
         "define detrend ID (required)", NULL);
-    psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-iter",  0,
-        "define iteration number", NULL);
+    psMetadataAddS32(addresidexpArgs, PS_LIST_TAIL, "-iteration",  0,
+        "define iteration number", 0);
     psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-exp_id",  0,
         "define detrend ID (required)", NULL);
@@ -216,6 +212,6 @@
     psMetadataAddStr(residexpArgs, PS_LIST_TAIL, "-det_id",  0,
         "search for detrend ID (required)", NULL);
-    psMetadataAddStr(residexpArgs, PS_LIST_TAIL, "-iter",  0,
-        "search for iteration number", NULL);
+    psMetadataAddS32(residexpArgs, PS_LIST_TAIL, "-iteration",  0,
+        "search for iteration number", 0);
     psMetadataAddStr(residexpArgs, PS_LIST_TAIL, "-class_id",  0,
         "search for class ID", NULL);
@@ -231,6 +227,6 @@
     psMetadataAddStr(addmasterframeArgs, PS_LIST_TAIL, "-det_id",  0,
         "define detrend ID (required)", NULL);
-    psMetadataAddStr(addmasterframeArgs, PS_LIST_TAIL, "-iteration",  0,
-        "define iteration number", NULL);
+    psMetadataAddS32(addmasterframeArgs, PS_LIST_TAIL, "-iteration",  0,
+        "define iteration number", 0);
     psMetadataAddStr(addmasterframeArgs, PS_LIST_TAIL, "-comment",  0,
         "define master frame comment", NULL);
@@ -245,4 +241,6 @@
     psMetadataAddStr(masterArgs, PS_LIST_TAIL, "-det_id",  0,
         "search for detrend master for detrend ID", NULL);
+    psMetadataAddS32(masterArgs, PS_LIST_TAIL, "-iteration",  0,
+        "search for detrend master for detrend ID", 0);
 
 #define PXTOOL_MODE(option, modeval, argset) \
