Skip to content

deformable_registration

This is a part of the implementation of the stochastic registration algorithm based on the following paper: Andriy Myronenko and Xubo Song, "Point set registration: Coherent Point drift", IEEE Transactions on Pattern Analysis and Machine Intelligence. 32 (2): 2262-2275, 2010.

The library is based on the python implementation of the paper in pycpd package.

DeformableRegistration(alpha=ALPHA, beta=BETA, *args, **kwargs) Link

Bases: ExpectationMaximizationRegistration

Implement a deformable registration by Expectation-Maximization.

Attributes:

Name Type Description
alpha float

???.

beta float

???.

W ndarray

???.

G ndarray

???.

Initialize the deformable registration algorithm.

Parameters:

Name Type Description Default
alpha float

???. Defaults to ALPHA.

ALPHA
beta float

???. Defaults to BETA.

BETA
Source code in skeleton_refinement/deformable_registration.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def __init__(self, alpha=ALPHA, beta=BETA, *args, **kwargs):
    """Initialize the deformable registration algorithm.

    Parameters
    ----------
    alpha : float, optional
        ???.
        Defaults to `ALPHA`.
    beta : float, optional
        ???.
        Defaults to `BETA`.
    """
    super().__init__(*args, **kwargs)
    self.alpha = ALPHA if alpha is None else alpha
    self.beta = BETA if alpha is None else beta
    self.W = np.zeros((self.M, self.D))
    self.G = gaussian_kernel(self.Y, self.beta)

get_registration_parameters() Link

Retrieve the registration parameters G & W.

Source code in skeleton_refinement/deformable_registration.py
82
83
84
def get_registration_parameters(self):
    """Retrieve the registration parameters `G` & `W`."""
    return self.G, self.W

transform_point_cloud(Y=None) Link

???

Source code in skeleton_refinement/deformable_registration.py
60
61
62
63
64
65
66
def transform_point_cloud(self, Y=None):
    """???"""
    if Y is None:
        self.TY = self.Y + np.dot(self.G, self.W)
        return
    else:
        return Y + np.dot(self.G, self.W)

update_transform() Link

???

Source code in skeleton_refinement/deformable_registration.py
54
55
56
57
58
def update_transform(self):
    """???"""
    A = np.dot(np.diag(self.P1), self.G) + self.alpha * self.sigma2 * np.eye(self.M)
    B = np.dot(self.P, self.X) - np.dot(np.diag(self.P1), self.Y)
    self.W = np.linalg.solve(A, B)

update_variance() Link

???

Source code in skeleton_refinement/deformable_registration.py
68
69
70
71
72
73
74
75
76
77
78
79
80
def update_variance(self):
    """???"""
    qprev = self.sigma2

    xPx = np.dot(np.transpose(self.Pt1), np.sum(np.multiply(self.X, self.X), axis=1))
    yPy = np.dot(np.transpose(self.P1), np.sum(np.multiply(self.TY, self.TY), axis=1))
    trPXY = np.sum(np.multiply(self.TY, np.dot(self.P, self.X)))

    self.sigma2 = (xPx - 2 * trPXY + yPy) / (self.Np * self.D)

    if self.sigma2 <= 0:
        self.sigma2 = self.tolerance / 10
    self.err = np.abs(self.sigma2 - qprev)