code: def test_sls(self):
      m = numpy.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
      s = numpy.array([[1, 2, 3], [3, 4, 5], [5, 6, 7]])
      sn_fp = numpy.array([[0, 1, 0], [1, 1, 0]])
      pn_fp = numpy.array([[1, 0], [1, 0], [0, 1]])
  
      # reflect
      patches = [
          numpy.array([[18, 33, 43], [46, 69, 83], [70, 101, 123]]),
          numpy.array([[43, 54, 68], [59, 70, 88], [75, 86, 108]]),
          numpy.array([[54, 81, 99], [70, 101, 123], [86, 121, 147]]),
      ]
      patches = [patch / 3.0 for patch in patches]
      noise = gaussian_filter(numpy.average(patches, 0), sigma=3)
      e = [-1 * numpy.exp(-1 * patch / noise) for patch in patches]
      e = numpy.rollaxis(numpy.asarray(e), 0, e[0].ndim + 1)
      r = sls(
          m,
          s,
          sn_footprint=sn_fp,
          pn_footprint=pn_fp,
          noise="local",
          signed=True,
      )
      numpy.testing.assert_allclose(r, e)
  
      e *= -1
      r = sls(
          m,
          -1 * s,
          sn_footprint=sn_fp,
          pn_footprint=pn_fp,
          noise="local",
          signed=True,
      )
      numpy.testing.assert_allclose(r, e)
  
      r = sls(
          m,
          s,
          sn_footprint=sn_fp,
          pn_footprint=pn_fp,
          noise="local",
          signed=False,
      )
      numpy.testing.assert_allclose(r, e)
  
      r = sls(
          m,
          -1 * s,
          sn_footprint=sn_fp,
          pn_footprint=pn_fp,
          noise="local",
          signed=False,
      )
      numpy.testing.assert_allclose(r, e)
  
      noise = noise.sum() / 9.0
      e = [-1 * numpy.exp(-1 * patch / noise) for patch in patches]
      e = numpy.rollaxis(numpy.asarray(e), 0, e[0].ndim + 1)
      r = sls(
          m,
          s,
          sn_footprint=sn_fp,
          pn_footprint=pn_fp,
          noise="global",
          signed=True,
      )
      numpy.testing.assert_allclose(r, e)
  
file_path: medpy/tests/filter_/image.py
imports: import unittest
  import numpy
  from medpy.filter.image import ssd, sls, sum_filter, average_filter
  from scipy.ndimage import gaussian_filter
label_desc: Use image node_id 2 for calling the TestMetrics obj's underlying member method code with example usage: obj.test_sls() without return types