def METHOD_NAME(peaks, signal, what="onset"):
    if what == "onset":
        direction = "smaller"
    else:
        direction = "greater"
    troughs, _ = scipy.signal.find_peaks(-1 * signal)
    bases = find_closest(peaks, troughs, direction=direction, strictly=True)
    bases = as_vector(bases)
    return bases