docstr: Expectation-Maximization Metric
  
  Similarity metric based on the Expectation-Maximization algorithm to
  handle multi-modal images. The transfer function is modeled as a set of
  hidden random variables that are estimated at each iteration of the
  algorithm.
  
  Parameters
  ----------
  dim : int (either 2 or 3)
      the dimension of the image domain
  smooth : float
      smoothness parameter, the larger the value the smoother the
      deformation field
  inner_iter : int
      number of iterations to be performed at each level of the multi-
      resolution Gauss-Seidel optimization algorithm (this is not the
      number of steps per Gaussian Pyramid level, that parameter must
      be set for the optimizer, not the metric)
  q_levels : number of quantization levels (equal to the number of hidden
      variables in the EM algorithm)
  double_gradient : boolean
      if True, the gradient of the expected static image under the moving
      modality will be added to the gradient of the moving image,
      similarly, the gradient of the expected moving image under the
      static modality will be added to the gradient of the static image.
  step_type : string ('gauss_newton', 'demons')
      the optimization schedule to be used in the multi-resolution
      Gauss-Seidel optimization algorithm (not used if Demons Step is
      selected)
docstr_tok: ["Expectation-Maximization","Metric","Similarity","metric","based","on","the","Expectation-Maximization","algorithm","to","handle","multi-modal","images",".","The","transfer","function","is","modeled","as","a","set","of","hidden","random","variables","that","are","estimated","at","each","iteration","of","the","algorithm",".","Parameters","--","--","--","--","--","dim",":","int","(","either","2","or","3",")","the","dimension","of","the","image","domain","smooth",":","float","smoothness","parameter",",","the","larger","the","value","the","smoother","the","deformation","field","inner_iter",":","int","number","of","iterations","to","be","performed","at","each","level","of","the","multi-","resolution","Gauss-Seidel","optimization","algorithm","(","this","is","not","the","number","of","steps","per","Gaussian","Pyramid","level",",","that","parameter","must","be","set","for","the","optimizer",",","not","the","metric",")","q_levels",":","number","of","quantization","levels","(","equal","to","the","number","of","hidden","variables","in","the","EM","algorithm",")","double_gradient",":","boolean","if","True",",","the","gradient","of","the","expected","static","image","under","the","moving","modality","will","be","added","to","the","gradient","of","the","moving","image",",","similarly",",","the","gradient","of","the","expected","moving","image","under","the","static","modality","will","be","added","to","the","gradient","of","the","static","image",".","step_type",":","string","(","'gauss_newton","'",",","'demons","'",")","the","optimization","schedule","to","be","used","in","the","multi-resolution","Gauss-Seidel","optimization","algorithm","(","not","used","if","Demons","Step","is","selected",")"]
code: def __init__(
      self,
      dim,
      smooth=1.0,
      inner_iter=5,
      q_levels=256,
      double_gradient=True,
      step_type="gauss_newton",
  ):
      r"""Expectation-Maximization Metric
  
      Similarity metric based on the Expectation-Maximization algorithm to
      handle multi-modal images. The transfer function is modeled as a set of
      hidden random variables that are estimated at each iteration of the
      algorithm.
  
      Parameters
      ----------
      dim : int (either 2 or 3)
          the dimension of the image domain
      smooth : float
          smoothness parameter, the larger the value the smoother the
          deformation field
      inner_iter : int
          number of iterations to be performed at each level of the multi-
          resolution Gauss-Seidel optimization algorithm (this is not the
          number of steps per Gaussian Pyramid level, that parameter must
          be set for the optimizer, not the metric)
      q_levels : number of quantization levels (equal to the number of hidden
          variables in the EM algorithm)
      double_gradient : boolean
          if True, the gradient of the expected static image under the moving
          modality will be added to the gradient of the moving image,
          similarly, the gradient of the expected moving image under the
          static modality will be added to the gradient of the static image.
      step_type : string ('gauss_newton', 'demons')
          the optimization schedule to be used in the multi-resolution
          Gauss-Seidel optimization algorithm (not used if Demons Step is
          selected)
      """
      super(EMMetric, self).__init__(dim)
      self.smooth = smooth
      self.inner_iter = inner_iter
      self.q_levels = q_levels
      self.use_double_gradient = double_gradient
      self.step_type = step_type
      self.static_image_mask = None
      self.moving_image_mask = None
      self.staticq_means_field = None
      self.movingq_means_field = None
      self.movingq_levels = None
      self.staticq_levels = None
      self._connect_functions()
  
imports: import abc
  import numpy
  from numpy import gradient
  from scipy import ndimage
  from dipy.align import vector_fields
  from dipy.align import sumsqdiff
  from dipy.align import crosscorr
  from dipy.align import expectmax
  from dipy.align import floating
label_desc: Use image node_id 1 to create a new EMMetric object from inherited base classes: SimilarityMetric with example: obj = EMMetric(dim, smooth, inner_iter, q_levels, double_gradient, step_type)