Index: trunk/ippScripts/scripts/detrend_resid.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_resid.pl	(revision 9446)
+++ trunk/ippScripts/scripts/detrend_resid.pl	(revision 9457)
@@ -115,4 +115,7 @@
 
 # Add the processed file to the database
+# XXX I think this has the names "bg_stdev" and "bg_mean_stdev" exchanged
+#     bg_stdev : standard deviation of the background
+#     bg_mean_stdev : standard deviation of the background means
 $outputName = File::Spec->abs2rel ($outputName, $ipprc->workdir() );
 $bin1Name = File::Spec->abs2rel( $bin1Name, $ipprc->workdir() );
@@ -123,11 +126,15 @@
 	"-b2_uri $bin2Name"; # Command to run dettool
     $command .= " -bg " . $stats->bg_mean();
+
+    # XXX note bg_stdev <--> bg_mean_stdev
     if (defined($stats->bg_stdev())) {
-	$command .= " -bg_stdev " . $stats->bg_stdev();
+	$command .= " -bg_mean_stdev " . $stats->bg_stdev();
     } else {
 	# May be undefined if there is only a single imfile
 	$command .= ' -bg_stdev 0';
     }
-    $command .= " -bg_mean_stdev " . $stats->bg_mean_stdev();
+
+    # XXX note bg_stdev <--> bg_mean_stdev
+    $command .= " -bg_stdev " . $stats->bg_mean_stdev();
 
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
