'Perform sigma clip by comparing the data to the minimum and
maximum values (median + sig * standard deviation). Use
sigma_lower and sigma_upper to get the correct limits. Data
values less or greater than the minimum / maximum values
will have True set in the mask array.'

def _perform_clip(self, _filtered_data, axis=None):

    if (_filtered_data.size == 0):
        return _filtered_data
    max_value = self.cenfunc(_filtered_data, axis=axis)
    std = self.stdfunc(_filtered_data, axis=axis)
    min_value = (max_value - (std * self.sigma_lower))
    max_value += (std * self.sigma_upper)
    if (axis is not None):
        if (axis != 0):
            min_value = np.expand_dims(min_value, axis=axis)
            max_value = np.expand_dims(max_value, axis=axis)
    if (max_value is np.ma.masked):
        max_value = np.ma.MaskedArray(np.nan, mask=True)
        min_value = np.ma.MaskedArray(np.nan, mask=True)
    _filtered_data.mask |= (_filtered_data > max_value)
    _filtered_data.mask |= (_filtered_data < min_value)
    return _filtered_data
