code: def checkerboard_matrix_filtering(similarity_matrix, kernel_width, kernel_type="default", thresh=0.25):
  
      
  
      checkerboard_matrix = get_checkerboard_matrix(kernel_width, kernel_type)
  
      # The values calculated in this step are starting from the 'kernel_width' position and ending
      # at length - kernel_width
      d = []
      for i in range(0, similarity_matrix.shape[0] - 2 * kernel_width):
          base = similarity_matrix[i:i + kernel_width * 2, i:i + kernel_width * 2]
          d.append(np.sum(np.multiply(base, checkerboard_matrix)))
  
      # The missing values from 0 to kernel_width are calculated here
      top_left_d = []
      for i in range(0, kernel_width):
          base = similarity_matrix[0:i + kernel_width, 0:i + kernel_width]
          top_left_d.append(np.sum(np.multiply(base, checkerboard_matrix[kernel_width - i:, kernel_width - i:])))
  
      # The missing kernel_width values at the bottom right are set to 0
      convolution_values = top_left_d + d + [0 for i in range(0, kernel_width)]
  
      # peaks = find_peaks_cwt(convolution_values, np.arange(1, peak_range))
      peaks = peakutils.indexes(convolution_values, thres=thresh)
  
      peaks = [0] + list(peaks) + [len(convolution_values)-1]
      return peaks, convolution_values
docs: Moving the checkerboard matrix over the main diagonal of the similarity matrix one sample at a time.
  
      :param kernel_type:
      :param thresh:
      :param similarity_matrix:
      :param kernel_width: the size of one quarter of the checkerboard matrix
      :return: peaks and convolution values