def _mean_in_rect(img_array, rect=None):
    """Get mean and standard deviation of pixels within rectangle.

    :param ndarray imgarray: the image data
    :param rect: rectanglular area ``[x0, y0, x1, y1]` where x0 < x1, y0 < y1
    """
    if rect is None:
        sub = img_array
    else:
        sub = img_array[rect[1]:rect[3], rect[0]:rect[2]]
    return sub.mean(), sub.std()
