class_docstr: Calculates various overlap measures between two maps, using the fuzzy
  definition proposed in: Crum et al., Generalized Overlap Measures for
  Evaluation and Validation in Medical Image Analysis, IEEE Trans. Med.
  Ima. 25(11),pp 1451-1461, Nov. 2006.
  
  in_ref and in_tst are lists of 2/3D images, each element on the list
  containing one volume fraction map of a class in a fuzzy partition
  of the domain.
  
  Example
  -------
  
  >>> overlap = FuzzyOverlap()
  >>> overlap.inputs.in_ref = [ 'ref_class0.nii', 'ref_class1.nii' ]
  >>> overlap.inputs.in_tst = [ 'tst_class0.nii', 'tst_class1.nii' ]
  >>> overlap.inputs.weighting = 'volume'
  >>> res = overlap.run() # doctest: +SKIP
code: def _run_interface(self, runtime):
      # Load data
      refdata = nb.concat_images(self.inputs.in_ref).dataobj
      tstdata = nb.concat_images(self.inputs.in_tst).dataobj
  
      # Data must have same shape
      if not refdata.shape == tstdata.shape:
          raise RuntimeError(
              'Size of "in_tst" %s must match that of "in_ref" %s.'
              % (tstdata.shape, refdata.shape)
          )
  
      ncomp = refdata.shape[-1]
  
      # Load mask
      mask = np.ones_like(refdata, dtype=bool)
      if isdefined(self.inputs.in_mask):
          mask = np.asanyarray(nb.load(self.inputs.in_mask).dataobj) > 0
          mask = np.repeat(mask[..., np.newaxis], ncomp, -1)
          assert mask.shape == refdata.shape
  
      # Drop data outside mask
      refdata = refdata[mask]
      tstdata = tstdata[mask]
  
      if np.any(refdata < 0.0):
          iflogger.warning(
              'Negative values encountered in "in_ref" input, '
              "taking absolute values."
          )
          refdata = np.abs(refdata)
  
      if np.any(tstdata < 0.0):
          iflogger.warning(
              'Negative values encountered in "in_tst" input, '
              "taking absolute values."
          )
          tstdata = np.abs(tstdata)
  
      if np.any(refdata > 1.0):
          iflogger.warning(
              'Values greater than 1.0 found in "in_ref" input, '
              "scaling values."
          )
          refdata /= refdata.max()
  
      if np.any(tstdata > 1.0):
          iflogger.warning(
              'Values greater than 1.0 found in "in_tst" input, '
              "scaling values."
          )
          tstdata /= tstdata.max()
  
      numerators = np.atleast_2d(
          np.minimum(refdata, tstdata).reshape((-1, ncomp))
      )
      denominators = np.atleast_2d(
          np.maximum(refdata, tstdata).reshape((-1, ncomp))
      )
  
      jaccards = numerators.sum(axis=0) / denominators.sum(axis=0)
  
      # Calculate weights
      weights = np.ones_like(jaccards, dtype=float)
      if self.inputs.weighting != "none":
          volumes = np.sum((refdata + tstdata) > 0, axis=1).reshape(
              (-1, ncomp)
          )
          weights = 1.0 / volumes
          if self.inputs.weighting == "squared_vol":
              weights = weights**2
  
      weights = weights / np.sum(weights)
      dices = 2.0 * jaccards / (jaccards + 1.0)
  
      # Fill-in the results object
      self._results["jaccard"] = float(weights.dot(jaccards))
      self._results["dice"] = float(weights.dot(dices))
      self._results["class_fji"] = [float(v) for v in jaccards]
      self._results["class_fdi"] = [float(v) for v in dices]
      return runtime
  
imports: import os
  import os.path
  import nibabel
  import numpy
  from ..None import config, logging
  from ..interfaces.base import SimpleInterface, BaseInterface, traits, TraitedSpec, File, InputMultiPath, BaseInterfaceInputSpec, isdefined
  from ..interfaces.nipy.base import NipyBaseInterface
label_desc: Use image node_id 1 for calling the FuzzyOverlap obj's underlying member method code with example usage: obj._run_interface(runtime) and returns: runtime