Index: branches/eam_branches/ipp-20100621/ippTools/src/diffphottool.c
===================================================================
--- branches/eam_branches/ipp-20100621/ippTools/src/diffphottool.c	(revision 28417)
+++ branches/eam_branches/ipp-20100621/ippTools/src/diffphottool.c	(revision 28439)
@@ -371,4 +371,5 @@
     PXOPT_LOOKUP_STR(ver_ppstats, config->args, "-ver_ppstats", false, false);
     PXOPT_LOOKUP_STR(ver_psphot, config->args, "-ver_psphot", false, false);
+    PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false);
 
     psString version = pxMergeCodeVersions(ver_pslib, ver_psmodules);
@@ -377,5 +378,5 @@
 
     if (!diffPhotSkyfileInsert(config->dbh, diff_phot_id, skycell_id, path_base, dtime_script, hostname,
-                               fault, quality, version)) {
+                               fault, quality, version, magicked)) {
         psError(psErrorCodeLast(), false, "database error");
         return false;
Index: branches/eam_branches/ipp-20100621/ippTools/src/diffphottoolConfig.c
===================================================================
--- branches/eam_branches/ipp-20100621/ippTools/src/diffphottoolConfig.c	(revision 28417)
+++ branches/eam_branches/ipp-20100621/ippTools/src/diffphottoolConfig.c	(revision 28439)
@@ -100,4 +100,5 @@
     psMetadataAddStr(doneArgs, PS_LIST_TAIL, "-ver_ppstats", 0, "define ppStats version", NULL);
     psMetadataAddStr(doneArgs, PS_LIST_TAIL, "-ver_psphot", 0, "define psphot version", NULL);
+    psMetadataAddS64(doneArgs, PS_LIST_TAIL, "-magicked", 0, "define magicked state", 0);
 
     // -advance
Index: branches/eam_branches/ipp-20100621/ippTools/src/dqstatstool.c
===================================================================
--- branches/eam_branches/ipp-20100621/ippTools/src/dqstatstool.c	(revision 28417)
+++ branches/eam_branches/ipp-20100621/ippTools/src/dqstatstool.c	(revision 28439)
@@ -85,5 +85,5 @@
 
   if (label) {
-    PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "==");
+    pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "LIKE"); // define using cam label
   }
   // use psDBGenerateWhereConditionSQL because the SQL ends in a WHERE
@@ -654,5 +654,15 @@
 	psError(PS_EXIT_CONFIG_ERROR, false, "Unable to find max value for %s",colname);
 	return(false);
-      }      
+      }
+      psString filter = psMetadataLookupStr(&status,rule,"FILTER");
+      if (!status) {
+	status = true;
+      }
+      if (filter) {
+	psString imfilter = psMetadataLookupStr(&status,tableRow,"FILTER");
+	if (strcmp(filter,imfilter) != 0) {
+	  continue;
+	}
+      }
       // Not happy with this being set to a F32. Can this ever be something else?
       psF32 value      = psMetadataLookupF32(&status,tableRow,colname);
