Index: trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 11830)
+++ trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 11837)
@@ -32,5 +32,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $exp_tag, $class_id, $det_type, $input_uri, $camera, $dbname, $workdir, $no_update);
+my ($det_id, $exp_tag, $class_id, $det_type, $input_uri, $camera, $dbname, $workdir, $no_update, $no_op);
 GetOptions(
     'det_id|d=s'        => \$det_id,
@@ -42,5 +42,6 @@
     'dbname|d=s'        => \$dbname, # Database name
     'workdir|w=s'       => \$workdir, # Working directory, for output files
-    'no-update'         => \$no_update
+    'no-update'         => \$no_update,
+    'no-op'             => \$no_op,
 ) or pod2usage( 2 );
 
@@ -105,5 +106,6 @@
 
 # Run ppImage
-{
+my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
+unless ($no_op) {
     my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" .
 	" -stat $outputStats"; # Command to run ppImage
@@ -118,9 +120,6 @@
     &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
     &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
-}
 
-# Get the statistics on the processed image
-my $stats;			# Statistics from ppImage
-{
+    # Get the statistics on the processed image
     my $statsFile;		# File handle
     open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n";
@@ -130,5 +129,4 @@
     my $metadata = $mdcParser->parse(join "", @contents)
         or &my_die("Unable to parse metadata config", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
-    $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
     $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
 }
@@ -139,16 +137,13 @@
 $outputBin2  = $ipprc->convert_filename_relative( $outputBin2  );
 
+my $bg = ($stats->bg_mean() or 'NAN');
+my $bg_stdev = ($stats->bg_stdev() or 'NAN');
+my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN');
+
 # Add the processed file to the database
 unless ($no_update) {
     my $command = "$dettool -addprocessedimfile -det_id $det_id -exp_tag $exp_tag " .
 	"-class_id $class_id -recip $recipe -uri $outputImage -b1_uri $outputRoot";  # Command to run dettool
-    $command .= " -bg " . $stats->bg_mean();
-    if (defined($stats->bg_mean_stdev())) {
-	$command .= " -bg_mean_stdev " . $stats->bg_mean_stdev();
-    } else {
-	# May be undefined if there's only a single imfile
-	$command .= " -bg_mean_stdev 0";
-    }
-    $command .= " -bg_stdev " . $stats->bg_stdev();
+    $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev";
     $command .= " -dbname $dbname" if defined $dbname;
 
