Index: trunk/pswarp/src/pswarpLoop.c
===================================================================
--- trunk/pswarp/src/pswarpLoop.c	(revision 28010)
+++ trunk/pswarp/src/pswarpLoop.c	(revision 28043)
@@ -266,5 +266,13 @@
         goto DONE;
     }
-
+    bool doStats = psMetadataLookupBool(&mdok,recipe,"MASK.STATS");
+    if (doStats) {
+      if (!pswarpMaskStats(output, stats, config)) {
+	psError(psErrorCodeLast(), false, "Unable to calculate mask stats.");
+	psFree(cells);
+	psFree(view);
+	goto DONE;
+      }
+    }
     // Set covariance matrix for output
     {
@@ -332,5 +340,5 @@
 
     pswarpVersionHeader(hdu->header);
-
+    
     if (!pmAstromWriteWCS(hdu->header, outFPA, outChip, WCS_NONLIN_TOL)) {
         psError(psErrorCodeLast(), false, "Unable to generate WCS header.");
@@ -347,4 +355,5 @@
     pswarpFileActivation(config, detectorFiles, false);
     pswarpFileActivation(config, independentFiles, false);
+
 
     // We need a new PSF model for the warped frame.  It would be good to generate this analytically, but
@@ -421,4 +430,5 @@
         }
     }
+    
 
     // Add MD5 information for readout
