docstr: Computes the Gauss-Newton energy minimization step
  
  Computes the Newton step to minimize this energy, i.e., minimizes the
  linearized energy function with respect to the
  regularized displacement field (this step does not require
  post-smoothing, as opposed to the demons step, which does not include
  regularization). To accelerate convergence we use the multi-grid
  Gauss-Seidel algorithm proposed by Bruhn and Weickert et al [Bruhn05]
  
  Parameters
  ----------
  forward_step : boolean
      if True, computes the Newton step in the forward direction
      (warping the moving towards the static image). If False,
      computes the backward step (warping the static image to the
      moving image)
  
  Returns
  -------
  displacement : array, shape (R, C, 2) or (S, R, C, 3)
      the Newton step
  
  References
  ----------
  [Bruhn05] Andres Bruhn and Joachim Weickert, "Towards ultimate motion
            estimation: combining highest accuracy with real-time
            performance", 10th IEEE International Conference on Computer
            Vision, 2005. ICCV 2005.
docstr_tok: ["Computes","the","Gauss-Newton","energy","minimization","step","Computes","the","Newton","step","to","minimize","this","energy",",","i.e.",",","minimizes","the","linearized","energy","function","with","respect","to","the","regularized","displacement","field","(","this","step","does","not","require","post-smoothing",",","as","opposed","to","the","demons","step",",","which","does","not","include","regularization",")",".","To","accelerate","convergence","we","use","the","multi-grid","Gauss-Seidel","algorithm","proposed","by","Bruhn","and","Weickert","et","al","[","Bruhn05","]","Parameters","--","--","--","--","--","forward_step",":","boolean","if","True",",","computes","the","Newton","step","in","the","forward","direction","(","warping","the","moving","towards","the","static","image",")",".","If","False",",","computes","the","backward","step","(","warping","the","static","image","to","the","moving","image",")","Returns","--","--","--","-","displacement",":","array",",","shape","(","R",",","C",",","2",")","or","(","S",",","R",",","C",",","3",")","the","Newton","step","References","--","--","--","--","--","[","Bruhn05","]","Andres","Bruhn","and","Joachim","Weickert",",","``","Towards","ultimate","motion","estimation",":","combining","highest","accuracy","with","real-time","performance","''",",","10th","IEEE","International","Conference","on","Computer","Vision",",","2005",".","ICCV","2005","."]
code: def compute_gauss_newton_step(self, forward_step=True):
      r"""Computes the Gauss-Newton energy minimization step
  
      Computes the Newton step to minimize this energy, i.e., minimizes the
      linearized energy function with respect to the
      regularized displacement field (this step does not require
      post-smoothing, as opposed to the demons step, which does not include
      regularization). To accelerate convergence we use the multi-grid
      Gauss-Seidel algorithm proposed by Bruhn and Weickert et al [Bruhn05]
  
      Parameters
      ----------
      forward_step : boolean
          if True, computes the Newton step in the forward direction
          (warping the moving towards the static image). If False,
          computes the backward step (warping the static image to the
          moving image)
  
      Returns
      -------
      displacement : array, shape (R, C, 2) or (S, R, C, 3)
          the Newton step
  
      References
      ----------
      [Bruhn05] Andres Bruhn and Joachim Weickert, "Towards ultimate motion
                estimation: combining highest accuracy with real-time
                performance", 10th IEEE International Conference on Computer
                Vision, 2005. ICCV 2005.
      """
      reference_shape = self.static_image.shape
  
      if forward_step:
          gradient = self.gradient_static
          delta = self.staticq_means_field - self.moving_image
          sigma_sq_field = self.staticq_sigma_sq_field
      else:
          gradient = self.gradient_moving
          delta = self.movingq_means_field - self.static_image
          sigma_sq_field = self.movingq_sigma_sq_field
  
      displacement = np.zeros(
          shape=reference_shape + (self.dim,), dtype=floating
      )
  
      if self.dim == 2:
          self.energy = v_cycle_2d(
              self.levels_below,
              self.inner_iter,
              delta,
              sigma_sq_field,
              gradient,
              None,
              self.smooth,
              displacement,
          )
      else:
          self.energy = v_cycle_3d(
              self.levels_below,
              self.inner_iter,
              delta,
              sigma_sq_field,
              gradient,
              None,
              self.smooth,
              displacement,
          )
      return displacement
  
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 7 for calling the EMMetric obj's underlying member method code with example usage: obj.compute_gauss_newton_step(forward_step) and returns: displacement