def read_piv_settings(datadir):
    """
    Returns used piv-related parameters in a dictionary when a path to pivlab output directory is provided

    Parameters
    ----------
    datadir: str
            location of directory where piv outputs are stored

    Returns
    -------
    piv_settings: dict
            keys are name of piv parameters
            values are parameter values (either str or float).

    """

    piv_settings_path = datadir + '/piv_settings/piv_settings.txt'
    fyle = open(piv_settings_path, 'r')
    lines = []
    for i, line in enumerate(fyle.read().split('\n')):
        if i > 1:
            lines.append(line)

    params = lines[0][:-1].split('\t')
    values_tmp = lines[1][:-1].split('\t')
    values = []
    for i, value_tmp in enumerate(values_tmp):
        try:
            value = float(value_tmp)
        except ValueError:
            value = value_tmp
            pass
        values.append(value)
    piv_settings = dict(list(zip(params, values)))
    return piv_settings