diff --git a/fslstats.cc b/fslstats.cc
index 0ee67f59f5c5bcf773a28997057f205d3df3e7ab..188ce647a8ce4eccae176ab39dd0feca89a5378f 100644
--- a/fslstats.cc
+++ b/fslstats.cc
@@ -256,6 +256,10 @@ int fmrib_main_float(int argc, char* argv[])
       ColumnVector hist;
       int nbins=1000;
       double entropy=0;
+      if (mask.nvoxels()<1) {
+	generate_masks(mask,masknz,vol,lthr,uthr); 
+	vol*=mask; 
+      }
       hist = vol.histogram(nbins,masknz);
       double ntot = hist.Sum();
       for (int j=1; j<=nbins; j++) {