def get_r1_0(pdw_file, t1w_file, max_r1_0, mask=None):
    """
    Returns the R1_0 map NIfTI file from the given proton density
    and T1-weighted images. The R1_0 map is computed using the
    ``pdw_t1w_to_r1`` function. The ``pdw_t1w_to_r1`` module
    must be in the Python path.

    :param pdw_file: the proton density NIfTI image file path
    :param t1w_file: the T1-weighted image file path
    :param max_r1_0: the R1_0 range maximum
    :param mask: the optional mask image file path to use
    :return: the R1_0 map NIfTI image file path
    """
    import os
    import nibabel as nb
    import numpy as np
    from pdw_t1w_to_r1 import pdw_t1w_to_r1
    from dcmstack.dcmmeta import NiftiWrapper
    pdw_nii = nb.load(pdw_file)
    pdw_nw = NiftiWrapper(pdw_nii, make_empty=True)
    t1w_nw = NiftiWrapper(nb.load(t1w_file), make_empty=True)
    r1_space = np.arange(0.01, max_r1_0, 0.01)
    pdw_opts = {}
    if mask:
        pdw_opts['mask'] = nb.load(mask).get_data()
    r1_0_arr = pdw_t1w_to_r1(pdw_nw, t1w_nw, r1_space=r1_space, **pdw_opts)
    cwd = os.getcwd()
    r1_0_nii = nb.Nifti1Image(r1_0_arr, pdw_nii.affine)
    out_file = os.path.join(cwd, 'r1_0_map.nii.gz')
    nb.save(r1_0_nii, out_file)
    return out_file
