def compute_extrema_voltage(df_samples, sig):
    """Compute the voltage of peaks and troughs.

    Parameters
    ---------
    df_samples : pandas.DataFrame
        Dataframe containing sample indices of cyclepoints.
    sig : 1d array
        Time series.

    Returns
    -------
    volt_peak : 1d array
        Voltage at the peak.
    volt_trough : 1d array
        Voltage at the last trough.

    Examples
    --------
    Compute the voltage at peaks and troughs:

    >>> from bycycle.features import compute_cyclepoints
    >>> from neurodsp.sim import sim_bursty_oscillation
    >>> fs = 500
    >>> sig = sim_bursty_oscillation(10, fs, freq=10)
    >>> df_samples = compute_cyclepoints(sig, fs, f_range=(8, 12))
    >>> volt_peak, volt_trough = compute_extrema_voltage(df_samples, sig)
    """

    volt_peak = sig[df_samples['sample_peak']]
    volt_trough = sig[df_samples['sample_last_trough']]

    return volt_peak, volt_trough