Index: trunk/ippScripts/scripts/detrend_stack.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_stack.pl	(revision 8763)
+++ trunk/ippScripts/scripts/detrend_stack.pl	(revision 8983)
@@ -111,5 +111,10 @@
 	" -uri $output -recip $recipe";	# Command to run
     $command .= ' -bg ' . $stats->bg_mean();
+    if (defined($stats->bg_stdev())) {
     $command .= ' -bg_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();
     $command .= ' -pleasenormalize' if NORMALISE()->{$det_type};
