docs: def _checkup(peaks, ecg_integrated, sample_rate, rr_buffer, spk1, npk1, threshold):
      """
      Check each peak according to thresholds
  
      ----------
      Parameters
      ----------
      peaks : list
          List of local maximums that pass the first stage of conditions needed to be considered as
          an R peak.
      ecg_integrated : ndarray
          Array that contains the samples of the integrated signal.
      sample_rate : int
          Sampling rate at which the acquisition took place.
      rr_buffer : list
          Data structure that stores the duration of the last eight RR intervals.
      spk1 : float
          Actual value of SPK1 parameter defined in Pan-Tompkins real-time R peak detection algorithm
          (named signal peak).
      npk1 : int
          Actual value of NPK1 parameter defined in Pan-Tompkins real-time R peak detection algorithm
          (named noise peak).
      threshold : float
          Initial value of the adaptive threshold level (relevant parameter for the application of
          specific criteria during the identification of R peaks).
  
      Returns
      -------
      out : list
          List with the position of the peaks considered as R peak by the algorithm.
  
      """
      peaks_amp = [ecg_integrated[peak] for peak in peaks]
      definitive_peaks = []
      for i, peak in enumerate(peaks):
          amp = peaks_amp[i]
  
          # accept if larger than threshold and slope in raw signal
          # is +-30% of previous slopes
          if amp > threshold:
              definitive_peaks, spk1, rr_buffer = _acceptpeak(peak, amp, definitive_peaks, spk1,
                                                              rr_buffer)
  
          # accept as qrs if higher than half threshold,
          # but is 360 ms after last qrs and next peak
          # is more than 1.5 rr intervals away
          # just abandon it if there is no peak before
          # or after
          elif amp > threshold / 2 and list(definitive_peaks) and len(peaks) > i + 1:
              mean_rr = numpy.mean(rr_buffer)
              last_qrs_ms = (peak - definitive_peaks[-1]) * (1000 / sample_rate)
              last_qrs_to_next_peak = peaks[i+1] - definitive_peaks[-1]
  
              if last_qrs_ms > 360 and last_qrs_to_next_peak > 1.5 * mean_rr:
                  definitive_peaks, spk1, rr_buffer = _acceptpeak(peak, amp, definitive_peaks, spk1,
                                                                  rr_buffer)
              else:
                  npk1 = _noisepeak(amp, npk1)
          # if not either of these it is noise
          else:
              npk1 = _noisepeak(amp, npk1)
          threshold = _buffer_update(npk1, spk1)
  
      definitive_peaks = numpy.array(definitive_peaks)
  
      return definitive_peaks