Index: trunk/ippScripts/scripts/detrend_process_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 9099)
+++ trunk/ippScripts/scripts/detrend_process_imfile.pl	(revision 9166)
@@ -10,4 +10,8 @@
 use PS::IPP::Metadata::Config;
 use PS::IPP::Metadata::Stats;
+
+use PS::IPP::Config;
+my $ipprc = PS::IPP::Config->new(); # IPP configuration
+use File::Spec;
 
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
@@ -42,6 +46,4 @@
 };
 
-use constant DELETE_STATS => 0;	# Delete the statistics file when done?
-
 # Look for programs we need
 my $missing_tools;
@@ -55,8 +57,10 @@
 
 ### Output file name --- must match camera configuration!
-my $outputRoot =  $exp_tag . '.detproc.' . $det_id;
-my $outputName = $outputRoot . '.' . $class_id ;
-my $outputImage = $outputName . '.fits';
-my $outputStats = $outputName . '.stats';
+my ($vol, $dir, $file) = File::Spec->splitpath( $input_uri );
+my $outputRoot = $exp_tag . '.detproc.' . $det_id; # Root name
+$outputRoot = File::Spec->rel2abs( File::Spec->catpath( $vol, $dir, $outputRoot ), $ipprc->workdir() );
+$input_uri = File::Spec->rel2abs( $input_uri, $ipprc->workdir() );
+my $outputImage = $outputRoot . '.' . $class_id . '.fits';
+my $outputStats = $outputRoot . '.' . $class_id . '.stats';
 
 # Run ppImage
@@ -85,4 +89,7 @@
 }
 
+# Take off the absolute path, to stuff into the database
+$outputImage = File::Spec->abs2rel( $outputImage, $ipprc->workdir() );
+
 # Add the processed file to the database
 unless ($no_update) {
@@ -102,7 +109,8 @@
     die "Unable to perform dettool -addprocessedimfile for $det_id/$exp_tag/$class_id: $error_code\n"
 	if not $success;
+
+    unlink $outputStats;
 }
 
-unlink "$outputStats" if DELETE_STATS;
 
 __END__
