def read_reject_parameters(fname):
    """Read rejection parameters from .cov or .ave config file.

    Parameters
    ----------
    fname : str
        Filename to read.

    Returns
    -------
    params : dict
        The rejection parameters.
    """
    with open(fname, 'r') as f:
        lines = f.readlines()
    reject_names = ['gradReject', 'magReject', 'eegReject', 'eogReject',
        'ecgReject']
    reject_pynames = ['grad', 'mag', 'eeg', 'eog', 'ecg']
    reject = dict()
    for line in lines:
        words = line.split()
        if words[0] in reject_names:
            reject[reject_pynames[reject_names.index(words[0])]] = float(words
                [1])
    return reject
