docs: def size_threshold(img, thr, comp='lt', structure = None):
      r"""
      Removes binary objects from an image identified by a size threshold.
      
      The unconnected binary objects in an image are identified and all removed
      whose size compares (e.g. less-than) to a supplied threshold value.
      
      The threshold ``thr`` can be any positive integer value. The comparison operator
      can be one of lt, le, gt, ge, ne or eq. The operators used are the functions of
      the same name supplied by the `operator` module of python.
      
      Parameters
      ----------
      img : array_like
          An array containing connected objects. Will be cast to type numpy.bool.
      thr : int
          Integer defining the threshold size of the binary objects to remove.
      comp : {'lt', 'le', 'gt', 'ge', 'ne', 'eq'}
          The type of comparison to perform. Use e.g. 'lt' for less-than.
      structure : array of ints, optional
          A structuring element that defines feature connections.
          ``structure`` must be symmetric. If no structuring element is provided,
          one is automatically generated with a squared connectivity equal to
          one. That is, for a 2-D ``input`` array, the default structuring element
          is::
          
              [[0,1,0],
               [1,1,1],
               [0,1,0]]
      
      Returns
      -------
      binary_image : ndarray
          The supplied binary image with all objects removed that positively compare
          to the threshold ``thr`` using the comparison operator defined with ``comp``.
          
      Notes
      -----
      If your voxel size is no isotrop i.e. of side-length 1 for all dimensions, simply
      divide the supplied threshold through the real voxel size.
      """
      
      operators = {'lt': lt, 'le': le, 'gt': gt, 'ge': ge, 'eq': eq, 'ne': ne}
      
      img = numpy.asarray(img).astype(numpy.bool)
      if comp not in operators:
          raise ValueError("comp must be one of {}".format(list(operators.keys())))
      comp = operators[comp]
      
      labeled_array, num_features = label(img, structure)
      for oidx in range(1, num_features + 1):
          omask = labeled_array == oidx
          if comp(numpy.count_nonzero(omask), thr):
              img[omask] = False
              
      return img