code: def denoise(data, radius=2, threshold=4):
      """Very simple noise removal function. Compares a point to surrounding points,
      replaces with nearby values if the difference is too large."""
  
      r2 = radius * 2
      d1 = data.view(np.ndarray)
      d2 = d1[radius:] - d1[:-radius]  # a derivative
      # d3 = data[r2:] - data[:-r2]
      # d4 = d2 - d3
      stdev = d2.std()
      # print "denoise: stdev of derivative:", stdev
      mask1 = (
          d2 > stdev * threshold
      )  # where derivative is large and positive
      mask2 = (
          d2 < -stdev * threshold
      )  # where derivative is large and negative
      maskpos = mask1[:-radius] * mask2[radius:]  # both need to be true
      maskneg = mask1[radius:] * mask2[:-radius]
      mask = maskpos + maskneg
      d5 = np.where(
          mask, d1[:-r2], d1[radius:-radius]
      )  # where both are true replace the value with the value from 2 points before
      d6 = np.empty(
          d1.shape, dtype=d1.dtype
      )  # add points back to the ends
      d6[radius:-radius] = d5
      d6[:radius] = d1[:radius]
      d6[-radius:] = d1[-radius:]
  
      if hasattr(data, "implements") and data.implements("MetaArray"):
          return MetaArray(d6, info=data.infoCopy())
      return d6
  
file_path: pyqtgraph/pyqtgraph/flowchart/library/functions.py
imports: import numpy
  from ...metaarray import MetaArray
label_desc: Use image node_id 8 for calling a global function with example usage: denoise(data, radius, threshold) and returns: d6, MetaArray