docs: def separate(polylines, f_mx_dist=2, mn_group_len=4):
      """
      split polylines wherever crinkles are found
      """
      s = []
  
      for n in range(len(polylines) - 1, -1, -1):
          c = polylines[n]
          separated = False
          start = 0
  
          for m in range(mn_group_len, len(c) - 1):
              if m - start < mn_group_len:
                  continue
              m += 1
              group = c[m - mn_group_len:m]
  
              x, y = group[:, 0], group[:, 1]
              asc, offs, _, _, _ = linregress(x, y)
              yfit = asc * x + offs
  
              # check whether next point would fit in:
              p1 = c[m]
              l = (x[0], yfit[0], p1[-1], asc * p1[-1] + offs)
              std = np.mean([line.distance(l, g) for g in group])
              dist = line.distance(l, p1)
  
              if dist > 2 and dist > f_mx_dist * std:
                  separated = True
                  s.append(c[start:m - 1])
                  start = m - 1
  
          if separated:
              if len(c) - start >= 2:
                  s.append(c[start:])
              polylines.pop(n)
  
      polylines.extend(s)
  
      return polylines