docs: def despeckle_simple(B, th2=2):
      """Single-chromosome despeckling
  
      Simple speckle removing function on a single chromomsome. It also works
      for multiple chromosomes but trends may be disrupted.
  
      Parameters
      ----------
      B : array_like
          The input matrix to despeckle
      th2 : float
          The number of standard deviations above the mean beyond which
          despeckling should be performed
  
      Returns
      -------
      array_like
          The despeckled matrix
      """
  
      A = np.copy(B)
      n1 = A.shape[0]
      dist = {u: np.diag(A, u) for u in range(n1)}
  
      medians, stds = {}, {}
      for u in dist:
          medians[u] = np.median(dist[u])
          stds[u] = np.std(dist[u])
  
      for nw, j in itertools.product(range(n1), range(n1)):
          lp = j + nw
          kp = j - nw
          if lp < n1:
              if A[j, lp] > medians[nw] + th2 * stds[nw]:
                  A[j, lp] = medians[nw]
          if kp >= 0:
              if A[j, kp] > medians[nw] + th2 * stds[nw]:
                  A[j, kp] = medians[nw]
      return A