def get_stroke_freq(Ax, Az, fs_a, nperseg, peak_thresh, stroke_ratio=None):
    """Determine stroke frequency to use as a cutoff for filtering

    Args
    ----
    Ax: numpy.ndarray, shape (n,)
        x-axis accelermeter data (longitudinal)
    Ay: numpy.ndarray, shape (n,)
        x-axis accelermeter data (lateral)
    Az: numpy.ndarray, shape (n,)
        z-axis accelermeter data (dorso-ventral)
    fs_a: float
        sampling frequency (i.e. number of samples per second)
    nperseg: int
        length of each segment (i.e. number of samples per frq. band in PSD
        calculation. Default to 512 (scipy.signal.welch() default is 256)
    peak_thresh: float
        PSD power level threshold. Only peaks over this threshold are returned.

    Returns
    -------
    cutoff_frq: float
        cutoff frequency of signal (Hz) to be used for low/high-pass filtering
    stroke_frq: float
        frequency of dominant wavelength in signal
    stroke_ratio: float

    Notes
    -----
    During all descents and ascents phases where mainly steady swimming occurs.
    When calculated for the whole dive it may be difficult to differentiate the
    peak at which stroking rate occurs as there are movements than
    only steady swimming

    Here the power spectra is calculated of the longitudinal and dorso-ventral
    accelerometer signals during descents and ascents to determine the dominant
    stroke frequency for each animal in each phase

    This numpy samples per f segment 512 and a sampling rate of fs_a.

    Output: S is the amount of power in each particular frequency (f)
    """
    import numpy
    from . import dsp
    from . import utils
    from .plots import plotdsp
    stroke_axes = [(0, 'x', 'dorsa-ventral', Ax), (2, 'z', 'lateral', Az)]
    cutoff_frqs = list()
    stroke_frqs = list()
    stroke_ratios = list()
    for i, i_alph, name, data in stroke_axes:
        frqs, S, _, _ = dsp.calc_PSD_welch(data, fs_a, nperseg)
        delta = S.max() / 1000
        max_ind, min_ind = dsp.simple_peakfinder(range(len(S)), S, delta)
        max0 = max_ind[0]
        try:
            min_ind[0]
        except Exception:
            stroke_ratio = 0.4
        stroke_frq = frqs[max0]
        title = 'PSD - {} axis (n={}), {}'.format(i_alph, i, name)
        plotdsp.plot_welch_peaks(frqs, S, max_ind, title=title)
        cutoff_frq = utils.recursive_input('cutoff frequency', float)
        cutoff_frqs.append(cutoff_frq)
        stroke_frqs.append(stroke_frq)
        stroke_ratios.append(stroke_ratio)
    cutoff_frq = float(numpy.mean(cutoff_frqs))
    stroke_frq = float(numpy.mean(stroke_frqs))
    try:
        stroke_ratio = float(numpy.mean(stroke_ratios))
    except Exception:
        stroke_ratio = None
    return cutoff_frq, stroke_frq, stroke_ratio
