Index: sansview/perspectives/fitting/basepage.py
===================================================================
--- sansview/perspectives/fitting/basepage.py	(revision da3f24c42d5d841725c8abadc9114c73aaeaf863)
+++ sansview/perspectives/fitting/basepage.py	(revision 51a71a3f6482bdb1392cffcfb429fa350bdb9b17)
@@ -1002,7 +1002,12 @@
              use : _check_value_enter 
         """
-        # Flag to register when a parameter has changed.      
+        # Flag to register when a parameter has changed.   
         is_modified = False
+        self.fitrange =True
+        is_2Ddata = False
         #self._undo.Enable(True)
+        # check if 2d data
+        if self.data.__class__.__name__ !="Data1D":
+            is_2Ddata = True
         if self.model !=None:
             try:
@@ -1026,20 +1031,21 @@
                     self.qmax_x = tempmax
                     is_modified = True
-                self.fitrange = True
+            
+                if is_2Ddata:
+                    # set mask   
+                    is_modified = self._validate_Npts()
+
             else:
-                self.fitrange = False
-            if self.npts != None:
-                if check_float(self.npts):
-                    temp_npts = float(self.npts.GetValue())
-                    if temp_npts !=  self.num_points:
-                        self.num_points = temp_npts
-                        is_modified = True
-                else:
-                    msg= "Cannot Plot :Must enter a number!!!  "
-                    wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
-                
-            
+                self.fitrange = False    
+
             ## if any value is modify draw model with new value
-            if is_modified:
+            if not self.fitrange:
+                self.btFit.Disable()
+                if is_2Ddata: self.btEditMask.Disable()
+            else:
+                self.btFit.Enable(True)
+                if is_2Ddata: self.btEditMask.Enable(True)
+
+            if is_modified and self.fitrange:
                 self.state_change= True
                 self._draw_model() 
@@ -1053,5 +1059,12 @@
         #flag for qmin qmax check values
         flag = True
+        self.fitrange = True
         is_modified = False
+        is_2Ddata = False
+
+        # check if 2d data
+        if self.data.__class__.__name__ !="Data1D":
+            is_2Ddata = True
+        
         ##So make sure that update param values on_Fit.
         #self._undo.Enable(True)
@@ -1066,5 +1079,6 @@
             # If qmin and qmax have been modified, update qmin and qmax and 
             # set the is_modified flag to True
-            if self._validate_qrange(self.qmin, self.qmax):
+            self.fitrange = self._validate_qrange(self.qmin, self.qmax)
+            if self.fitrange:
                 tempmin = float(self.qmin.GetValue())
                 if tempmin != self.qmin_x:
@@ -1085,16 +1099,34 @@
                         self.manager.set_smearer(smearer=temp_smearer, qmin= float(self.qmin_x),
                                                  qmax= float(self.qmax_x))
-                elif self.data.__class__.__name__ !="Data2D":
+                elif not is_2Ddata:
                     self.manager.set_smearer(smearer=temp_smearer, qmin= float(self.qmin_x),
                                                  qmax= float(self.qmax_x))
+                    index_data = ((self.qmin_x <= self.data.x)&(self.data.x <= self.qmax_x))
+                    self.Npts_fit.SetValue(str(len(self.data.x[index_data==True])))
+                    flag = True
+                if is_2Ddata:
+                    # only 2D case set mask   
+                    flag = self._validate_Npts()
+                    if not flag:
+                        return flag
             else: flag = False
         else: 
             flag = False
+
+        #For invalid q range, disable the mask editor and fit button, vs.    
+        if not self.fitrange:
+            self.btFit.Disable()
+            self.btEditMask.Disable()
+        else:
+            self.btFit.Enable(True)
+            self.btEditMask.Enable(True)
+
         
         if not flag:
-            msg= "Cannot Fit :Must select a model or Fitting range is not valid!!!  "
+            msg= "Cannot Plot or Fit :Must select a model or Fitting range is not valid!!!  "
             wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
-            
+        
         self.save_current_state()
+            
         return flag                           
                
@@ -1597,5 +1629,5 @@
             self.structurebox.Enable()
             self.text2.Enable()
-        if self.data.__class__.__name__ =="Data2D":
+        if self.data.__class__.__name__ !="Data1D":
             self.smear_description_2d.Show(True)
             
@@ -1652,5 +1684,36 @@
                 return False
         return True
-
+    
+    def _validate_Npts(self):  
+        """
+            Validate the number of points for fitting is more than 10 points.
+            If valid, setvalues Npts_fit otherwise post msg.
+        """
+        #default flag
+        flag = True
+
+        # q value from qx and qy
+        radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + self.data.qy_data*self.data.qy_data )
+        #get unmasked index
+        index_data = (float(self.qmin.GetValue()) <= radius)&(radius<= float(self.qmax.GetValue()))
+        index_data = (index_data)&(self.data.mask) 
+        index_data = (index_data)&(numpy.isfinite(self.data.data))
+
+        if len(index_data[index_data]) < 10:
+            # change the color pink.
+            self.qmin.SetBackgroundColour("pink")
+            self.qmin.Refresh()
+            self.qmax.SetBackgroundColour("pink")
+            self.qmax.Refresh()
+            msg= "Cannot Plot :No or too little npts in that data range!!!  "
+            wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+            self.fitrange = False
+            flag = False
+        else:
+            self.Npts_fit.SetValue(str(len(self.data.mask[index_data==True])))
+            self.fitrange = True
+            
+        return flag
+    
     def _check_value_enter(self, list, modified):
         """
@@ -1664,5 +1727,5 @@
         for item in list:
             #skip angle parameters for 1D
-            if self.data.__class__.__name__ !="Data2D":
+            if self.data.__class__.__name__ !="Data1D":
                 if item in self.orientation_params:
                     continue
@@ -1930,5 +1993,5 @@
                 self.disp_cb_dict[p] = wx.RadioButton(self, -1, p, (10, 10))
                 self.state.disp_cb_dict[p]=  self.disp_cb_dict[p].GetValue()
-                if not (self.enable2D or self.data.__class__.__name__ =="Data2D"):
+                if not (self.enable2D or self.data.__class__.__name__ !="Data1D"):
                     self.disp_cb_dict[p].Hide()
                 else:
@@ -1974,4 +2037,11 @@
             Fill the Q range sizer
         """
+        #2D data? default
+        is_2Ddata = False
+        
+        #check if it is 2D data
+        if self.data.__class__.__name__ != 'Data1D':
+            is_2Ddata = True
+            
         self.sizer5.Clear(True)
         #--------------------------------------------------------------
@@ -1994,5 +2064,5 @@
         
         id = wx.NewId()
-        self.reset_qrange =wx.Button(self,id,'Reset',size=(70,23))
+        self.reset_qrange =wx.Button(self,id,'Reset',size=(77,20))
       
         self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked,id=id)
@@ -2000,21 +2070,32 @@
      
         sizer_horizontal=wx.BoxSizer(wx.HORIZONTAL)
-        sizer= wx.GridSizer(3, 3,2, 5)
-        
+        sizer= wx.GridSizer(2, 4,2, 6)
+
+        self.btEditMask = wx.Button(self,wx.NewId(),'Editor', size=(88,23))
+        self.btEditMask.Bind(wx.EVT_BUTTON, self._onMask,id= self.btEditMask.GetId())
+        self.btEditMask.SetToolTipString("Edit Mask.")
+        self.EditMask_title = wx.StaticText(self, -1, ' Masking(2D)')
+
         sizer.Add(wx.StaticText(self, -1, '    Q range'))     
-        sizer.Add(wx.StaticText(self, -1, ' Min'))
-        sizer.Add(wx.StaticText(self, -1, ' Max'))
+        sizer.Add(wx.StaticText(self, -1, ' Min[1/A]'))
+        sizer.Add(wx.StaticText(self, -1, ' Max[1/A]'))
+        sizer.Add(self.EditMask_title)
         sizer.Add(self.reset_qrange)   
-             
+        
         sizer.Add(self.qmin)
         sizer.Add(self.qmax)
-        sizer_horizontal.Add(sizer)
+        sizer.Add(self.btEditMask)
+       
+        if object1!=None:
+            
+            boxsizer1.Add(object1) 
+            boxsizer1.Add((10,10))
+        boxsizer1.Add(sizer)
         if object!=None:
-            sizer_horizontal.Add(object)
-        
-        if object1!=None:
-           boxsizer1.Add(object1) 
-           boxsizer1.Add((10,10))
-        boxsizer1.Add(sizer_horizontal)
+            boxsizer1.Add((10,15))
+            boxsizer1.Add(object)
+        if not is_2Ddata:
+            self.btEditMask.Disable()  
+            self.EditMask_title.Disable()   
         ## save state
         self.save_current_state()
@@ -2077,5 +2158,5 @@
             return
         ##For 3 different cases: Data2D, Data1D, and theory
-        if self.data.__class__.__name__ == "Data2D":
+        if self.data.__class__.__name__ != "Data1D":
             data_min= 0
             x= max(math.fabs(self.data.xmin), math.fabs(self.data.xmax)) 
@@ -2105,4 +2186,13 @@
             msg= "Cannot Plot :Must enter a number!!!  "
             wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+        else:
+            # set relative text ctrs.
+            self.qmin.SetValue(str(self.qmin_x))
+            self.qmax.SetValue(str(self.qmax_x))
+            self.set_npts2fit()
+            # At this point, some button and variables satatus (disabled?) should be checked 
+            # such as color that should be reset to white in case that it was pink.
+            self._onparamEnter_helper()
+
             
         self.save_current_state()
Index: sansview/perspectives/fitting/fitpage.py
===================================================================
--- sansview/perspectives/fitting/fitpage.py	(revision 6747217a65bc7b38c610ba4878cc028b2472751f)
+++ sansview/perspectives/fitting/fitpage.py	(revision 51a71a3f6482bdb1392cffcfb429fa350bdb9b17)
@@ -12,4 +12,5 @@
 from sans.guicomm.events import StatusEvent   
 from sans.guiframe.utils import format_number,check_float
+#from sans.guiframe.local_perspectives.plotting.Masking import ModelPanel2D as panel2D
 
 ## event to post model to fit to fitting plugins
@@ -44,5 +45,5 @@
             Initialization of the Panel
         """
-        ## fit page does not content npts txtcrtl
+        ## total number of point: float
         self.npts=None
         ## thread for compute Chisqr
@@ -77,5 +78,11 @@
             if self.smearer ==None:
                 self.enable_smearer.Disable()
-                #self.disable_smearer.Disable()
+            if self.data.__class__.__name__ =="Data2D":
+                if self.model != None:
+                    self.smear_description_2d.Show(True)
+                    self.npts = len(self.data.data)
+            else:
+                self.npts = len(self.data.x)
+                
 
         self.disp_cb_dict = {}
@@ -169,4 +176,10 @@
             add  access to npts
         """
+        is_2Ddata = False
+        
+        # Check if data is 2D
+        if self.data.__class__.__name__ != 'Data1D':
+            is_2Ddata = True
+            
         title = "Fitting"
         #smear messages & titles
@@ -180,18 +193,14 @@
         smear_message_slit_height_title = "Slit height[1/A]:"
         smear_message_slit_width_title = "Slit width[1/A]:"
+        #Fit button
+        self.btFit = wx.Button(self,wx.NewId(),'Fit', size=(88,25))
+        self.btFit.Bind(wx.EVT_BUTTON, self._onFit,id= self.btFit.GetId())
+        self.btFit.SetToolTipString("Start fitting.")
         
         self._get_smear_info()
-
+        
+        #Sizers
         box_description_range = wx.StaticBox(self, -1,str(title))
-        boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL)
-
-        sizer_fit = wx.GridSizer(1, 1,0, 0)
-    
-        self.btFit = wx.Button(self,wx.NewId(),'Fit', size=(80,23))
-        self.btFit.Bind(wx.EVT_BUTTON, self._onFit,id= self.btFit.GetId())
-        self.btFit.SetToolTipString("Perform fit.")
-      
-        
-
+        boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL)      
         self.sizer_set_smearer = wx.BoxSizer(wx.VERTICAL)
         sizer_smearer = wx.BoxSizer(wx.HORIZONTAL)
@@ -247,13 +256,29 @@
         sizer_smearer.Add((10,10))       
         
-        # static box for chi2
-        box_description= wx.StaticBox(self, -1,'Chi2/dof')
-        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
-        boxsizer1.SetMinSize((70,40))
-        
-        
-        
-        # StaticText for chi2 and smear
-        self.tcChi    =  wx.StaticText(self, -1, "-", style=wx.ALIGN_LEFT)
+        # StaticText for chi2, N(for fitting), Npts
+        self.tcChi    =  BGTextCtrl(self, -1, "-", size=(75,20), style=0)
+        self.tcChi.SetToolTipString("Chi2/Npts")
+        self.Npts_fit    =  BGTextCtrl(self, -1, "-", size=(75,20), style=0)
+        self.Npts_fit.SetToolTipString(" Npts : number of points selected for fitting")
+        self.Npts_total  =  BGTextCtrl(self, -1, "-", size=(75,20), style=0)
+        self.Npts_total.SetValue(str(self.npts))
+        self.Npts_total.SetToolTipString(" Total Npts : total number of data points")
+        box_description_1= wx.StaticText(self, -1,'    Chi2/Npts')
+        box_description_2= wx.StaticText(self, -1,'  Npts')
+        box_description_3= wx.StaticText(self, -1,'  Total Npts')
+        box_description_4= wx.StaticText(self, -1,' ')
+        
+        sizer_fit = wx.GridSizer(2, 4,2,6)
+        sizer_fit.Add(box_description_1,0,0)
+        sizer_fit.Add(box_description_2,0,0)
+        sizer_fit.Add(box_description_3,0,0)       
+        sizer_fit.Add(box_description_4,0,0)
+        sizer_fit.Add(self.tcChi,0,0)
+        sizer_fit.Add(self.Npts_fit ,0,0)
+        sizer_fit.Add(self.Npts_total,0,0)
+        sizer_fit.Add(self.btFit,0,0) 
+
+        # StaticText for smear
+        #self.tcChi    =  wx.StaticText(self, -1, "-", style=wx.ALIGN_LEFT)
         self.smear_description_none    =  wx.StaticText(self, -1, smear_message_none , style=wx.ALIGN_LEFT)
         self.smear_description_dqdata    =  wx.StaticText(self, -1, smear_message_dqdata , style=wx.ALIGN_LEFT)
@@ -271,5 +296,5 @@
         
         #arrange sizers 
-        boxsizer1.Add( self.tcChi )  
+        #boxsizer1.Add( self.tcChi )  
         self.sizer_set_smearer.Add(sizer_smearer )
         self.sizer_set_smearer.Add((10,10))
@@ -297,19 +322,9 @@
         self.sizer_set_smearer.Add( self.sizer_new_smear,0, wx.CENTER, 10 )
         
-        # add all to chi2 sizer
-        
-        sizer_smearer_box.Add(self.sizer_set_smearer) 
-        
+        # add all to chi2 sizer 
+        sizer_smearer_box.Add(self.sizer_set_smearer)       
         sizer_chi2.Add(sizer_smearer_box)
         sizer_chi2.Add((-1,5))
-        self.sizer_set_masking.Add((305,-1))
-        #self.sizer_set_masking.Add(boxsizer1,0, wx.RIGHT, 10)
-        sizer_chi2.Add(self.sizer_set_masking )
-          
-        sizer_fit.Add(boxsizer1,0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 63)
-        #sizer_fit.Add((-1,1),0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 1) 
-        sizer_fit.Add(self.btFit,0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 63) 
-        sizer_fit.Layout()
-        #sizer_smearer_box.Add(sizer_chi2)
+
         # hide all smear messages and textctrl
         self._hide_all_smear_info()
@@ -320,5 +335,5 @@
         # Show only the relevant smear messages, etc
         if self.current_smearer == None:
-            if self.data.__class__.__name__ != 'Data2D':
+            if not is_2Ddata:
                 self.smear_description_none.Show(True)
                 self.enable_smearer.Disable()  
@@ -329,5 +344,5 @@
                 self.enable_smearer.Disable() 
         else: self._show_smear_sizer()
-  
+        boxsizer_range.Add(self.sizer_set_masking)
             
         #Set sizer for Fitting section
@@ -814,5 +829,8 @@
             when enter value on panel redraw model according to changed
         """
+        #default flag
         flag = False
+        self.fitrange = True
+        #get event object
         tcrtl= event.GetEventObject()
 
@@ -822,27 +840,30 @@
 
         if check_float(tcrtl):
-            flag = self._onparamEnter_helper()                
-            temp_smearer = None
-            if not self.disable_smearer.GetValue():
-                temp_smearer= self.current_smearer
-                ## set smearing value whether or not the data contain the smearing info
-                if self.slit_smearer.GetValue():
-                    flag1 = self.update_slit_smear()
-                    flag = flag or flag1
-                elif self.pinhole_smearer.GetValue():
-                    flag1 = self.update_pinhole_smear()
-                    flag = flag or flag1
-            elif self.data.__class__.__name__ !="Data2D":
-                self.manager.set_smearer(smearer=temp_smearer, qmin= float(self.qmin_x),
-                                                         qmax= float(self.qmax_x)) 
-            if flag:   
-                self.compute_chisqr(smearer= temp_smearer)
-    
-                ## new state posted
-                if self.state_change:
-                    #self._undo.Enable(True)
-                    event = PageInfoEvent(page = self)
-                    wx.PostEvent(self.parent, event)
-                self.state_change= False           
+            flag = self._onparamEnter_helper()  
+            if self.fitrange:             
+                temp_smearer = None
+                if not self.disable_smearer.GetValue():
+                    temp_smearer= self.current_smearer
+                    ## set smearing value whether or not the data contain the smearing info
+                    if self.slit_smearer.GetValue():
+                        flag1 = self.update_slit_smear()
+                        flag = flag or flag1
+                    elif self.pinhole_smearer.GetValue():
+                        flag1 = self.update_pinhole_smear()
+                        flag = flag or flag1
+                elif self.data.__class__.__name__ !="Data2D":
+                    self.manager.set_smearer(smearer=temp_smearer, qmin= float(self.qmin_x),
+                                                             qmax= float(self.qmax_x)) 
+                if flag:   
+                    self.compute_chisqr(smearer= temp_smearer)
+        
+                    ## new state posted
+                    if self.state_change:
+                        #self._undo.Enable(True)
+                        event = PageInfoEvent(page = self)
+                        wx.PostEvent(self.parent, event)
+                    self.state_change= False 
+            else: 
+                return    # invalid fit range: do nothing here: msg already displayed in validate    
         else:
             self.save_current_state()
@@ -923,13 +944,21 @@
                 return 
             #Check if # of points for theory model are valid(>0).
-            if self.npts != None:
-                if check_float(self.npts):
-                    temp_npts = float(self.npts.GetValue())
-                    if temp_npts !=  self.num_points:
-                        self.num_points = temp_npts
-                        is_modified = True
+            # check for 2d
+            if self.data.__class__.__name__ =="Data2D":
+                # set mask   
+                radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + self.data.qy_data*self.data.qy_data )
+                index_data = ((self.qmin <= radius)&(radius<= self.qmax))
+                index_data = (index_data)&(self.data.mask)
+                index_data = (index_data)&(numpy.isfinite(self.data.data))
+                if len(index_data[index_data]) < 10:
+                    msg= "Cannot Plot :No or too little npts in that data range!!!  "
+                    wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+                    return
                 else:
-                    msg= "Cannot Plot :No npts in that Qrange!!!  "
-                    wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+                    self.data.mask = index_data
+                    self.Npts_fit.Setvalue(str(len(self.data.mask)))
+            else:
+                index_data = ((self.qmin <= self.data.x)&(self.data.x <= self.qmax))
+                self.Npts_fit.SetValue(str(len(self.data.x[index_data])))
            
         else:
@@ -945,5 +974,5 @@
         self.state_change= False
         self._draw_model()
-        
+        return
     def _clear_Err_on_Fit(self):
         """
@@ -1086,4 +1115,27 @@
         self.smear_message_new_s.Hide()
     
+    def _onMask(self, event):     
+        """
+            Build a panel to allow to edit Mask
+        """
+        
+        from sans.guiframe.local_perspectives.plotting.masking import MaskPanel as MaskDialog
+        
+        self.panel = MaskDialog(self, data=self.data,id =-1 )
+        self.panel.Bind(wx.EVT_CLOSE, self._draw_masked_model)
+        self.panel.ShowModal()
+        #wx.PostEvent(self.parent, event)
+        
+    def _draw_masked_model(self,event):
+        event.Skip()
+
+        is_valid_qrange = self._update_paramv_on_fit()
+        if is_valid_qrange:
+            self._draw_model()
+            self.panel.Destroy() # frame
+            self.set_npts2fit()
+        else:
+            msg = ' Please consider your Q range.'
+            self.panel.ShowMessage(msg)
         
     def set_data(self, data):
@@ -1092,4 +1144,6 @@
         """
         self.data = data
+
+        
         if self.data is None:
             data_min = ""
@@ -1105,5 +1159,5 @@
             else:
                 self.enable_smearer.Enable()
-
+            
             # more disables for 2D
             if self.data.__class__.__name__ =="Data2D":
@@ -1113,4 +1167,5 @@
                 self.pinhole_smearer.Disable()
                 self.slit_smearer.Disable()
+                self.default_mask = copy.deepcopy(self.data.mask)
                 
                 
@@ -1124,4 +1179,8 @@
                 # Maximum value of data  
                 data_max = max(self.data.x)
+                #number of total data points
+                self.Npts_total.SetValue(str(len(self.data.x)))
+                #default:number of data points selected to fit
+                self.Npts_fit.SetValue(str(len(self.data.x)))
             else:
                 ## Minimum value of data 
@@ -1131,5 +1190,9 @@
                 ## Maximum value of data  
                 data_max = math.sqrt(x*x + y*y)
-        
+                #number of total data points
+                self.Npts_total.SetValue(str(len(self.data.data)))
+                #default:number of data points selected to fit
+                self.Npts_fit.SetValue(str(len(self.data.data)))
+            
         self.dataSource.SetValue(data_name)
         self.qmin_x = data_min
@@ -1177,6 +1240,10 @@
         npts2fit = 0
         qmin,qmax = self.get_range()
-        if self.data.__class__.__name__ =="Data2D":
-            npts2fit = len(self.data.data[self.mask])
+        if self.data.__class__.__name__ =="Data2D": 
+            radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + self.data.qy_data*self.data.qy_data )
+            index_data = (self.qmin_x <= radius)&(radius<= self.qmax_x)
+            index_data= (index_data)&(self.data.mask)
+            index_data = (index_data)&(numpy.isfinite(self.data.data))
+            npts2fit = len(self.data.data[index_data])
         else:
             for qx in self.data.x:
@@ -1185,5 +1252,11 @@
         return npts2fit
 
-
+    def set_npts2fit(self):
+        """
+            setValue Npts for fitting 
+        """
+        self.Npts_fit.SetValue(str(self.get_npts2fit()))
+        
+        
     def get_chi2(self):
         """
Index: sansview/perspectives/fitting/model_thread.py
===================================================================
--- sansview/perspectives/fitting/model_thread.py	(revision 43e685d86073e01499f75d7dcaa915217f82a478)
+++ sansview/perspectives/fitting/model_thread.py	(revision 51a71a3f6482bdb1392cffcfb429fa350bdb9b17)
@@ -81,13 +81,13 @@
         # so that must be mulitified by sqrt(2) to get actual max for 2d
         index_model = ((self.qmin <= radius)&(radius<= self.qmax))
-        self.mask = (index_model)&(self.mask)
-        self.mask = (self.mask)&(numpy.isfinite(self.I_data))
+        index_model = (index_model)&(self.mask)
+        index_model = (index_model)&(numpy.isfinite(self.I_data))
         if self.data ==None:
             # Only qmin value will be consider for the detector
-            self.mask = index_data  
+            index_model = index_data  
              
-        value = self.model.evalDistribution([self.qx_data[self.mask],self.qy_data[self.mask]] )
+        value = self.model.evalDistribution([self.qx_data[index_model],self.qy_data[index_model]] )
 
-        output = numpy.zeros(len(self.mask))
+        output = numpy.zeros(len(self.qx_data))
         
         # output default is None
@@ -95,6 +95,5 @@
         output = output/output
         # set value for self.mask==True, else still None to Plottools
-        output[self.mask] = value 
-
+        output[index_model] = value 
         elapsed = time.time()-self.starttime
         self.complete( image = output,
