Skip to content

Commit

Permalink
Merge pull request #226 from dzenanz/testsAndDocs
Browse files Browse the repository at this point in the history
ENH: Enable unit tests which are no longer failing
  • Loading branch information
thewtex committed Apr 26, 2024
2 parents 1959142 + 0070c46 commit 79c8195
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 34 deletions.
27 changes: 21 additions & 6 deletions include/itkTileMontage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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ć, [email protected]
*
* \ingroup Montage
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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);

Expand All @@ -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)
{
Expand All @@ -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);

Expand Down Expand Up @@ -203,11 +217,12 @@ class ITK_TEMPLATE_EXPORT TileMontage : public ProcessObject
return static_cast<TransformOutputType *>(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<float>;

/** 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
Expand Down
51 changes: 23 additions & 28 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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}
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}_
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 79c8195

Please sign in to comment.