def nii_to_json(nii_fname):
    """
    Replace Nifti extension ('.nii.gz' or '.nii') with '.json'

    :param nii_fname:
    :return: json_fname
    """
    if '.nii.gz' in nii_fname:
        json_fname = nii_fname.replace('.nii.gz', '.json')
    elif 'nii' in nii_fname:
        json_fname = nii_fname.replace('.nii', '.json')
    else:
        print('* Unknown extension for %s' % nii_fname)
        json_fname = nii_fname + '.json'

    return json_fname