docstr: Demons step for EM metric
  
  Parameters
  ----------
  forward_step : boolean
      if True, computes the Demons 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 Demons step
docstr_tok: ["Demons","step","for","EM","metric","Parameters","--","--","--","--","--","forward_step",":","boolean","if","True",",","computes","the","Demons","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","Demons","step"]
code: def compute_demons_step(self, forward_step=True):
      r"""Demons step for EM metric
  
      Parameters
      ----------
      forward_step : boolean
          if True, computes the Demons 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 Demons step
      """
      sigma_reg_2 = np.sum(self.static_spacing**2) / self.dim
  
      if forward_step:
          gradient = self.gradient_static
          delta_field = self.static_image - self.movingq_means_field
          sigma_sq_field = self.movingq_sigma_sq_field
      else:
          gradient = self.gradient_moving
          delta_field = self.moving_image - self.staticq_means_field
          sigma_sq_field = self.staticq_sigma_sq_field
  
      if self.dim == 2:
          step, self.energy = em.compute_em_demons_step_2d(
              delta_field, sigma_sq_field, gradient, sigma_reg_2, None
          )
      else:
          step, self.energy = em.compute_em_demons_step_3d(
              delta_field, sigma_sq_field, gradient, sigma_reg_2, None
          )
      for i in range(self.dim):
          step[..., i] = ndimage.gaussian_filter(
              step[..., i], self.smooth
          )
      return step
  
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 8 for calling the EMMetric obj's underlying member method code with example usage: obj.compute_demons_step(forward_step) and returns: step