Index: trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 14048)
+++ trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 14115)
@@ -70,8 +70,9 @@
    [   
        #          PPSTATS KEYWORD         STATISTIC          CHIPTOOL FLAG
-       { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg" },
-       { name => "ROBUST_MEDIAN",  type => "stdev", flag => "-bg_mean_stdev" },
-       { name => "ROBUST_STDEV",   type => "rms",   flag => "-bg_stdev" },
+       { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg",            dtype => "float" },
+       { name => "ROBUST_MEDIAN",  type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },
+       { name => "ROBUST_STDEV",   type => "rms",   flag => "-bg_stdev",      dtype => "float" },
    ];
+my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
 
 # Look for programs we need
@@ -127,5 +128,4 @@
 
     # extract the stats from the metadata
-    my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
     $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
 }
@@ -139,11 +139,5 @@
 $command .= " -uri $outputImage -path_base $outputRoot";
 $command .= " -dbname $dbname" if defined $dbname;
-
-# add in the elements from the selected stats above
-foreach my $entry (@$STATS) {
-    my $value = $entry->{value};
-    my $flag = $entry->{flag};
-    $command .= " $flag $value";
-}
+$command .= $stats->cmdflags();
 
 # Add the processed file to the database
