title: How to get the correct peaks and troughs from an 1d-array
body: <p>We are trying to find peaks and troughs from an 1d-array. </p>
  
  <p>We are using the <code>numpy.r_()</code> and it finds every peak and trough from an array but we want only the peaks and troughs that correspond to relaxation and contraction points of diaphragmatic motion.</p>
  
  <p>Is there any function that rejects the wrong min and max points?</p>
  
  <p>See a bad example below:</p>
  
  <p><a href="https://i.stack.imgur.com/EKvFI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EKvFI.png" alt="enter image description here"></a></p>