docstr: Update the histogram according to the current affine transform.
  
  The current affine transform is given by `self.affine_map`, which
  must be set before calling this method.
  
  Returns
  -------
  static_values: array, shape(n,) if sparse sampling is being used,
                 array, shape(S, R, C) or (R, C) if dense sampling
      the intensity values corresponding to the static image used to
      update the histogram. If sparse sampling is being used, then
      it is simply a sequence of scalars, obtained by sampling the static
      image at the `n` sampling points. If dense sampling is being used,
      then the intensities are given directly by the static image,
      whose shape is (S, R, C) in the 3D case or (R, C) in the 2D case.
  moving_values: array, shape(n,) if sparse sampling is being used,
                 array, shape(S, R, C) or (R, C) if dense sampling
      the intensity values corresponding to the moving image used to
      update the histogram. If sparse sampling is being used, then
      it is simply a sequence of scalars, obtained by sampling the moving
      image at the `n` sampling points (mapped to the moving space by the
      current affine transform). If dense sampling is being used,
      then the intensities are given by the moving imaged linearly
      transformed towards the static image by the current affine, which
      results in an image of the same shape as the static image.
docstr_tok: ["Update","the","histogram","according","to","the","current","affine","transform",".","The","current","affine","transform","is","given","by","`","self.affine_map","`",",","which","must","be","set","before","calling","this","method",".","Returns","--","--","--","-","static_values",":","array",",","shape","(","n",",",")","if","sparse","sampling","is","being","used",",","array",",","shape","(","S",",","R",",","C",")","or","(","R",",","C",")","if","dense","sampling","the","intensity","values","corresponding","to","the","static","image","used","to","update","the","histogram",".","If","sparse","sampling","is","being","used",",","then","it","is","simply","a","sequence","of","scalars",",","obtained","by","sampling","the","static","image","at","the","`","n","`","sampling","points",".","If","dense","sampling","is","being","used",",","then","the","intensities","are","given","directly","by","the","static","image",",","whose","shape","is","(","S",",","R",",","C",")","in","the","3D","case","or","(","R",",","C",")","in","the","2D","case",".","moving_values",":","array",",","shape","(","n",",",")","if","sparse","sampling","is","being","used",",","array",",","shape","(","S",",","R",",","C",")","or","(","R",",","C",")","if","dense","sampling","the","intensity","values","corresponding","to","the","moving","image","used","to","update","the","histogram",".","If","sparse","sampling","is","being","used",",","then","it","is","simply","a","sequence","of","scalars",",","obtained","by","sampling","the","moving","image","at","the","`","n","`","sampling","points","(","mapped","to","the","moving","space","by","the","current","affine","transform",")",".","If","dense","sampling","is","being","used",",","then","the","intensities","are","given","by","the","moving","imaged","linearly","transformed","towards","the","static","image","by","the","current","affine",",","which","results","in","an","image","of","the","same","shape","as","the","static","image","."]
code: def _update_histogram(self):
      r"""Update the histogram according to the current affine transform.
  
      The current affine transform is given by `self.affine_map`, which
      must be set before calling this method.
  
      Returns
      -------
      static_values: array, shape(n,) if sparse sampling is being used,
                     array, shape(S, R, C) or (R, C) if dense sampling
          the intensity values corresponding to the static image used to
          update the histogram. If sparse sampling is being used, then
          it is simply a sequence of scalars, obtained by sampling the static
          image at the `n` sampling points. If dense sampling is being used,
          then the intensities are given directly by the static image,
          whose shape is (S, R, C) in the 3D case or (R, C) in the 2D case.
      moving_values: array, shape(n,) if sparse sampling is being used,
                     array, shape(S, R, C) or (R, C) if dense sampling
          the intensity values corresponding to the moving image used to
          update the histogram. If sparse sampling is being used, then
          it is simply a sequence of scalars, obtained by sampling the moving
          image at the `n` sampling points (mapped to the moving space by the
          current affine transform). If dense sampling is being used,
          then the intensities are given by the moving imaged linearly
          transformed towards the static image by the current affine, which
          results in an image of the same shape as the static image.
  
      """
      static_mask_values, moving_mask_values = None, None
      if self.sampling_proportion is None:  # Dense case
          static_values = self.static
          moving_values = self.affine_map.transform(self.moving)
  
          if self.static_mask is not None:
              static_mask_values = self.static_mask
          if self.moving_mask is not None:
              moving_mask_values = self.affine_map.transform(
                  self.moving_mask, interpolation="nearest"
              ).astype(np.int32)
  
          self.histogram.update_pdfs_dense(
              static_values,
              moving_values,
              self.static_mask,
              moving_mask_values,
          )
      else:  # Sparse case
          sp_to_moving = self.moving_world2grid.dot(
              self.affine_map.affine
          )
          pts = sp_to_moving.dot(
              self.samples.T
          ).T  # Points on moving grid
          pts = pts[..., : self.dim]
          self.moving_vals, inside = self.interp_method(
              self.moving, pts
          )
          self.moving_vals = np.array(self.moving_vals)
          static_values = self.static_vals
          moving_values = self.moving_vals
          self.histogram.update_pdfs_sparse(
              static_values, moving_values
          )
      return (
          static_values,
          moving_values,
          static_mask_values,
          moving_mask_values,
      )
  
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 3 for calling the MutualInformationMetric obj's underlying member method code with example usage: obj._update_histogram() and returns: static_values,  moving_values,  static_mask_values,  moving_mask_values