docstr: centers: N times 3 array
  
  We are given a set of affine transforms T_i with centers x_i,
  all in homogeneous coordinates. The polyaffine transform is
  defined, up to a right composition with a global affine, as:
  
  T(x) = sum_i w_i(x) T_i x
  
  where w_i(x) = g(x-x_i)/Z(x) are normalized Gaussian weights
  that sum up to one for every x.
docstr_tok: ["centers",":","N","times","3","array","We","are","given","a","set","of","affine","transforms","T_i","with","centers","x_i",",","all","in","homogeneous","coordinates",".","The","polyaffine","transform","is","defined",",","up","to","a","right","composition","with","a","global","affine",",","as",":","T","(","x",")","=","sum_i","w_i","(","x",")","T_i","x","where","w_i","(","x",")","=","g","(","x-x_i",")","\/Z","(","x",")","are","normalized","Gaussian","weights","that","sum","up","to","one","for","every","x","."]
code: def __init__(self, centers, affines, sigma, glob_affine=None):
      """
      centers: N times 3 array
  
      We are given a set of affine transforms T_i with centers x_i,
      all in homogeneous coordinates. The polyaffine transform is
      defined, up to a right composition with a global affine, as:
  
      T(x) = sum_i w_i(x) T_i x
  
      where w_i(x) = g(x-x_i)/Z(x) are normalized Gaussian weights
      that sum up to one for every x.
      """
  
      # Format input arguments
      self.centers = np.asarray(centers, dtype="double", order="C")
      self.sigma = np.zeros(3)
      self.sigma[:] = np.maximum(TINY_SIGMA, sigma)
      if hasattr(affines[0], "as_affine"):
          affines = np.array([a.as_affine() for a in affines])
      else:
          affines = np.asarray(affines)
      if hasattr(glob_affine, "as_affine"):
          self.glob_affine = glob_affine.as_affine()
      else:
          self.glob_affine = glob_affine
  
      # Cache a (N, 12) matrix containing the affines coefficients,
      # should be C-contiguous double.
      self._affines = np.zeros((len(self.centers), 12))
      self._affines[:] = np.reshape(
          affines[:, 0:3, :], (len(self.centers), 12)
      )
  
file_path: nipy/nipy/algorithms/registration/polyaffine.py
imports: import numpy
  from ._registration import _apply_polyaffine
  from .affine import apply_affine
  from .transform import Transform
label_desc: Use image node_id 1 to create a new PolyAffine object from inherited base classes: Transform with example: obj = PolyAffine(centers, affines, sigma, glob_affine)