def test_simetry_of_aligment(self):
        """Check registration using inverse composition"""
        warping = elastic_registration_warping(self.unimodal_samples,
                                               self.template)
        inverse = invert_warping(warping)
        register = self.template_rep.compose(inverse)
        distances = np.diag(metric(self.unimodal_samples, register))

        np.testing.assert_allclose(distances, 0, atol=12e-3)
Beispiel #2
0
    def test_invert_warping(self):

        inverse = invert_warping(self.polynomial)

        # Check if identity
        id = self.polynomial.compose(inverse)

        np.testing.assert_array_almost_equal([self.time, self.time],
                                             id.data_matrix[..., 0],
                                             decimal=3)
Beispiel #3
0
    def test_simmetry_of_aligment(self):
        """Check registration using inverse composition"""
        reg = ElasticRegistration(template=self.template)
        reg.fit_transform(self.unimodal_samples)
        warping = reg.warping_
        inverse = invert_warping(warping)
        register = self.template_rep.compose(inverse)
        distances = np.diag(metric(self.unimodal_samples, register))

        np.testing.assert_allclose(distances, 0, atol=12e-3)
Beispiel #4
0
t = np.linspace(0, 1)
fig.axes[0].plot(t, t, linestyle='--')

# Legend
fig.axes[0].legend(['$\\gamma$', '$\\gamma_{id}$'])

fig

##############################################################################
# The transformation necessary to align :math:`g` to :math:`f` will be the
# inverse of the original warping function, :math:`\gamma^{-1}`.
# This fact is a consequence of the use of the Fisher-Rao metric as energy
# function.
#

warping_inverse = invert_warping(warping)

fig = fd.plot(label='$f$')
g.compose(warping_inverse).plot(fig=fig, color='C1', linestyle='--')


# Legend
fig.axes[0].legend(['$f$', '$g$', '$g \\circ \\gamma^{-1} $'])

##############################################################################
# The amount of deformation used in the registration can be controlled by
# using a variation of the metric with a penalty term
# :math:`\lambda \mathcal{R}(\gamma)` wich will reduce the elasticity of the
# metric.
#
# The following figure shows the original curves and the result to the