Exemple #1
0
    def register(self, fixed_points, moving_points):
        """
        Does the registration
        """
        success = False
        fre = 0.0
        expected_tre_squared = 0.0
        expected_fre_sq = 0.0
        actual_tre = 0.0
        self.transformed_target = np.zeros(shape=(1, 3), dtype=np.float64)
        no_fids = fixed_points.shape[0]

        if no_fids > 2:
            rotation, translation, fre = orthogonal_procrustes(
                fixed_points, moving_points)
            expected_tre_squared = compute_tre_from_fle(
                moving_points[:, 0:3], self.fixed_fle_esv, self.target[:, 0:3])
            expected_fre_sq = compute_fre_from_fle(moving_points[:, 0:3],
                                                   self.fixed_fle_esv)

            self.transformed_target = np.matmul(rotation,
                                                self.target.transpose()) + \
                                               translation
            actual_tre = np.linalg.norm(
                self.transformed_target - self.target[:, 0:3].transpose())
            success = True


        return [success, fre, self.fixed_fle_esv, expected_tre_squared,
                expected_fre_sq, self.transformed_target[:, 0:3], actual_tre,
                no_fids]
Exemple #2
0
def measure_tre_1(mean_fle_squared, target):

    fiducials = np.zeros((4, 3))
    fiducials[0][0] = 1
    fiducials[0][1] = 1
    fiducials[1][0] = -0.5
    fiducials[1][1] = 0.5
    fiducials[2][0] = -1
    fiducials[2][1] = -1
    fiducials[3][0] = 0.5
    fiducials[3][1] = -0.5

    error = err.compute_tre_from_fle(fiducials, mean_fle_squared, target)
    return error
Exemple #3
0
def measure_tre_2(mean_fle_squared, target):
    """This is a square to make checking moment of inertia easier"""
    fiducials = np.zeros((4, 3))
    fiducials[0][0] = 1
    fiducials[0][1] = 1
    fiducials[1][0] = -1
    fiducials[1][1] = 1
    fiducials[2][0] = 1
    fiducials[2][1] = -1
    fiducials[3][0] = -1
    fiducials[3][1] = -1

    error = err.compute_tre_from_fle(fiducials, mean_fle_squared, target)
    return error
Exemple #4
0
def test_invalid_because_fiducials_wrong_rows():
    with pytest.raises(ValueError):
        err.compute_tre_from_fle(np.ones((3, 3)), 1, np.ones((2, 3)))
Exemple #5
0
def test_invalid_because_target_wrong_columns():
    with pytest.raises(ValueError):
        err.compute_tre_from_fle(np.ones((3, 3)), 1, np.ones((1, 4)))
Exemple #6
0
def test_invalid_because_target_wrong_type():
    with pytest.raises(TypeError):
        err.compute_tre_from_fle(np.ones((3, 3)), 1, "not an array")
Exemple #7
0
def test_invalid_because_fiducials_wrong_type():
    with pytest.raises(TypeError):
        err.compute_tre_from_fle("not an arrray", 1, np.ones((1, 3)))