Index: trunk/ippScripts/scripts/detrend_process.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process.pl	(revision 8490)
+++ trunk/ippScripts/scripts/detrend_process.pl	(revision 8578)
@@ -15,4 +15,10 @@
     'dark' => 'PPIMAGE_OB',	# Overscan and bias only
     'flat' => 'PPIMAGE_OBD',	# Overscan, bias and dark only
+};
+
+use constant PREFIX => {
+    'bias' => 'o',		# Overscan only
+    'dark' => 'ob',		# Overscan and bias only
+    'flat' => 'obd',		# Overscan, bias and dark only
 };
 
@@ -40,16 +46,20 @@
 my $recipe = RECIPES->{$detType};
 die "Unrecognised detrend type: $detType\n" if not defined $recipe;
+die "Unrecognised detrend type: $detType\n" if not defined PREFIX->{$detType};
 
 ### Output file name --- must match camera configuration!
-my $outputName = $output . "." . $classId . ".fit";
+my $outputRoot =  PREFIX->{$detType} . '_' . $output;
+my $outputName = $outputRoot . '.' . $classId ;
+my $outputImage = $outputName . '.fit';
+my $outputStats = $outputName . '.stats';
 
 # Run ppImage
 {
-    my $command = "$ppImage -file $input $output -recipe PPIMAGE $recipe" .
-	" -stat $output.stats"; # Command to run ppImage
+    my $command = "$ppImage -file $input $outputRoot -recipe PPIMAGE $recipe" .
+	" -stat $outputStats"; # Command to run ppImage
     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
 	run(command => $command, verbose => 1);
     die "Unable to perform ppImage on $input: $error_code\n" if not $success;
-    die "Couldn't find expected output file: $outputName\n" if not -f $outputName;
+    die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage;
 }
 
@@ -58,5 +68,5 @@
 {
     my $statsFile;		# File handle
-    open $statsFile, "$output.stats" or die "Can't open statistics file $output.stats: $!\n";
+    open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n";
     my @contents = <$statsFile>; # Contents of file
     close $statsFile;
@@ -69,6 +79,6 @@
 # Add the processed file to the database
 {
-    my $command = "dettool -addprocessed -det_id $detId -exp_id $expId " .
-	"-class_id $classId -recipe $recipe -uri $outputName"; # Command to run dettool
+    my $command = "$dettool -addprocessed -det_id $detId -exp_id $expId " .
+	"-class_id $classId -recip $recipe -uri $outputImage"; # Command to run dettool
     $command .= " -bg " . $stats->bg_mean();
     $command .= " -bg_stdev " . $stats->bg_stdev();
@@ -81,5 +91,5 @@
 }
 
-unlink "$output.stats" if DELETE_STATS;
+unlink "$outputStats" if DELETE_STATS;
 
 __END__
