@nifti_out<EOL>def thr_img(img, thr=<NUM_LIT>, mode='<STR_LIT:+>'):
vol  = read_img(img).get_data()<EOL>if mode == '<STR_LIT:+>':<EOL><INDENT>mask = vol > thr<EOL><DEDENT>elif mode == '<STR_LIT>' or mode == '<STR_LIT>':<EOL><INDENT>mask = np.abs(vol) > thr<EOL><DEDENT>elif mode == '<STR_LIT:->':<EOL><INDENT>mask = vol < -thr<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>".format(mode))<EOL><DEDENT>return vol * mask<EOL>
Use the given magic function name `func` to threshold with value `thr`
    the data of `img` and return a new nibabel.Nifti1Image.
    Parameters
    ----------
    img: img-like

    thr: float or int
        The threshold value.

    mode: str
        Choices: '+' for positive threshold,
                 '+-' for positive and negative threshold and
                 '-' for negative threshold.
    Returns
    -------
    thr_img: nibabel.Nifti1Image
        Thresholded image