code: def _remove_duplicate(old_events, dat):
      diff_events = diff(old_events, axis=0)
      dupl = where((diff_events[:, 0] == 0) & (diff_events[:, 2] == 0))[0]
      dupl += 1
      n_nondupl_events = old_events.shape[0] - len(dupl)
      new_events = zeros((n_nondupl_events, old_events.shape[1]), dtype='int')
      if len(dupl):
          lg.debug('Removing ' + str(len(dupl)) + ' duplicate events')
      i = 0
      indices = []
      for i_old, one_old_event in enumerate(old_events):
          if i_old not in dupl:
              new_events[i, :] = one_old_event
              i += 1
              indices.append(i_old)
          else:
              peak_0 = new_events[i - 1, 1]
              peak_1 = one_old_event[1]
              if dat[peak_0] >= dat[peak_1]:
                  new_events[i - 1, 1] = peak_0
              else:
                  new_events[i - 1, 1] = peak_1
      return indices, new_events