code: def decluster(self, trig_int, timing='detect', metric='avg_cor'):
          all_detections = []
          for fam in self.families:
              all_detections.extend(fam.detections)
          if timing == 'detect':
              if metric == 'avg_cor':
                  detect_info = [(d.detect_time, d.detect_val / d.no_chans)
                                 for d in all_detections]
              elif metric == 'cor_sum':
                  detect_info = [(d.detect_time, d.detect_val)
                                 for d in all_detections]
              else:
                  raise MatchFilterError('metric is not cor_sum or avg_cor')
          elif timing == 'origin':
              if metric == 'avg_cor':
                  detect_info = [(_get_origin(d.event).time,
                                  d.detect_val / d.no_chans)
                                 for d in all_detections]
              elif metric == 'cor_sum':
                  detect_info = [(_get_origin(d.event).time, d.detect_val)
                                 for d in all_detections]
              else:
                  raise MatchFilterError('metric is not cor_sum or avg_cor')
          else:
              raise MatchFilterError('timing is not detect or origin')
          min_det = sorted([d[0] for d in detect_info])[0]
          detect_vals = np.array([d[1] for d in detect_info])
          detect_times = np.array([
              _total_microsec(d[0].datetime, min_det.datetime)
              for d in detect_info])
          peaks_out = decluster(
              peaks=detect_vals, index=detect_times, trig_int=trig_int * 10 ** 6)
          declustered_detections = []
          for ind in peaks_out:
              matching_time_indeces = np.where(detect_times == ind[-1])[0]
              matches = matching_time_indeces[
                  np.where(detect_vals[matching_time_indeces] == ind[0])[0][0]]
              declustered_detections.append(all_detections[matches])
          template_names = list(set([d.template_name
                                     for d in declustered_detections]))
          new_families = []
          for template_name in template_names:
              template = [fam.template for fam in self.families
                          if fam.template.name == template_name][0]
              new_families.append(Family(
                  template=template,
                  detections=[d for d in declustered_detections
                              if d.template_name == template_name]))
          self.families = new_families
          return self