Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit dad4bcce authored by Gustavo Pinzon's avatar Gustavo Pinzon
Browse files

Test for ddicTools

parent 1e42c974
Pipeline #54279 passed with stages
in 25 minutes and 29 seconds
......@@ -1084,6 +1084,15 @@ class testAll(unittest.TestCase):
# Check that the F matrix is equal to the initial
self.assertTrue((tsvRes['PhiField'][10][:-1, :-1] == TSV['PhiField'][10][:-1, :-1]).all())
# Case 3: Run the function with an incomplete TSV file
TSV = spam.helpers.readCorrelationTSV('Step0-Step1-discreteDVC.tsv',
readConvergence=False,
readError=False,
readLabelDilate=False,
readPSCC=False)
res = spam.deformation.deformationField.getDisplacementFromNeighbours(imLab, TSV, './TSV_getDisplacementFromNeighbours.tsv', previousDVC = TSV)
self.assertIsNone(res)
def test_mergeRegistrationAndDiscreteFields(self):
#Create an initial Lab
......
......@@ -39,6 +39,7 @@ PSCC = numpy.full((fieldCoords.shape[0]), 0.2)
TSVheader = "NodeNumber\tZpos\tYpos\tXpos\tFzz\tFzy\tFzx\tZdisp\tFyz\tFyy\tFyx\tYdisp\tFxz\tFxy\tFxx\tXdisp\treturnStatus\tdeltaPhiNorm\titerations"
TSVheaderOld = "NodeNumber\tZpos\tYpos\tXpos\tF11\tF12\tF13\tF14\tF21\tF22\tF23\tF24\tF31\tF32\tF33\tF34\tSubPixReturnStat\tSubPixDeltaPhiNorm\tSubPixIterations"
TSVheaderDiscrete = "Label\tZpos\tYpos\tXpos\tF11\tF12\tF13\tZdisp\tF21\tF22\tF23\tYdisp\tF31\tF32\tF33\tXdisp\treturnStatus\tdeltaPhiNorm\titerations\terror\tLabelDilate\tPSCC"
TSVheaderDiscreteSimple = "Label\tZpos\tYpos\tXpos\tF11\tF12\tF13\tZdisp\tF21\tF22\tF23\tYdisp\tF31\tF32\tF33\tXdisp\treturnStatus\tdeltaPhiNorm\titerations"
outMatrix = numpy.array([numpy.array(range(PhiField.shape[0])),
fieldCoords[:, 0], fieldCoords[:, 1], fieldCoords[:, 2],
......@@ -53,11 +54,19 @@ outMatrixDiscrete = numpy.array([numpy.array(range(PhiField.shape[0])),
PhiField[:, 1, 0], PhiField[:, 1, 1], PhiField[:, 1, 2], PhiField[:, 1, 3],
PhiField[:, 2, 0], PhiField[:, 2, 1], PhiField[:, 2, 2], PhiField[:, 2, 3],
RS, DF, IT, error, labelDilate, PSCC]).T
outMatrixDiscreteSimple = numpy.array([numpy.array(range(PhiField.shape[0])),
fieldCoords[:, 0], fieldCoords[:, 1], fieldCoords[:, 2],
PhiField[:, 0, 0], PhiField[:, 0, 1], PhiField[:, 0, 2], PhiField[:, 0, 3],
PhiField[:, 1, 0], PhiField[:, 1, 1], PhiField[:, 1, 2], PhiField[:, 1, 3],
PhiField[:, 2, 0], PhiField[:, 2, 1], PhiField[:, 2, 2], PhiField[:, 2, 3],
RS, DF, IT]).T
numpy.savetxt("spamPhiField.tsv", outMatrix, fmt='%.7f', delimiter='\t', newline='\n', comments='', header=TSVheader)
numpy.savetxt("spamPhiFieldOld.tsv", outMatrix, fmt='%.7f', delimiter='\t', newline='\n', comments='', header=TSVheaderOld)
numpy.savetxt("spamPhiFieldOldReg.tsv", numpy.array([outMatrix[0, :]]), fmt='%.7f', delimiter='\t', newline='\n', comments='', header=TSVheaderOld)
numpy.savetxt("spamPhiFieldDiscrete.tsv", outMatrixDiscrete, fmt='%.7f', delimiter='\t', newline='\n', comments='', header=TSVheaderDiscrete)
numpy.savetxt("spamPhiFieldDiscreteSimple.tsv", outMatrixDiscreteSimple, fmt='%.7f', delimiter='\t', newline='\n', comments='', header=TSVheaderDiscreteSimple)
numpy.savetxt("spamPhiFieldDiscreteSimpleLine.tsv", numpy.array([outMatrixDiscreteSimple[0, :]]), fmt='%.7f', delimiter='\t', newline='\n', comments='', header=TSVheaderDiscreteSimple)
class testAll(unittest.TestCase):
......@@ -69,6 +78,8 @@ class testAll(unittest.TestCase):
os.remove("spamReg2D.tsv")
os.remove("spamPhiField.tsv")
os.remove("spamPhiFieldDiscrete.tsv")
os.remove("spamPhiFieldDiscreteSimple.tsv")
os.remove("spamPhiFieldDiscreteSimpleLine.tsv")
os.remove("spamPhiFieldOld.tsv")
os.remove("spamPhiFieldOldReg.tsv")
os.remove("spamPhiField-Zdisp.tif")
......@@ -151,6 +162,18 @@ class testAll(unittest.TestCase):
self.assertAlmostEqual(PSCC.sum(), f3["PSCC"].sum(), places=4)
self.assertAlmostEqual(labelDilate.sum(), f3["LabelDilate"].sum(), places=4)
# case 4a: read simple tsv file with all the options (but no data)
f4 = tsvio.readCorrelationTSV(fileName="spamPhiFieldDiscreteSimple.tsv", readConvergence= True, readError= True, readLabelDilate=True, readPSCC=True)
self.assertEqual(20, f4["numberOfLabels"])
self.assertEqual([0, 0, 0], f4["fieldDims"])
self.assertAlmostEqual(PhiField.sum(), f4["PhiField"].sum(), places=4)
# case 4b: read one-line tsv file with all the options (but no data)
f5 = tsvio.readCorrelationTSV(fileName="spamPhiFieldDiscreteSimpleLine.tsv", readConvergence= True, readError= True, readLabelDilate=True, readPSCC=True)
self.assertEqual(1, f5["numberOfLabels"])
self.assertEqual([1, 1, 1], f5["fieldDims"])
self.assertAlmostEqual(PhiField[0][0:3, -1].sum(), f5["PhiField"][0][0:3, -1].sum(), places=4)
def test_TSVtoTIFF(self):
import tifffile
......
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