From 6b663a69ed14511ed7a3cb486a84b87b5a1dbd4f Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Thu, 7 May 2026 19:59:08 +0100 Subject: [PATCH 1/4] ENH: Adjust RTK applications and example to modern CMake interface See https://docs.itk.org/en/latest/migration_guides/itk_6_migration_guide.html#migration-for-itk-modules for a detailed explanation. Similar to RTKConsortium/RTK#894 --- applications/CMakeLists.txt | 24 ++++++++++++------- .../pctbackprojectionbinning/CMakeLists.txt | 2 +- applications/pctbinning/CMakeLists.txt | 2 +- applications/pctfdk/CMakeLists.txt | 2 +- applications/pctpaircuts/CMakeLists.txt | 2 +- applications/pctpairgeometry/CMakeLists.txt | 2 +- applications/pctprojections/CMakeLists.txt | 2 +- .../pctzengbackprojections/CMakeLists.txt | 2 +- 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/applications/CMakeLists.txt b/applications/CMakeLists.txt index 53f75e4..121fc8e 100644 --- a/applications/CMakeLists.txt +++ b/applications/CMakeLists.txt @@ -8,15 +8,23 @@ find_package(Gengetopt REQUIRED) if(NOT ITK_DIR) set(ITK_DIR ${ITK_BINARY_DIR}/CMakeTmp) endif() -find_package( - ITK - REQUIRED - COMPONENTS - ${ITK_MODULE_PCT_DEPENDS} - ${ITK_MODULE_PCT-Test_DEPENDS} -) -include(${ITK_USE_FILE}) +find_package(ITK REQUIRED COMPONENTS ${ITK_MODULE_PCT_DEPENDS}) +include(itkVersion) +if("${ITK_VERSION_MAJOR}" VERSION_LESS "6") + include(${ITK_USE_FILE}) + set(PCT_APPLICATION_TARGETS ${PCT_LIBRARIES}) +else() + itk_generate_factory_registration() + set( + PCT_APPLICATION_TARGETS + ITK::PCTModule + ITK::ITKImageIO + ITK::ITKFFTImageFilterInit + ) +endif() +#----------------------------------------------------------------------------- +# Executables add_subdirectory(pctbackprojectionbinning) add_subdirectory(pctbinning) add_subdirectory(pctfdk) diff --git a/applications/pctbackprojectionbinning/CMakeLists.txt b/applications/pctbackprojectionbinning/CMakeLists.txt index df15edd..f40947e 100644 --- a/applications/pctbackprojectionbinning/CMakeLists.txt +++ b/applications/pctbackprojectionbinning/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable( pctbackprojectionbinning.cxx ${pctbackprojectionbinning_GGO_C} ) -target_link_libraries(pctbackprojectionbinning PCT) +target_link_libraries(pctbackprojectionbinning ${PCT_APPLICATION_TARGETS}) # Ensure binary is placed in the central PCT binary dir set_target_properties( diff --git a/applications/pctbinning/CMakeLists.txt b/applications/pctbinning/CMakeLists.txt index 4c61ee9..3b564db 100644 --- a/applications/pctbinning/CMakeLists.txt +++ b/applications/pctbinning/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable( pctbinning.cxx ${pctbinning_GGO_C} ) -target_link_libraries(pctbinning PCT) +target_link_libraries(pctbinning ${PCT_APPLICATION_TARGETS}) # Ensure binary is placed in the central PCT binary dir set_target_properties( diff --git a/applications/pctfdk/CMakeLists.txt b/applications/pctfdk/CMakeLists.txt index 904dc0b..48c9091 100644 --- a/applications/pctfdk/CMakeLists.txt +++ b/applications/pctfdk/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable( pctfdk.cxx ${pctfdk_GGO_C} ) -target_link_libraries(pctfdk PCT) +target_link_libraries(pctfdk ${PCT_APPLICATION_TARGETS}) # Ensure binary is placed in the central PCT binary dir set_target_properties( diff --git a/applications/pctpaircuts/CMakeLists.txt b/applications/pctpaircuts/CMakeLists.txt index 0dbba6a..693fb14 100644 --- a/applications/pctpaircuts/CMakeLists.txt +++ b/applications/pctpaircuts/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable( pctpaircuts.cxx ${pctpaircuts_GGO_C} ) -target_link_libraries(pctpaircuts PCT) +target_link_libraries(pctpaircuts ${PCT_APPLICATION_TARGETS}) # Ensure binary is placed in the central PCT binary dir set_target_properties( diff --git a/applications/pctpairgeometry/CMakeLists.txt b/applications/pctpairgeometry/CMakeLists.txt index 2d31164..7f4f69e 100644 --- a/applications/pctpairgeometry/CMakeLists.txt +++ b/applications/pctpairgeometry/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable( pctpairgeometry.cxx ${pctpairgeometry_GGO_C} ) -target_link_libraries(pctpairgeometry PCT) +target_link_libraries(pctpairgeometry ${PCT_APPLICATION_TARGETS}) # Ensure binary is placed in the central PCT binary dir set_target_properties( diff --git a/applications/pctprojections/CMakeLists.txt b/applications/pctprojections/CMakeLists.txt index 5b772b9..081709e 100644 --- a/applications/pctprojections/CMakeLists.txt +++ b/applications/pctprojections/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable( pctprojections.cxx ${pctprojections_GGO_C} ) -target_link_libraries(pctprojections PCT) +target_link_libraries(pctprojections ${PCT_APPLICATION_TARGETS}) # Ensure binary is placed in the central PCT binary dir set_target_properties( diff --git a/applications/pctzengbackprojections/CMakeLists.txt b/applications/pctzengbackprojections/CMakeLists.txt index af42a28..d019416 100644 --- a/applications/pctzengbackprojections/CMakeLists.txt +++ b/applications/pctzengbackprojections/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable( pctzengbackprojections.cxx ${pctzengbackprojections_GGO_C} ) -target_link_libraries(pctzengbackprojections PCT) +target_link_libraries(pctzengbackprojections ${PCT_APPLICATION_TARGETS}) # Ensure binary is placed in the central PCT binary dir set_target_properties( From 4e9ab11b7135e37d53ae4055febca419749e472b Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Thu, 7 May 2026 20:08:25 +0100 Subject: [PATCH 2/4] STYLE: Replace itkTypeMacro by itkOverrideGetNameOfClassMacro Missing in pct::HoleFillingImageFilter, the rest was done in 916f070c48008daf0516ea371f8dccb6c791129b --- include/pctHoleFillingImageFilter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pctHoleFillingImageFilter.h b/include/pctHoleFillingImageFilter.h index 5f4cf4a..6217d79 100644 --- a/include/pctHoleFillingImageFilter.h +++ b/include/pctHoleFillingImageFilter.h @@ -30,7 +30,7 @@ class HoleFillingImageFilter : public itk::ImageToImageFilter; itkNewMacro(Self); - itkTypeMacro(HoleFillingImageFilter, ImageToImageFilter); + itkOverrideGetNameOfClassMacro(HoleFillingImageFilter); using InputImageType = TInputImage; using OutputImageType = TOutputImage; From 8040eb430930f71e4cdd36ec621be15261324096 Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Thu, 7 May 2026 20:49:13 +0100 Subject: [PATCH 3/4] PERF: Use IteratorWithIndex to compute pixel indices incrementally This commit follows InsightSoftwareConsortium/ITK#5803 --- include/pctDDParkerShortScanImageFilter.hxx | 4 ++-- include/pctProtonPairsToBackProjection.hxx | 4 ++-- include/pctProtonPairsToDistanceDrivenProjection.hxx | 8 ++++---- test/pctHoleFillingImageFilterTest.cxx | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/pctDDParkerShortScanImageFilter.hxx b/include/pctDDParkerShortScanImageFilter.hxx index 360fbc4..c521ff5 100644 --- a/include/pctDDParkerShortScanImageFilter.hxx +++ b/include/pctDDParkerShortScanImageFilter.hxx @@ -21,8 +21,8 @@ DDParkerShortScanImageFilter::DynamicThreadedGenerate maxAngularGapPos = iProj; // Input / ouput iterators - itk::ImageRegionConstIterator itIn(this->GetInput(), outputRegionForThread); - itk::ImageRegionIterator itOut(this->GetOutput(), outputRegionForThread); + itk::ImageRegionConstIteratorWithIndex itIn(this->GetInput(), outputRegionForThread); + itk::ImageRegionIteratorWithIndex itOut(this->GetOutput(), outputRegionForThread); itIn.GoToBegin(); itOut.GoToBegin(); diff --git a/include/pctProtonPairsToBackProjection.hxx b/include/pctProtonPairsToBackProjection.hxx index b42812d..0aa3074 100644 --- a/include/pctProtonPairsToBackProjection.hxx +++ b/include/pctProtonPairsToBackProjection.hxx @@ -1,5 +1,5 @@ #include -#include +#include #include @@ -155,7 +155,7 @@ ProtonPairsToBackProjection::GenerateData() zmm.push_back(zmm.back() + minSpacing); // Process pairs - itk::ImageRegionIterator it(m_ProtonPairs, outputRegionForThread); + itk::ImageRegionIteratorWithIndex it(m_ProtonPairs, outputRegionForThread); while (!it.IsAtEnd()) { if (outputRegionForThread.GetIndex(1) == 0 && it.GetIndex()[1] % 1000 == 0) diff --git a/include/pctProtonPairsToDistanceDrivenProjection.hxx b/include/pctProtonPairsToDistanceDrivenProjection.hxx index 32c461e..b134124 100644 --- a/include/pctProtonPairsToDistanceDrivenProjection.hxx +++ b/include/pctProtonPairsToDistanceDrivenProjection.hxx @@ -1,5 +1,5 @@ #include -#include +#include #include "pctThirdOrderPolynomialMLPFunction.h" #include "pctSchulteMLPFunction.h" @@ -169,9 +169,9 @@ ProtonPairsToDistanceDrivenProjection::ThreadedGenera using VectorType = itk::Vector; // Create zmm and magnitude lut (look up table) - itk::ImageRegionIterator it(m_ProtonPairs, region); - std::vector zmm(imgSize[2]); - std::vector zmag(imgSize[2]); + itk::ImageRegionIteratorWithIndex it(m_ProtonPairs, region); + std::vector zmm(imgSize[2]); + std::vector zmag(imgSize[2]); ++it; const double zPlaneOutInMM = it.Get()[2]; --it; diff --git a/test/pctHoleFillingImageFilterTest.cxx b/test/pctHoleFillingImageFilterTest.cxx index 25d706f..43cf425 100644 --- a/test/pctHoleFillingImageFilterTest.cxx +++ b/test/pctHoleFillingImageFilterTest.cxx @@ -1,7 +1,7 @@ #include "pctHoleFillingImageFilter.h" #include "itkImage.h" -#include "itkImageRegionIterator.h" +#include "itkImageRegionIteratorWithIndex.h" #include "itkTestingMacros.h" int @@ -19,7 +19,7 @@ pctHoleFillingImageFilterTest(int argc, char * argv[]) img->FillBuffer(42); // Insert some holes (use 0 as hole value) - itk::ImageRegionIterator it(img, region); + itk::ImageRegionIteratorWithIndex it(img, region); for (it.GoToBegin(); !it.IsAtEnd(); ++it) { ImageType::IndexType idx = it.GetIndex(); From fcddc7494b45c1faacaa24299615f235b290675b Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Thu, 7 May 2026 20:52:12 +0100 Subject: [PATCH 4/4] COMP: Define PointType according to rtk::QuadricShape definition The definition changed with RTKConsortium/RTK#841 --- include/pctEnergyAdaptiveMLPFunction.h | 5 +++-- include/pctMostLikelyPathFunction.h | 14 +++++++++----- include/pctPolynomialMLPFunction.h | 3 ++- include/pctProtonPairsToBackProjection.hxx | 10 +++++----- .../pctProtonPairsToDistanceDrivenProjection.hxx | 14 +++++++------- include/pctSchulteMLPFunction.h | 7 ++++--- include/pctThirdOrderPolynomialMLPFunction.h | 3 ++- include/pctThirdOrderPolynomialMLPFunction.hxx | 4 ++-- src/pctEnergyAdaptiveMLPFunction.cxx | 4 ++-- src/pctPolynomialMLPFunction.cxx | 4 ++-- src/pctSchulteMLPFunction.cxx | 8 ++++---- 11 files changed, 42 insertions(+), 34 deletions(-) diff --git a/include/pctEnergyAdaptiveMLPFunction.h b/include/pctEnergyAdaptiveMLPFunction.h index 173ac7c..022d661 100644 --- a/include/pctEnergyAdaptiveMLPFunction.h +++ b/include/pctEnergyAdaptiveMLPFunction.h @@ -113,12 +113,13 @@ class PCT_EXPORT EnergyAdaptiveMLPFunction : public MostLikelyPathFunction #endif +#include + namespace pct { @@ -29,19 +31,21 @@ class ITK_TEMPLATE_EXPORT MostLikelyPathFunction : public itk::LightObject using ConstPointer = itk::SmartPointer; /** Useful defines. */ + // PointType definition based on rtk::QuadricShape to be compatible with RTK 2 and 3 + using PointType = rtk::QuadricShape::PointType; using VectorType = itk::Vector; /** Init the mlp parameters from the input and output directions and positions. */ virtual void - Init(const VectorType posIn, const VectorType posOut, const VectorType dirIn, const VectorType dirOut) + Init(const PointType posIn, const PointType posOut, const VectorType dirIn, const VectorType dirOut) { itkGenericExceptionMacro("This version of the Init method not implemented for derived class."); } /** Init the mlp parameters from the input and output directions and positions, and energies. */ virtual void - Init(const VectorType posIn, - const VectorType posOut, + Init(const PointType posIn, + const PointType posOut, const VectorType dirIn, const VectorType dirOut, double eIn, @@ -52,8 +56,8 @@ class ITK_TEMPLATE_EXPORT MostLikelyPathFunction : public itk::LightObject /** Init with additional parameters to consider tracker uncertainties */ virtual void - InitUncertain(const VectorType posIn, - const VectorType posOut, + InitUncertain(const PointType posIn, + const PointType posOut, const VectorType dirIn, const VectorType dirOut, double dEntry, diff --git a/include/pctPolynomialMLPFunction.h b/include/pctPolynomialMLPFunction.h index 8b554f1..63ca5f2 100644 --- a/include/pctPolynomialMLPFunction.h +++ b/include/pctPolynomialMLPFunction.h @@ -149,11 +149,12 @@ class PCT_EXPORT PolynomialMLPFunction : public MostLikelyPathFunction itkNewMacro(Self); /** Useful defines. */ + using PointType = Superclass::PointType; using VectorType = Superclass::VectorType; /** Init the mlp parameters from the input and output directions and positions. */ virtual void - Init(const VectorType posIn, const VectorType posOut, const VectorType dirIn, const VectorType dirOut) override; + Init(const PointType posIn, const PointType posOut, const VectorType dirIn, const VectorType dirOut) override; /* Vectorised version of Evaluate function. */ virtual void diff --git a/include/pctProtonPairsToBackProjection.hxx b/include/pctProtonPairsToBackProjection.hxx index 0aa3074..31befb6 100644 --- a/include/pctProtonPairsToBackProjection.hxx +++ b/include/pctProtonPairsToBackProjection.hxx @@ -165,9 +165,9 @@ ProtonPairsToBackProjection::GenerateData() << 100 * it.GetIndex()[1] / outputRegionForThread.GetSize(1) << "%) in thread 1" << std::flush; } - VectorType pIn = it.Get(); + RQIType::PointType pIn(it.Get()); ++it; - VectorType pOut = it.Get(); + RQIType::PointType pOut(it.Get()); ++it; VectorType dIn = it.Get(); ++it; @@ -185,9 +185,9 @@ ProtonPairsToBackProjection::GenerateData() ++it; // Move straight to entrance and exit shapes - VectorType pSIn = pIn; - VectorType pSOut = pOut; - double nearDistIn, nearDistOut, farDistIn, farDistOut; + RQIType::PointType pSIn = pIn; + RQIType::PointType pSOut = pOut; + double nearDistIn, nearDistOut, farDistIn, farDistOut; if (m_QuadricIn.GetPointer() != NULL) { if (m_QuadricIn->IsIntersectedByRay(pIn, dIn, nearDistIn, farDistIn) && diff --git a/include/pctProtonPairsToDistanceDrivenProjection.hxx b/include/pctProtonPairsToDistanceDrivenProjection.hxx index b134124..472fd21 100644 --- a/include/pctProtonPairsToDistanceDrivenProjection.hxx +++ b/include/pctProtonPairsToDistanceDrivenProjection.hxx @@ -190,9 +190,9 @@ ProtonPairsToDistanceDrivenProjection::ThreadedGenera << 100 * it.GetIndex()[1] / region.GetSize(1) << "%) in thread 1" << std::flush; } - VectorType pIn = it.Get(); + RQIType::PointType pIn(it.Get()); ++it; - VectorType pOut = it.Get(); + RQIType::PointType pOut(it.Get()); ++it; VectorType dIn = it.Get(); ++it; @@ -257,11 +257,11 @@ ProtonPairsToDistanceDrivenProjection::ThreadedGenera // Move straight to entrance and exit shapes - VectorType pSIn = pIn; - VectorType pSOut = pOut; - double nearDistIn, nearDistOut, farDistIn, farDistOut; - double distanceEntry, distanceExit; - bool QuadricIntersected = false; + RQIType::PointType pSIn = pIn; + RQIType::PointType pSOut = pOut; + double nearDistIn, nearDistOut, farDistIn, farDistOut; + double distanceEntry, distanceExit; + bool QuadricIntersected = false; if (m_QuadricIn.GetPointer() != NULL) { if (m_QuadricIn->IsIntersectedByRay(pIn, dIn, nearDistIn, farDistIn) && diff --git a/include/pctSchulteMLPFunction.h b/include/pctSchulteMLPFunction.h index d5d153e..93cf6f2 100644 --- a/include/pctSchulteMLPFunction.h +++ b/include/pctSchulteMLPFunction.h @@ -150,16 +150,17 @@ class PCT_EXPORT SchulteMLPFunction : public MostLikelyPathFunction itkNewMacro(Self); /** Useful defines. */ + using PointType = Superclass::PointType; using VectorType = Superclass::VectorType; /** Init the mlp parameters from the input and output directions and positions. */ virtual void - Init(const VectorType posIn, const VectorType posOut, const VectorType dirIn, const VectorType dirOut) override; + Init(const PointType posIn, const PointType posOut, const VectorType dirIn, const VectorType dirOut) override; /** Init with additional parameters to consider tracker uncertainties */ virtual void - InitUncertain(const VectorType posIn, - const VectorType posOut, + InitUncertain(const PointType posIn, + const PointType posOut, const VectorType dirIn, const VectorType dirOut, double dEntry, diff --git a/include/pctThirdOrderPolynomialMLPFunction.h b/include/pctThirdOrderPolynomialMLPFunction.h index f7e78a3..ef3817e 100644 --- a/include/pctThirdOrderPolynomialMLPFunction.h +++ b/include/pctThirdOrderPolynomialMLPFunction.h @@ -25,11 +25,12 @@ class ITK_TEMPLATE_EXPORT ThirdOrderPolynomialMLPFunction : public MostLikelyPat itkNewMacro(Self); /** Useful defines. */ + using PointType = typename Superclass::PointType; using VectorType = typename Superclass::VectorType; /** Init the mlp parameters from the input and output directions and positions. */ virtual void - Init(const VectorType posIn, const VectorType posOut, const VectorType dirIn, const VectorType dirOut) override; + Init(const PointType posIn, const PointType posOut, const VectorType dirIn, const VectorType dirOut) override; /** Evaluate the coordinates (x,y) at depth z. */ virtual void diff --git a/include/pctThirdOrderPolynomialMLPFunction.hxx b/include/pctThirdOrderPolynomialMLPFunction.hxx index 7f29735..c1d0743 100644 --- a/include/pctThirdOrderPolynomialMLPFunction.hxx +++ b/include/pctThirdOrderPolynomialMLPFunction.hxx @@ -3,8 +3,8 @@ namespace pct template void -ThirdOrderPolynomialMLPFunction::Init(const VectorType posIn, - const VectorType posOut, +ThirdOrderPolynomialMLPFunction::Init(const PointType posIn, + const PointType posOut, const VectorType dirIn, const VectorType dirOut) { diff --git a/src/pctEnergyAdaptiveMLPFunction.cxx b/src/pctEnergyAdaptiveMLPFunction.cxx index 89146d7..55f1da0 100644 --- a/src/pctEnergyAdaptiveMLPFunction.cxx +++ b/src/pctEnergyAdaptiveMLPFunction.cxx @@ -29,8 +29,8 @@ EnergyAdaptiveMLPFunction ::EnergyAdaptiveMLPFunction() } void -EnergyAdaptiveMLPFunction ::Init(const VectorType posIn, - const VectorType posOut, +EnergyAdaptiveMLPFunction ::Init(const PointType posIn, + const PointType posOut, const VectorType dirIn, const VectorType dirOut, double eIn, diff --git a/src/pctPolynomialMLPFunction.cxx b/src/pctPolynomialMLPFunction.cxx index 05b0436..67ed049 100644 --- a/src/pctPolynomialMLPFunction.cxx +++ b/src/pctPolynomialMLPFunction.cxx @@ -76,8 +76,8 @@ PolynomialMLPFunction ::SetPolynomialDegree(const int polydeg) } void -PolynomialMLPFunction ::Init(const VectorType posIn, - const VectorType posOut, +PolynomialMLPFunction ::Init(const PointType posIn, + const PointType posOut, const VectorType dirIn, const VectorType dirOut) { diff --git a/src/pctSchulteMLPFunction.cxx b/src/pctSchulteMLPFunction.cxx index 6f8e8d4..7522d7f 100644 --- a/src/pctSchulteMLPFunction.cxx +++ b/src/pctSchulteMLPFunction.cxx @@ -46,8 +46,8 @@ SchulteMLPFunction ::SchulteMLPFunction() // Initialize terms needed to include tracker uncertainties void -SchulteMLPFunction ::InitUncertain(const VectorType posIn, - const VectorType posOut, +SchulteMLPFunction ::InitUncertain(const PointType posIn, + const PointType posOut, const VectorType dirIn, const VectorType dirOut, double dEntry, @@ -97,8 +97,8 @@ SchulteMLPFunction ::InitUncertain(const VectorType posIn, // standard part of the Initialization void -SchulteMLPFunction ::Init(const VectorType posIn, - const VectorType posOut, +SchulteMLPFunction ::Init(const PointType posIn, + const PointType posOut, const VectorType dirIn, const VectorType dirOut) {