def stimKeywords(hdr, segment, avg_s1, avg_s2, rms_s1, rms_s2, s1_ref, s2_ref):
    """Update keywords for the locations of the stims.

    hdr: pyfits Header object
        The input events extension header (updated).

    segment: {"FUVA", "FUVB"}
        Segment name.

    avg_s1:  list of two floats
        avg_s1[0] is the average Y location of the first stim.
        avg_s1[1] is the average X location of the first stim.

    avg_s2:  list of two floats
        avg_s2[0] is the average Y location of the second stim.
        avg_s2[1] is the average X location of the second stim.

    rms_s1:  list of two floats
        rms_s1[0] is the RMS in Y for the first stim.
        rms_s1[1] is the RMS in X for the first stim.

    rms_s2:  list of two floats
        rms_s2[0] is the RMS in Y for the second stim.
        rms_s2[1] is the RMS in X for the second stim.

    s1_ref:  list of two floats
        s1_ref[0] is the Y position of the first stim, from the BRFTAB.
        s1_ref[1] is the X position of the first stim, from the BRFTAB.

    s2_ref:  list of two floats
        s2_ref[0] is the Y position of the second stim, from the BRFTAB.
        s2_ref[1] is the X position of the second stim, from the BRFTAB.
    """
    seg = segment[-1]
    hdr['STIM' + seg + '0LX'] = s1_ref[1]
    hdr['STIM' + seg + '0LY'] = s1_ref[0]
    hdr['STIM' + seg + '0RX'] = s2_ref[1]
    hdr['STIM' + seg + '0RY'] = s2_ref[0]
    if avg_s1[0] is None or avg_s1[1] is None:
        hdr['STIM' + seg + '_LX'] = -1.0
        hdr['STIM' + seg + '_LY'] = -1.0
    else:
        hdr['STIM' + seg + '_LX'] = round(avg_s1[1], 3)
        hdr['STIM' + seg + '_LY'] = round(avg_s1[0], 3)
        hdr['STIM' + seg + 'SLX'] = round(rms_s1[1], 3)
        hdr['STIM' + seg + 'SLY'] = round(rms_s1[0], 3)
    if avg_s2[0] is None or avg_s2[1] is None:
        hdr['STIM' + seg + '_RX'] = -1.0
        hdr['STIM' + seg + '_RY'] = -1.0
    else:
        hdr['STIM' + seg + '_RX'] = round(avg_s2[1], 3)
        hdr['STIM' + seg + '_RY'] = round(avg_s2[0], 3)
        hdr['STIM' + seg + 'SRX'] = round(rms_s2[1], 3)
        hdr['STIM' + seg + 'SRY'] = round(rms_s2[0], 3)
