def load_mask(image, allow_empty=True):
img    = check_img(image, make_it_3d=True)<EOL>values = np.unique(img.get_data())<EOL>if len(values) == <NUM_LIT:1>:<EOL><INDENT>if values[<NUM_LIT:0>] == <NUM_LIT:0> and not allow_empty:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT><DEDENT>elif len(values) == <NUM_LIT:2>:<EOL><INDENT>if <NUM_LIT:0> not in values:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'.format(values))<EOL><DEDENT><DEDENT>elif len(values) != <NUM_LIT:2>:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'.format(values))<EOL><DEDENT>return nib.Nifti1Image(as_ndarray(get_img_data(img), dtype=bool), img.get_affine(), img.get_header())<EOL>
Load a Nifti mask volume.

    Parameters
    ----------
    image: img-like object or boyle.nifti.NeuroImage or str
        Can either be:
        - a file path to a Nifti image
        - any object with get_data() and get_affine() methods, e.g., nibabel.Nifti1Image.
        If niimg is a string, consider it as a path to Nifti image and
        call nibabel.load on it. If it is an object, check if get_data()
        and get_affine() methods are present, raise TypeError otherwise.

    allow_empty: boolean, optional
        Allow loading an empty mask (full of 0 values)

    Returns
    -------
    nibabel.Nifti1Image with boolean data.