docstr: Prepares the metric to compute one displacement field iteration.
  
  Pre-computes the gradient of the input images to be used in the
  computation of the forward and backward steps.
docstr_tok: ["Prepares","the","metric","to","compute","one","displacement","field","iteration",".","Pre-computes","the","gradient","of","the","input","images","to","be","used","in","the","computation","of","the","forward","and","backward","steps","."]
code: def initialize_iteration(self):
      r"""Prepares the metric to compute one displacement field iteration.
  
      Pre-computes the gradient of the input images to be used in the
      computation of the forward and backward steps.
      """
      self.gradient_moving = np.empty(
          shape=self.moving_image.shape + (self.dim,), dtype=floating
      )
      for i, grad in enumerate(gradient(self.moving_image)):
          self.gradient_moving[..., i] = grad
  
      # Convert static image's gradient field from voxel to physical space
      if self.moving_spacing is not None:
          self.gradient_moving /= self.moving_spacing
      if self.moving_direction is not None:
          self.reorient_vector_field(
              self.gradient_moving, self.moving_direction
          )
  
      self.gradient_static = np.empty(
          shape=self.static_image.shape + (self.dim,), dtype=floating
      )
      for i, grad in enumerate(gradient(self.static_image)):
          self.gradient_static[..., i] = grad
  
      # Convert static image's gradient field from voxel to physical space
      if self.static_spacing is not None:
          self.gradient_static /= self.static_spacing
      if self.static_direction is not None:
          self.reorient_vector_field(
              self.gradient_static, self.static_direction
          )
  
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 3 for calling the SSDMetric obj's underlying member method code with example usage: obj.initialize_iteration() without return types