Commit ca1afd3a authored by Olga Stamati's avatar Olga Stamati
Browse files

fix bug in applyRegistrationToPoints() plus test

parent 778535ea
Pipeline #66988 passed with stages
in 27 minutes
...@@ -846,7 +846,7 @@ def applyRegistrationToPoints(Phi, PhiCentre, points, applyF='all', nProcesses=n ...@@ -846,7 +846,7 @@ def applyRegistrationToPoints(Phi, PhiCentre, points, applyF='all', nProcesses=n
# 2. by calling the decomposePhi function to compute the translation of each point # 2. by calling the decomposePhi function to compute the translation of each point
if applyF is "all": if applyF is "all":
outputPhi = Phi.copy() outputPhi = Phi.copy()
if applyF is "rigid": elif applyF is "rigid":
outputPhi = PhiRigid.copy() outputPhi = PhiRigid.copy()
else: # applyF is displacement only else: # applyF is displacement only
outputPhi = numpy.eye(4) outputPhi = numpy.eye(4)
......
...@@ -369,11 +369,11 @@ class TestFunctionDVC(unittest.TestCase): ...@@ -369,11 +369,11 @@ class TestFunctionDVC(unittest.TestCase):
def test_makeGrid(self): def test_makeGrid(self):
# 3D image # 3D image
nodePositions, nodesDim = spam.DIC.grid.makeGrid((50, 50, 50), 10) nodePositions, nodesDim = spam.DIC.makeGrid((50, 50, 50), 10)
self.assertEqual((4, 4, 4), nodesDim) self.assertEqual((4, 4, 4), nodesDim)
# 2D image # 2D image
nodePositions, nodesDim2D = spam.DIC.grid.makeGrid((1, 50, 50), 10) nodePositions, nodesDim2D = spam.DIC.makeGrid((1, 50, 50), 10)
self.assertEqual((1, 4, 4), nodesDim2D) self.assertEqual((1, 4, 4), nodesDim2D)
im = spam.datasets.loadSnow() im = spam.datasets.loadSnow()
...@@ -689,6 +689,23 @@ class TestFunctionDVC(unittest.TestCase): ...@@ -689,6 +689,23 @@ class TestFunctionDVC(unittest.TestCase):
self.assertTrue(numpy.allclose(interpolatedPhi[0, 0:3, -1], transformation['t'], atol=0.01)) self.assertTrue(numpy.allclose(interpolatedPhi[0, 0:3, -1], transformation['t'], atol=0.01))
self.assertTrue(numpy.allclose(interpolatedPhi[0, 0:3, 0:3], Phi[0:3, 0:3], atol=0.01)) self.assertTrue(numpy.allclose(interpolatedPhi[0, 0:3, 0:3], Phi[0:3, 0:3], atol=0.01))
def test_applyRegistrationToPoints(self):
Phi = spam.deformation.computePhi({"t": numpy.random.randint(1, 10, size=3),
"r": numpy.random.randint(1, 10, size=3),
"z": numpy.random.uniform(low=0.80, high=1.15, size=3),
})
points, nodesDim = spam.DIC.makeGrid((100, 100, 100), 10)
PhiCentre = [50, 50, 50]
PhiField = spam.DIC.applyRegistrationToPoints(Phi, PhiCentre, points, verbose=False)
self.assertTrue(numpy.allclose(numpy.mean(PhiField[:, 0:3, 0:3], axis=0), Phi[0:3, 0:3], atol=0.001))
self.assertTrue(numpy.allclose(PhiField[points.shape[0]//2], Phi, atol=0.001))
PhiField = spam.DIC.applyRegistrationToPoints(Phi, PhiCentre, points, applyF="rigid", verbose=False)
self.assertTrue(numpy.allclose(numpy.mean(PhiField[:, 0:3, 0:3], axis=0), spam.deformation.computeRigidPhi(Phi)[0:3, 0:3], atol=0.001))
PhiField = spam.DIC.applyRegistrationToPoints(Phi, PhiCentre, points, applyF="no", verbose=False)
self.assertTrue(numpy.allclose(numpy.mean(PhiField[:, 0:3, 0:3], axis=0), numpy.eye(3), atol=0.001))
def test_LQC(self): def test_LQC(self):
points, _ = spam.DIC.grid.makeGrid((10, 10, 10), 2) points, _ = spam.DIC.grid.makeGrid((10, 10, 10), 2)
disp = numpy.ones_like(points, dtype='<f4')*5 disp = numpy.ones_like(points, dtype='<f4')*5
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment