docstr: Numeric value of the metric and its gradient at given parameters.
  
  Parameters
  ----------
  params : array, shape (n,)
      the parameter vector of the transform currently used by the metric
      (the transform name is provided when self.setup is called), n is
      the number of parameters of the transform
  
  Returns
  -------
  neg_mi : float
      the negative mutual information of the input images after
      transforming the moving image by the currently set transform
      with `params` parameters
  neg_mi_grad : array, shape (n,)
      the gradient of the negative Mutual Information
docstr_tok: ["Numeric","value","of","the","metric","and","its","gradient","at","given","parameters",".","Parameters","--","--","--","--","--","params",":","array",",","shape","(","n",",",")","the","parameter","vector","of","the","transform","currently","used","by","the","metric","(","the","transform","name","is","provided","when","self.setup","is","called",")",",","n","is","the","number","of","parameters","of","the","transform","Returns","--","--","--","-","neg_mi",":","float","the","negative","mutual","information","of","the","input","images","after","transforming","the","moving","image","by","the","currently","set","transform","with","`","params","`","parameters","neg_mi_grad",":","array",",","shape","(","n",",",")","the","gradient","of","the","negative","Mutual","Information"]
code: def distance_and_gradient(self, params):
      r"""Numeric value of the metric and its gradient at given parameters.
  
      Parameters
      ----------
      params : array, shape (n,)
          the parameter vector of the transform currently used by the metric
          (the transform name is provided when self.setup is called), n is
          the number of parameters of the transform
  
      Returns
      -------
      neg_mi : float
          the negative mutual information of the input images after
          transforming the moving image by the currently set transform
          with `params` parameters
      neg_mi_grad : array, shape (n,)
          the gradient of the negative Mutual Information
  
      """
      try:
          self._update_mutual_information(params, True)
      except (AffineInversionError, AffineInvalidValuesError):
          return np.inf, 0 * self.metric_grad
      return -1 * self.metric_val, -1 * self.metric_grad
  
imports: from warnings import warn
  import numpy
  import numpy.linalg
  import scipy.ndimage
  from dipy.core.optimize import Optimizer
  from dipy.core.interpolation import interpolate_scalar_2d, interpolate_scalar_3d
  from dipy.align import vector_fields
  from dipy.align import VerbosityLevels
  from dipy.align.parzenhist import ParzenJointHistogram, sample_domain_regular, compute_parzen_mi
  from dipy.align.imwarp import get_direction_and_spacings, ScaleSpace
  from dipy.align.scalespace import IsotropicScaleSpace
  from dipy.utils.deprecator import deprecated_params
label_desc: Use image node_id 7 for calling the MutualInformationMetric obj's underlying member method code with example usage: obj.distance_and_gradient(params) and returns: unknown,  unknown, np,  unknown