Index: trunk/psphot/src/psModulesUtils.c
===================================================================
--- trunk/psphot/src/psModulesUtils.c	(revision 4949)
+++ trunk/psphot/src/psModulesUtils.c	(revision 4954)
@@ -11,20 +11,20 @@
     psImage *image = source->pixels;
     psImage *mask  = source->mask;
-    psPeak *peak  = source->peak;
-    psRegion *srcRegion;
-
-    srcRegion = psRegionSquare (peak->x, peak->y, Radius);
-    srcRegion = psRegionForImage (srcRegion, mask, srcRegion);
-    psImageMaskRegion (mask, srcRegion, OR, 0x80);
-
+    pmPeak *peak  = source->peak;
+    psRegion srcRegion;
+
+    // XXX EAM : psRegionXXX funcs need value not ptr
+
+    srcRegion = psRegionForSquare (peak->x, peak->y, Radius);
+    srcRegion = psRegionForImage (mask, &srcRegion);
+
+    psImageMaskRegion (mask, &srcRegion, "OR", PSPHOT_MASK_MARKED);
     psStats *myStats = psStatsAlloc(statsOptions);
     myStats = psImageStats(myStats, image, mask, 0xff);
-    psImageMaskRegion (mask, srcRegion, AND, 0x7f);
+    psImageMaskRegion (mask, &srcRegion, "AND", ~PSPHOT_MASK_MARKED);
 
     psF64 tmpF64;
     p_psGetStatValue(myStats, &tmpF64);
-
     psFree (myStats);
-    psFree (srcRegion);
 
     if (isnan(tmpF64)) return (false);
@@ -40,10 +40,10 @@
 			     const bool PSF)
 {
-    PS_PTR_CHECK_NULL(source, false);
-    PS_PTR_CHECK_NULL(source->moments, false);
-    PS_PTR_CHECK_NULL(source->peak, false);
-    PS_PTR_CHECK_NULL(source->pixels, false);
-    PS_PTR_CHECK_NULL(source->mask, false);
-    PS_PTR_CHECK_NULL(source->noise, false);
+    // PS_PTR_CHECK_NULL(source, false);
+    // PS_PTR_CHECK_NULL(source->moments, false);
+    // PS_PTR_CHECK_NULL(source->peak, false);
+    // PS_PTR_CHECK_NULL(source->pixels, false);
+    // PS_PTR_CHECK_NULL(source->mask, false);
+    // PS_PTR_CHECK_NULL(source->noise, false);
     psBool fitStatus = true;
     psBool onPic     = true;
@@ -188,4 +188,6 @@
  
 XXX: mask values?
+
+XXX EAM : this version clips input pixels on S/N
 *****************************************************************************/
 # define VALID_RADIUS(X,Y) (((R2) >= (PS_SQR(X) + PS_SQR(Y))) ? 1 : 0)
@@ -194,8 +196,8 @@
 			 psF32 radius)
 {
-    PS_PTR_CHECK_NULL(source, NULL);
-    PS_PTR_CHECK_NULL(source->peak, NULL);
-    PS_PTR_CHECK_NULL(source->pixels, NULL);
-    PS_PTR_CHECK_NULL(source->noise, NULL);
+    // PS_PTR_CHECK_NULL(source, NULL);
+    // PS_PTR_CHECK_NULL(source->peak, NULL);
+    // PS_PTR_CHECK_NULL(source->pixels, NULL);
+    // PS_PTR_CHECK_NULL(source->noise, NULL);
     PS_FLOAT_COMPARE(0.0, radius, NULL);
 
