class_docstr: Deformable point cloud registration.
  
  Attributes
  ----------
  X: numpy array
      NxD array of target points.
  
  Y: numpy array
      MxD array of source points.
  
  TY: numpy array
      MxD array of transformed source points.
  
  sigma2: float (positive)
      Initial variance of the Gaussian mixture model.
  
  N: int
      Number of target points.
  
  M: int
      Number of source points.
  
  D: int
      Dimensionality of source and target points
  
  iteration: int
      The current iteration throughout registration.
  
  max_iterations: int
      Registration will terminate once the algorithm has taken this
      many iterations.
  
  tolerance: float (positive)
      Registration will terminate once the difference between
      consecutive objective function values falls within this tolerance.
  
  w: float (between 0 and 1)
      Contribution of the uniform distribution to account for outliers.
      Valid values span 0 (inclusive) and 1 (exclusive).
  
  q: float
      The objective function value that represents the misalignment between
      source and target point clouds.
  
  diff: float (positive)
      The absolute difference between the current and previous objective
      function values.
  
  P: numpy array
      MxN array of probabilities.
      P[m, n] represents the probability that the m-th source point
      corresponds to the n-th target point.
  
  Pt1: numpy array
      Nx1 column array. Multiplication result between the transpose of P
      and a column vector of all 1s.
  
  P1: numpy array
      Mx1 column array.
      Multiplication result between P and a column vector of all 1s.
  
  Np: float (positive)
      The sum of all elements in P.
  
  alpha: float (positive)
      Represents the trade-off between the goodness of maximum likelihoo
      fit and regularization.
  
  beta: float(positive)
      Width of the Gaussian kernel.
  
  low_rank: bool
      Whether to use low rank approximation.
  
  num_eig: int
      Number of eigenvectors to use in lowrank calculation.
class_docstr_tok: ["Deformable","point","cloud","registration",".","Attributes","--","--","--","--","--","X",":","numpy","array","NxD","array","of","target","points",".","Y",":","numpy","array","MxD","array","of","source","points",".","TY",":","numpy","array","MxD","array","of","transformed","source","points",".","sigma2",":","float","(","positive",")","Initial","variance","of","the","Gaussian","mixture","model",".","N",":","int","Number","of","target","points",".","M",":","int","Number","of","source","points",".","D",":","int","Dimensionality","of","source","and","target","points","iteration",":","int","The","current","iteration","throughout","registration",".","max_iterations",":","int","Registration","will","terminate","once","the","algorithm","has","taken","this","many","iterations",".","tolerance",":","float","(","positive",")","Registration","will","terminate","once","the","difference","between","consecutive","objective","function","values","falls","within","this","tolerance",".","w",":","float","(","between","0","and","1",")","Contribution","of","the","uniform","distribution","to","account","for","outliers",".","Valid","values","span","0","(","inclusive",")","and","1","(","exclusive",")",".","q",":","float","The","objective","function","value","that","represents","the","misalignment","between","source","and","target","point","clouds",".","diff",":","float","(","positive",")","The","absolute","difference","between","the","current","and","previous","objective","function","values",".","P",":","numpy","array","MxN","array","of","probabilities",".","P","[","m",",","n","]","represents","the","probability","that","the","m-th","source","point","corresponds","to","the","n-th","target","point",".","Pt1",":","numpy","array","Nx1","column","array",".","Multiplication","result","between","the","transpose","of","P","and","a","column","vector","of","all","1s",".","P1",":","numpy","array","Mx1","column","array",".","Multiplication","result","between","P","and","a","column","vector","of","all","1s",".","Np",":","float","(","positive",")","The","sum","of","all","elements","in","P.","alpha",":","float","(","positive",")","Represents","the","trade-off","between","the","goodness","of","maximum","likelihoo","fit","and","regularization",".","beta",":","float","(","positive",")","Width","of","the","Gaussian","kernel",".","low_rank",":","bool","Whether","to","use","low","rank","approximation",".","num_eig",":","int","Number","of","eigenvectors","to","use","in","lowrank","calculation","."]
code: def __init__(
      self,
      X,
      Y,
      sigma2=None,
      alpha=None,
      beta=None,
      low_rank=False,
      num_eig=100,
      max_iterations=None,
      tolerance=None,
      w=None,
      *args,
      **kwargs,
  ):
      if not isinstance(X, np.ndarray) or X.ndim != 2:
          raise ValueError(
              "The target point cloud (X) must be at a 2D numpy array."
          )
  
      if not isinstance(Y, np.ndarray) or Y.ndim != 2:
          raise ValueError(
              "The source point cloud (Y) must be a 2D numpy array."
          )
  
      if X.shape[1] != Y.shape[1]:
          msg = "Both point clouds need to have the same number "
          msg += "of dimensions."
          raise ValueError(msg)
  
      if sigma2 is not None and (
          not isinstance(sigma2, numbers.Number) or sigma2 <= 0
      ):
          msg = f"Expected a positive value for sigma2 instead got: {sigma2}"
          raise ValueError(msg)
  
      if max_iterations is not None and (
          not isinstance(max_iterations, numbers.Number)
          or max_iterations < 0
      ):
          msg = "Expected a positive integer for max_iterations "
          msg += f"instead got: {max_iterations}"
          raise ValueError(msg)
      elif isinstance(
          max_iterations, numbers.Number
      ) and not isinstance(max_iterations, int):
          msg = "Received a non-integer value for max_iterations: "
          msg += f"{max_iterations}. Casting to integer."
          warn(msg)
          max_iterations = int(max_iterations)
  
      if tolerance is not None and (
          not isinstance(tolerance, numbers.Number) or tolerance < 0
      ):
          msg = "Expected a positive float for tolerance "
          msg += f"instead got: {tolerance}"
          raise ValueError(msg)
  
      if w is not None and (
          not isinstance(w, numbers.Number) or w < 0 or w >= 1
      ):
          msg = "Expected a value between 0 (inclusive) and 1 (exclusive) "
          msg += f"for w instead got: {w}"
          raise ValueError(msg)
  
      self.X = X
      self.Y = Y
      self.TY = Y
      self.sigma2 = (
          initialize_sigma2(X, Y) if sigma2 is None else sigma2
      )
      (self.N, self.D) = self.X.shape
      (self.M, _) = self.Y.shape
      self.tolerance = 0.001 if tolerance is None else tolerance
      self.w = 0.0 if w is None else w
      self.max_iterations = (
          100 if max_iterations is None else max_iterations
      )
      self.iteration = 0
      self.diff = np.inf
      self.q = np.inf
      self.P = np.zeros((self.M, self.N))
      self.Pt1 = np.zeros((self.N,))
      self.P1 = np.zeros((self.M,))
      self.PX = np.zeros((self.M, self.D))
      self.Np = 0
  
      if alpha is not None and (
          not isinstance(alpha, numbers.Number) or alpha <= 0
      ):
          msg = (
              "Expected a positive value for regularization parameter "
          )
          msg += f"alpha. Instead got: {alpha}"
          raise ValueError(msg)
  
      if beta is not None and (
          not isinstance(beta, numbers.Number) or beta <= 0
      ):
          msg = (
              "Expected a positive value for the width of the coherent "
          )
          msg += f"Gaussian kernel. Instead got: {beta}"
  
      self.alpha = 2 if alpha is None else alpha
      self.beta = 2 if beta is None else beta
      self.W = np.zeros((self.M, self.D))
      self.G = gaussian_kernel(self.Y, self.beta)
      self.low_rank = low_rank
      self.num_eig = num_eig
      if self.low_rank is True:
          self.Q, self.S = low_rank_eigen(self.G, self.num_eig)
          self.inv_S = np.diag(1.0 / self.S)
          self.S = np.diag(self.S)
          self.E = 0.0
  
file_path: dipy/dipy/align/cpd.py
imports: import numpy
  import numbers
  from warnings import warn
label_desc: Use image node_id 1 to create a new DeformableRegistration object  with example: obj = DeformableRegistration(X, Y, sigma2, alpha, beta, low_rank, num_eig, max_iterations, tolerance, w)