Index: trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_stack.pl	(revision 8578)
+++ trunk/ippScripts/scripts/detrend_stack.pl	(revision 8586)
@@ -46,5 +46,5 @@
 my $files;			# Array of files to be stacked
 {
-    my $command = "$dettool -processed -det_id $detId -iter $iter -class_id $classId"; # Command to run
+    my $command = "$dettool -processed -det_id $detId -iteration $iter -class_id $classId"; # Command to run
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
@@ -55,5 +55,5 @@
 
 # Stack the files
-my $output = $detType . '_' . $classId . '_' . $detId . '_' . $iter; # Output name
+my $output = $detType . '_' . $classId . '_' . $detId . '_' . $iter . '.fit'; # Output name
 {
     my $command = "$ppMerge $output"; # Command to run
@@ -63,16 +63,25 @@
     }
     $command .= " -recipe PPMERGE $recipe";
-    $command .= ' -type' . uc($detType); # Type of stacking to perform
+    $command .= ' -type ' . uc($detType); # Type of stacking to perform
 
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run(command => $command, verbose => 1);
-    die "Unable to perform ppMerge: $error_code\n" if not $success;
+#    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+#	run(command => $command, verbose => 1);
+#    die "Unable to perform ppMerge: $error_code\n" if not $success;
     die "Unable to find expected output file: $output\n" if not -f $output;
 }
 
+### XXX: Need to add statistics
+my $bg_mean = 0;
+my $bg_stdev = 0;
+my $bg_mean_stdev = 0;
+
+
 # Add the resultant into the database
 {
-    my $command = "dettool -addstacked -det_id $detId -iter $iter -class_id $classId" .
-	" -uri $output";	# Command to run
+    my $command = "$dettool -addstacked -det_id $detId -iteration $iter -class_id $classId" .
+	" -uri $output -recip $recipe";	# Command to run
+    $command .= ' -bg ' . $bg_mean;
+    $command .= ' -bg_stdev ' . $bg_stdev;
+    $command .= ' -bg_mean_stdev ' . $bg_mean_stdev;
     $command .= ' -pleasenormalize' if NORMALISE()->{$detType};
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
