class_docstr: A class to represent a generic intensity-based image registration
  algorithm.
class_docstr_tok: ["A","class","to","represent","a","generic","intensity-based","image","registration","algorithm","."]
docstr: Optimize transform `T` with respect to similarity measure.
  
  The input object `T` will change as a result of the optimization.
  
  Parameters
  ----------
  T : object or str
    An object representing a transformation that should
    implement ``apply`` method and ``param`` attribute or
    property. If a string, one of 'rigid', 'similarity', or
    'affine'. The corresponding transformation class is then
    initialized by default.
  optimizer : str
    Name of optimization function (one of 'powell', 'steepest',
    'cg', 'bfgs', 'simplex')
  **kwargs : dict
    keyword arguments to pass to optimizer
  
  Returns
  -------
  T : object
    Locally optimal transformation
docstr_tok: ["Optimize","transform","`","T","`","with","respect","to","similarity","measure",".","The","input","object","`","T","`","will","change","as","a","result","of","the","optimization",".","Parameters","--","--","--","--","--","T",":","object","or","str","An","object","representing","a","transformation","that","should","implement","``","apply","``","method","and","``","param","``","attribute","or","property",".","If","a","string",",","one","of","'rigid","'",",","'similarity","'",",","or","'affine","'",".","The","corresponding","transformation","class","is","then","initialized","by","default",".","optimizer",":","str","Name","of","optimization","function","(","one","of","'powell","'",",","'steepest","'",",","'cg","'",",","'bfgs","'",",","'simplex","'",")","*","*","kwargs",":","dict","keyword","arguments","to","pass","to","optimizer","Returns","--","--","--","-","T",":","object","Locally","optimal","transformation"]
code: def optimize(self, T, optimizer=OPTIMIZER, **kwargs):
      """Optimize transform `T` with respect to similarity measure.
  
      The input object `T` will change as a result of the optimization.
  
      Parameters
      ----------
      T : object or str
        An object representing a transformation that should
        implement ``apply`` method and ``param`` attribute or
        property. If a string, one of 'rigid', 'similarity', or
        'affine'. The corresponding transformation class is then
        initialized by default.
      optimizer : str
        Name of optimization function (one of 'powell', 'steepest',
        'cg', 'bfgs', 'simplex')
      **kwargs : dict
        keyword arguments to pass to optimizer
  
      Returns
      -------
      T : object
        Locally optimal transformation
      """
      # Replace T if a string is passed
      if T in affine_transforms:
          T = affine_transforms[T]()
  
      # Pull callback out of keyword arguments, if present
      callback = kwargs.pop("callback", None)
  
      # Create transform chain object with T generating params
      Tv = ChainTransform(
          T, pre=self._from_affine, post=self._to_inv_affine
      )
      tc0 = Tv.param
  
      # Cost function to minimize
      def cost(tc):
          # This is where the similarity function is calculated
          Tv.param = tc
          return -self._eval(Tv)
  
      # Callback during optimization
      if callback is None and VERBOSE:
  
          def callback(tc):
              Tv.param = tc
              print(Tv.optimizable)
              print(str(self.similarity) + f" = {self._eval(Tv)}")
              print("")
  
      # Switching to the appropriate optimizer
      if VERBOSE:
          print("Initial guess...")
          print(Tv.optimizable)
  
      kwargs.setdefault("xtol", XTOL)
      kwargs.setdefault("ftol", FTOL)
      kwargs.setdefault("gtol", GTOL)
      kwargs.setdefault("maxiter", MAXITER)
      kwargs.setdefault("maxfun", MAXFUN)
  
      fmin, args, kwargs = configure_optimizer(
          optimizer, fprime=None, fhess=None, **kwargs
      )
  
      # Output
      if VERBOSE:
          print(f"Optimizing using {fmin.__name__}")
      kwargs["callback"] = callback
      Tv.param = fmin(cost, tc0, *args, **kwargs)
      return Tv.optimizable
  
imports: import numpy
  import scipy.ndimage
  from ...core.image.image_spaces import as_xyz_image, make_xyz_image, xyz_affine
  from ._registration import _joint_histogram
  from .affine import affine_transforms, inverse_affine, subgrid_affine
  from .chain_transform import ChainTransform
  from .optimizer import configure_optimizer
  from .similarity_measures import similarity_measures
label_desc: Use image node_id 13 for calling the HistogramRegistration obj's underlying member method code with example usage: obj.optimize(T, optimizer) and returns: Tv, unknown