From 801bf31a6a69912df1eb536c86133036631acead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Thu, 25 Apr 2024 16:07:33 -0400 Subject: [PATCH 1/3] ENH: Enable unit tests which are no longer failing --- test/CMakeLists.txt | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8547dd9b..c6072dd7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -494,17 +494,14 @@ itk_add_test(NAME itkMontageGroundTruthMake${tempDir} COMMAND MontageTestDriver itkMontageTruthCreator DATA{Input/DzZ_T1/DzZ_T1_orig.nhdr,DzZ_T1_orig.raw.gz} ${outDir} 3 6 3 25 15 50 ) -set(regressionPart "") -if (Module_Montage_EnableFailingTests) - set(regressionPart --compare DATA{Input/DzZ_T1/DzZ_T1_orig.nhdr} ${TESTING_OUTPUT_PATH}/itkMontageGT${tempDir}_2_1.mha) -endif() itk_add_test(NAME itkMontageGroundTruthRun${tempDir} COMMAND MontageTestDriver # a lot of tolerances are required because the reconstruction is not perfect --compareRadiusTolerance 1 --compareIntensityTolerance 128 --compareNumberOfPixelsTolerance 300 - ${regressionPart} + --compare DATA{Input/DzZ_T1/DzZ_T1_orig.nhdr} + ${TESTING_OUTPUT_PATH}/itkMontageGT${tempDir}_2_1.mha itkMontageTest ${outDir} ${TESTING_OUTPUT_PATH}/itkMontageGT${tempDir}_ @@ -558,19 +555,17 @@ if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/Input/Ti7/Region2_150_Mosaic36Flat/36/1323. 0 1 1 5 0 0 1 0 1 ) - if (Module_Montage_EnableFailingTests) - itk_add_test(NAME itkMontagePCMFiles36_088 - COMMAND MontageTestDriver - itkMontagePCMTestFiles - ${rawPrefix}088.tif - ${rawPrefix}089.tif - ${TESTING_OUTPUT_PATH}/itkMontagePCMFiles36raw088_089.nrrd - 81.28 - 0.0 - 0.0 - 0.0 - ) - endif() # Module_Montage_EnableFailingTests + itk_add_test(NAME itkMontagePCMFiles36_088 + COMMAND MontageTestDriver + itkMontagePCMTestFiles + ${rawPrefix}088.tif + ${rawPrefix}089.tif + ${TESTING_OUTPUT_PATH}/itkMontagePCMFiles36raw088_089.nrrd + 81.28 + 0.0 + 0.0 + 0.0 + ) endif() if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/Input/Ti7/Region1_10_Mosaic36/Ti-7Al_Region #1_10_Mosaic_36_p323.tif") From 06cacd62adfb176c31897f4230c8aca343439f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Thu, 25 Apr 2024 16:07:33 -0400 Subject: [PATCH 2/3] ENH: Add per-test regression intensity tolerance The montages with 16 bit depth need 256x higher intensity comparison tolerance than 8-bit ones. --- test/CMakeLists.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c6072dd7..1527e76c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -294,6 +294,7 @@ AddTestTi64raw(3) AddTestTi64raw(4) option(Module_Montage_EnableFailingTests "Should we enable tests which are failing due to not-yet-resolved issues?" OFF) +# we should remove this option once we resolve https://github.com/InsightSoftwareConsortium/ITK/issues/4613 # have uniform options for GroundTruthTests set(varyingPaddingMethods 0) @@ -306,7 +307,7 @@ set(allowDrift 1) set(positionTolerance 0) set(writeImage 1) -function(GroundTruthTest2D tempDir inputFile) # other command-line parameters +function(GroundTruthTest2D tempDir inputFile intensityTolerance) # other command-line parameters set(outDir ${TESTING_OUTPUT_PATH}/${tempDir}/) file(MAKE_DIRECTORY ${outDir}) itk_add_test(NAME itkMontageGroundTruthMake${tempDir} @@ -321,9 +322,8 @@ function(GroundTruthTest2D tempDir inputFile) # other command-line parameters itk_add_test(NAME itkMontageGroundTruthRun${tempDir} COMMAND MontageTestDriver - # these tolerances only work for small uchar cases --compareRadiusTolerance 1 - --compareIntensityTolerance 16 + --compareIntensityTolerance ${intensityTolerance} --compareNumberOfPixelsTolerance 1500 ${regressionPart} itkMontageTest @@ -344,13 +344,13 @@ function(GroundTruthTest2D tempDir inputFile) # other command-line parameters PROPERTIES DEPENDS itkMontageGroundTruthMake${tempDir}) endfunction() -GroundTruthTest2D(10-129 DATA{Input/10-129-C_2/10-129-C_2_p00.jpg} 6 4 15 25) -GroundTruthTest2D(run2 DATA{Input/05MAR09_run2_64-Raw/05MAR09_run2_64-Raw_p0.bmp} 4 5 15 10) -GroundTruthTest2D(MediumCarbonSteel DATA{Input/MediumCarbonSteel/1701701_000000_Fused.tif} 11 3 20 20) -GroundTruthTest2D(MNML3 DATA{Input/MNML_3_200x_701/MNML-3-ITK.png} 4 5 5 5) -GroundTruthTest2D(MNML5 DATA{Input/MNML_5_500x_101/MNML_5-ITK.png} 6 9 5 5) -GroundTruthTest2D(VisibleHuman DATA{Input/VisibleHumanRGB/VisibleHumanMale1608.png} 5 4 15 15) -GroundTruthTest2D(OMC14 DATA{Input/OMC/FlatField/14/OMC14-ITK.tif} 8 6 10 10) +GroundTruthTest2D(10-129 DATA{Input/10-129-C_2/10-129-C_2_p00.jpg} 16 6 4 15 25) +GroundTruthTest2D(run2 DATA{Input/05MAR09_run2_64-Raw/05MAR09_run2_64-Raw_p0.bmp} 16 4 5 15 10) +GroundTruthTest2D(MediumCarbonSteel DATA{Input/MediumCarbonSteel/1701701_000000_Fused.tif} 4096 11 3 20 20) +GroundTruthTest2D(MNML3 DATA{Input/MNML_3_200x_701/MNML-3-ITK.png} 16 4 5 5 5) +GroundTruthTest2D(MNML5 DATA{Input/MNML_5_500x_101/MNML_5-ITK.png} 16 6 9 5 5) +GroundTruthTest2D(VisibleHuman DATA{Input/VisibleHumanRGB/VisibleHumanMale1608.png} 16 5 4 15 15) +GroundTruthTest2D(OMC14 DATA{Input/OMC/FlatField/14/OMC14-ITK.tif} 4096 8 6 10 10) itk_add_test(NAME itkMontage-10-129-C_2 From 0070c463dae42aefc6bcbb2daf2d7c02081e908f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Thu, 25 Apr 2024 16:06:44 -0400 Subject: [PATCH 3/3] DOC: Improve class description and documentation of parameters --- include/itkTileMontage.h | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/include/itkTileMontage.h b/include/itkTileMontage.h index 9948c7fc..603f38b2 100644 --- a/include/itkTileMontage.h +++ b/include/itkTileMontage.h @@ -35,6 +35,13 @@ namespace itk * * Determines registrations which can be used to resample a mosaic into a single image. * + * This deals with n-dimensional rectangular arrays of image tiles. + * Arbitrarily shaped tile arrays (e.g. circular) are not directly supported. + * A possible (untested) workaround is adding all-zero (black) tiles around the shape + * to make a regular rectangular tile array (2D, 3D, or nD). + * + * Take a look a documentation of parameters, most influential of which is PositionTolerance. + * * \author Dženan Zukić, dzenan.zukic@kitware.com * * \ingroup Montage @@ -111,6 +118,7 @@ class ITK_TEMPLATE_EXPORT TileMontage : public ProcessObject /** Set/Get absolute registration threshold. * The maximum allowed residual error for a registration pair during * global optimization. Expressed in number of pixels. Default: 1.0. + * Reasonable values are from around 0.8 to around 1.5. * When a registration pair exceeds the threshold, it is replaced by * the next best candidate for that pair. If all canidates are * exhausted, the registration pair is assumed to have no translation. @@ -121,6 +129,7 @@ class ITK_TEMPLATE_EXPORT TileMontage : public ProcessObject /** Set/Get relative registration threshold. * The maximum allowed deviation for a registration pair during global * optimization. Expressed in multiples of standard deviation. Default: 3.0. + * Reasonable values are from around 2 to around 5. * The deviation is calculated by taking the translations of all the * registration pairs, while assuming zero mean. This implies expectation * that deviations from expected positions for all registration pairs @@ -131,7 +140,10 @@ class ITK_TEMPLATE_EXPORT TileMontage : public ProcessObject /** Set/Get tile positioning precision. * Get/Set expected maximum linear translation needed, in pixels. * Zero (the default) means unknown, and allows translations - * up to about half the image size.*/ + * up to about half the image size. + * This is an important parameter for reliability of pair-wise registrations, + * but it is microscope-dependent so we cannot have a restrictive default. + */ itkSetMacro(PositionTolerance, SizeValueType); itkGetConstMacro(PositionTolerance, SizeValueType); @@ -145,7 +157,7 @@ class ITK_TEMPLATE_EXPORT TileMontage : public ProcessObject /** Set/Get obligatory padding. * If set, padding of this many pixels is added on both beginning and end - * sides of each dimension of the image. */ + * sides of each dimension of the image. Default value of 8 is usually fine. */ virtual void SetObligatoryPadding(const SizeType pad) { @@ -157,11 +169,13 @@ class ITK_TEMPLATE_EXPORT TileMontage : public ProcessObject } itkGetConstMacro(ObligatoryPadding, SizeType); - /** Set/Get the padding method. */ + /** Set/Get the padding method. + * The default (MirrorWithExponentialDecay) is usually the best. */ itkSetEnumMacro(PaddingMethod, typename PCMType::PaddingMethodEnum); itkGetConstMacro(PaddingMethod, typename PCMType::PaddingMethodEnum); - /** Set/Get the peak interpolation method. */ + /** Set/Get the peak interpolation method. + * The default (Parabolic) is usually the best. */ itkSetEnumMacro(PeakInterpolationMethod, typename PCMOptimizerType::PeakInterpolationMethodEnum); itkGetConstMacro(PeakInterpolationMethod, typename PCMOptimizerType::PeakInterpolationMethodEnum); @@ -203,11 +217,12 @@ class ITK_TEMPLATE_EXPORT TileMontage : public ProcessObject return static_cast(this->GetOutput(this->nDIndexToLinearIndex(position)))->Get(); } - /** Reliability of each tile, highest normalized to 1.0. */ + /** Reliability of each tile, highest normalized to 1.0.*/ using TileReliabilities = std::vector; /** Tile reliability, from 0.0 (lowest) to 1.0 (highest). - * This can be used to judge successfulness of registration to adjacent tiles. */ + * This can be used to judge successfulness of registration to adjacent tiles. + * The lowest reliability is usually around 0.01 to 0.1. */ itkGetConstReferenceMacro(TileReliabilities, TileReliabilities); float GetTileReliability(DataObjectPointerArraySizeType linearIndex) const