Skip to content

Commit

Permalink
ENH: Cleaning up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanz committed Sep 27, 2024
1 parent 34f9d91 commit 7b59c75
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 51 deletions.
2 changes: 1 addition & 1 deletion include/itkANTSGroupwiseRegistration.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace itk
*
*/
template <typename TImage,
typename TTemplateImage = ::itk::Image<float, TImage::ImageDimension>,
typename TTemplateImage = Image<float, TImage::ImageDimension>,
typename TParametersValueType = double>
class ANTSGroupwiseRegistration : public ImageToImageFilter<TTemplateImage, TTemplateImage>
{
Expand Down
2 changes: 1 addition & 1 deletion test/Baseline/PythonANTsGroupwiseBrainSlices.nrrd.cid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bafkreigmboiru3wwwvv4nnfdkcs36wr6w3gsrkdqf47kpwojvdh3d2utui
bafkreicvwcuenu5nlt3m7q7h6vf2ef3d6llkvv6zs7w7k7anj3qsh62fpe
1 change: 1 addition & 0 deletions test/Baseline/PythonANTsGroupwiseFaces.png.cid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreid4bibdjbbo5hgeo6yfbxbdhatosxprngkfvazbzgzo7je7tnujmy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bafkreig3nkiq2qar3zmavuxp3hhjqzron2wvacn5vlwswu3axovbt2xkzm
49 changes: 5 additions & 44 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,22 @@ itk_add_test(NAME itkANTSRegistrationBasicTests
itkANTSRegistrationBasicTests ${ITK_TEST_OUTPUT_DIR}
)

itk_add_test(NAME itkANTsGroupwiseRegistrationTestFacesAffine
COMMAND ANTsWasmTestDriver
--compare
DATA{Baseline/itkANTsGroupwiseRegistrationTestFacesAffine.png}
${ITK_TEST_OUTPUT_DIR}/itkANTsGroupwiseRegistrationTestFacesAffine.nrrd
itkANTSGroupwiseRegistrationTestFaces
DATA{${CMAKE_CURRENT_LIST_DIR}/Input/face10.png,REGEX:face[0-9]+\\.png} # download data at build time
${ITK_TEST_OUTPUT_DIR}/itkANTsGroupwiseRegistrationTestFacesAffine.nrrd
10
Affine
)

itk_add_test(NAME itkANTsGroupwiseRegistrationTestFacesSyNFromAffineTemplate
COMMAND ANTsWasmTestDriver
--compare
DATA{Baseline/T_template0Result337.nrrd}
${ITK_TEST_OUTPUT_DIR}/itkANTsGroupwiseRegistrationTestFacesSyNFromAffineTemplate.nrrd
itkANTSGroupwiseRegistrationTestFaces
DATA{${CMAKE_CURRENT_LIST_DIR}/Input/face10.png,REGEX:face[0-9]+\\.png} # download data at build time
${ITK_TEST_OUTPUT_DIR}/itkANTsGroupwiseRegistrationTestFacesSyNFromAffineTemplate.nrrd
10
SyN
DATA{Baseline/itkANTsGroupwiseRegistrationTestFacesAffine.png}
)

itk_add_test(NAME itkANTsGroupwiseRegistrationTestFacesDirectSyN
COMMAND ANTsWasmTestDriver
--compare
DATA{Baseline/T_template0Result337.nrrd}
DATA{Baseline/itkANTsGroupwiseRegistrationTestFacesDirectSyN.png}
${ITK_TEST_OUTPUT_DIR}/itkANTsGroupwiseRegistrationTestFacesDirectSyN.nrrd
--compareIntensityTolerance 10
--compareRadiusTolerance 3
--compareNumberOfPixelsTolerance 1000
itkANTSGroupwiseRegistrationTestFaces
DATA{${CMAKE_CURRENT_LIST_DIR}/Input/face10.png,REGEX:face[0-9]+\\.png} # download data at build time
${ITK_TEST_OUTPUT_DIR}/itkANTsGroupwiseRegistrationTestFacesDirectSyN.nrrd
10
SyN
)

itk_add_test(NAME itkANTsGroupwiseRegistrationTestFacesBSplineSyN
COMMAND ANTsWasmTestDriver
--compare
DATA{Baseline/T_template0Result337.nrrd}
${ITK_TEST_OUTPUT_DIR}/itkANTsGroupwiseRegistrationTestFacesBSplineSyN.nrrd
itkANTSGroupwiseRegistrationTestFaces
DATA{${CMAKE_CURRENT_LIST_DIR}/Input/face10.png,REGEX:face[0-9]+\\.png} # download data at build time
${ITK_TEST_OUTPUT_DIR}/itkANTsGroupwiseRegistrationTestFacesBSplineSyN.nrrd
10
BSplineSyN
)

# Debugging, test data only present locally
# itk_add_test(NAME itkANTSGroupwiseRegistrationTest3D
# COMMAND ANTsWasmTestDriver itkANTSGroupwiseRegistrationTest3D
# C:/a/lola11CT ${ITK_TEST_OUTPUT_DIR}
# )

# the rest are pairwise registration tests, mostly taken directly from reference ANTs (C++ and scripts)

itk_add_test(NAME antsRegistrationTest_AffineScaleMasks
COMMAND ANTsWasmTestDriver
Expand Down
2 changes: 1 addition & 1 deletion test/itkANTSGroupwiseRegistrationTestFaces.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ itkANTSGroupwiseRegistrationTestFaces(int argc, char * argv[])
}

filter->SetImageList(images);
filter->SetIterations(6);
filter->SetIterations(4);
filter->SetGradientStep(0.15);

using PairwiseType = itk::ANTSRegistration<FloatImageType, ImageType, float>;
Expand Down
9 changes: 6 additions & 3 deletions wrapping/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ itk_python_expression_add_test(NAME PythonInstantiateANTSGroupwiseRegistrationSh
itk_python_add_test(NAME PythonANTsGroupwiseFaces
TEST_DRIVER_ARGS
--compare
DATA{${test_baseline_dir}/T_template0Result337.nrrd}
DATA{${test_baseline_dir}/PythonANTsGroupwiseFaces.png}
${ITK_TEST_OUTPUT_DIR}/PythonANTsGroupwiseFaces.nrrd
--compareIntensityTolerance 10
--compareRadiusTolerance 3
--compareNumberOfPixelsTolerance 1000
COMMAND PythonANTsGroupwiseFaces.py
-o ${ITK_TEST_OUTPUT_DIR}/PythonANTsGroupwiseFaces.nrrd
-i DATA{${test_input_dir}/face1.png}
Expand All @@ -50,8 +53,8 @@ itk_python_add_test(NAME PythonANTsGroupwiseBrainSlices
DATA{${test_baseline_dir}/PythonANTsGroupwiseBrainSlices.nrrd}
${ITK_TEST_OUTPUT_DIR}/PythonANTsGroupwiseBrainSlices.nrrd
--compareIntensityTolerance 10
--compareRadiusTolerance 1
--compareNumberOfPixelsTolerance 1000
--compareRadiusTolerance 5
--compareNumberOfPixelsTolerance 2000
COMMAND PythonANTsGroupwiseBrainSlices.py
-o ${ITK_TEST_OUTPUT_DIR}/PythonANTsGroupwiseBrainSlices.nrrd
-i DATA{${test_input_dir}/OASIS-TRT-20-10Slice121.nii.gz}
Expand Down
3 changes: 2 additions & 1 deletion wrapping/test/PythonANTsGroupwiseFaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@
images.append(image)
gwr.SetImageList(images)

gwr.SetIterations(6)
gwr.SetIterations(4)
gwr.SetGradientStep(0.15)

pwr.SetTypeOfTransform("BSplineSyN")
pwr.SetSynMetric("CC")
pwr.SetSynIterations([100, 100, 100, 70, 50, 10])
pwr.SetShrinkFactors([16, 12, 8, 4, 2, 1])
pwr.SetSmoothingSigmas([4, 4, 4, 2, 1, 0])
pwr.SetRandomSeed(30101983) # improve reproducibility

gwr.SetPairwiseRegistration(pwr)
print(gwr)
Expand Down

0 comments on commit 7b59c75

Please sign in to comment.