code: def _filter_meshes(self):
          
  
          from scipy.ndimage import generic_filter
          try:
              nanmedian_func = np.nanmedian    # numpy >= 1.9
          except AttributeError:    # pragma: no cover
              from scipy.stats import nanmedian
              nanmedian_func = nanmedian
  
          if self.filter_threshold is None:
              # filter the entire arrays
              self.background_mesh = generic_filter(
                  self.background_mesh, nanmedian_func, size=self.filter_size,
                  mode='constant', cval=np.nan)
              self.background_rms_mesh = generic_filter(
                  self.background_rms_mesh, nanmedian_func,
                  size=self.filter_size, mode='constant', cval=np.nan)
          else:
              # selectively filter
              indices = np.nonzero(self.background_mesh > self.filter_threshold)
              self.background_mesh = self._selective_filter(
                  self.background_mesh, indices)
              self.background_rms_mesh = self._selective_filter(
                  self.background_rms_mesh, indices)
  
          return
docs: Apply a 2D median filter to the low-resolution 2D mesh,
          including only pixels inside the image at the borders.