def half_amp_dur(self, waveforms):
    '\n        Half amplitude duration of a spike\n\n        Parameters\n        ----------\n        A: ndarray\n            An nSpikes x nElectrodes x nSamples array\n\n        Returns\n        -------\n        had: float\n            The half-amplitude duration for the channel (electrode) that has\n            the strongest (highest amplitude) signal. Units are ms\n        '
    from scipy import optimize
    best_chan = np.argmax(np.max(np.mean(waveforms, 0), 1))
    mn_wvs = np.mean(waveforms, 0)
    wvs = mn_wvs[best_chan, :]
    half_amp = (np.max(wvs) / 2)
    half_amp = (np.zeros_like(wvs) + half_amp)
    t = np.linspace(0, (1 / 1000.0), 50)
    from scipy.interpolate import BPoly
    p1 = BPoly.from_derivatives(t, wvs[:, np.newaxis])
    p2 = BPoly.from_derivatives(t, half_amp[:, np.newaxis])
    xs = np.r_[(t, t)]
    xs.sort()
    x_min = xs.min()
    x_max = xs.max()
    x_mid = (xs[:(- 1)] + (np.diff(xs) / 2))
    roots = set()
    for val in x_mid:
        (root, infodict, ier, mesg) = optimize.fsolve((lambda x: (p1(x) - p2(x))), val, full_output=True)
        if ((ier == 1) and (x_min < root < x_max)):
            roots.add(root[0])
    roots = list(roots)
    if (len(roots) > 1):
        r = np.abs(np.diff(roots[0:2]))[0]
    else:
        r = np.nan
    return r
Half amplitude duration of a spike

Parameters
----------
A: ndarray
    An nSpikes x nElectrodes x nSamples array

Returns
-------
had: float
    The half-amplitude duration for the channel (electrode) that has
    the strongest (highest amplitude) signal. Units are ms
def half_amp_dur(self, waveforms):
    '\n        Half amplitude duration of a spike\n\n        Parameters\n        ----------\n        A: ndarray\n            An nSpikes x nElectrodes x nSamples array\n\n        Returns\n        -------\n        had: float\n            The half-amplitude duration for the channel (electrode) that has\n            the strongest (highest amplitude) signal. Units are ms\n        '
    from scipy import optimize
    best_chan = np.argmax(np.max(np.mean(waveforms, 0), 1))
    mn_wvs = np.mean(waveforms, 0)
    wvs = mn_wvs[best_chan, :]
    half_amp = (np.max(wvs) / 2)
    half_amp = (np.zeros_like(wvs) + half_amp)
    t = np.linspace(0, (1 / 1000.0), 50)
    from scipy.interpolate import BPoly
    p1 = BPoly.from_derivatives(t, wvs[:, np.newaxis])
    p2 = BPoly.from_derivatives(t, half_amp[:, np.newaxis])
    xs = np.r_[(t, t)]
    xs.sort()
    x_min = xs.min()
    x_max = xs.max()
    x_mid = (xs[:(- 1)] + (np.diff(xs) / 2))
    roots = set()
    for val in x_mid:
        (root, infodict, ier, mesg) = optimize.fsolve((lambda x: (p1(x) - p2(x))), val, full_output=True)
        if ((ier == 1) and (x_min < root < x_max)):
            roots.add(root[0])
    roots = list(roots)
    if (len(roots) > 1):
        r = np.abs(np.diff(roots[0:2]))[0]
    else:
        r = np.nan
    return r