def find_flank_zerox(sig, flank):
    """Find zero-crossings on rising or decaying flanks of a filtered signal.

    Parameters
    ----------
    sig : 1d array
        Time series to detect zero-crossings in.
    flank : {'rise', 'decay'}
        Which flank, rise or decay, to use to get zero crossings.

    Returns
    -------
    zero_xs : 1d array
        Samples of the zero crossings.

    Examples
    --------
    Find rising flanks in a filtered signal:

    >>> from neurodsp.sim import sim_bursty_oscillation
    >>> from neurodsp.filt import filter_signal
    >>> sig = sim_bursty_oscillation(10, 500, freq=10)
    >>> sig_filt = filter_signal(sig, 500, 'lowpass', 30)
    >>> rises_flank = find_flank_zerox(sig_filt, 'rise')
    """

    assert flank in ['rise', 'decay']
    pos = sig <= 0 if flank == 'rise' else sig > 0

    zero_xs = (pos[:-1] & ~pos[1:]).nonzero()[0]

    # If no zero-crossing's found (peak and trough are same voltage), output dummy value
    zero_xs = [int(len(sig) / 2)] if len(zero_xs) == 0 else zero_xs

    return zero_xs