分享

scipy.signal.find_peaks

 LibraryPKU 2019-11-16
  • scipy.signal.find_peaks(x, height=None, threshold=None, distance=None, prominence=None, width=None, wlen=None, rel_height=0.5, plateau_size=None)[source]

  • Find peaks inside a signal based on peak properties.

    This function takes a one-dimensional array and finds all local maxima by simple comparison of neighbouring values. Optionally, a subset of these peaks can be selected by specifying conditions for a peak’s properties.

    • Parameters

      • xsequence

      • A signal with peaks.

      • heightnumber or ndarray or sequence, optional

      • Required height of peaks. Either a number, None, an array matchingx or a 2-element sequence of the former. The first element is always interpreted as the minimal and the second, if supplied, as the maximal required height.

      • thresholdnumber or ndarray or sequence, optional

      • Required threshold of peaks, the vertical distance to its neighbouring samples. Either a number, None, an array matching x or a 2-element sequence of the former. The first element is always interpreted as the minimal and the second, if supplied, as the maximal required threshold.

      • distancenumber, optional

      • Required minimal horizontal distance (>= 1) in samples between neighbouring peaks. Smaller peaks are removed first until the condition is fulfilled for all remaining peaks.

      • prominencenumber or ndarray or sequence, optional

      • Required prominence of peaks. Either a number, None, an array matching x or a 2-element sequence of the former. The first element is always interpreted as the minimal and the second, if supplied, as the maximal required prominence.

      • widthnumber or ndarray or sequence, optional

      • Required width of peaks in samples. Either a number, None, an array matching x or a 2-element sequence of the former. The first element is always interpreted as the minimal and the second, if supplied, as the maximal required width.

      • wlenint, optional

      • Used for calculation of the peaks prominences, thus it is only used if one of the arguments prominence or width is given. See argumentwlen in peak_prominences for a full description of its effects.

      • rel_heightfloat, optional

      • Used for calculation of the peaks width, thus it is only used if widthis given. See argument rel_height in peak_widths for a full description of its effects.

      • plateau_sizenumber or ndarray or sequence, optional

      • Required size of the flat top of peaks in samples. Either a number,None, an array matching x or a 2-element sequence of the former. The first element is always interpreted as the minimal and the second, if supplied as the maximal required plateau size.

        New in version 1.2.0.

      • Examples

      • To demonstrate this function’s usage we use a signal x supplied with SciPy (see scipy.misc.electrocardiogram). Let’s find all peaks (local maxima) in x whose amplitude lies above 0.

      • >>>

        >>> import matplotlib.pyplot as plt>>> from scipy.misc import electrocardiogram>>> from scipy.signal import find_peaks>>> x = electrocardiogram()[2000:4000]>>> peaks, _ = find_peaks(x, height=0)>>> plt.plot(x)>>> plt.plot(peaks, x[peaks], "x")>>> plt.plot(np.zeros_like(x), "--", color="gray")>>> plt.show()
      • ../_images/scipy-signal-find_peaks-1_00_00.png

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多