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( 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/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; itkNewMacro(Self); - itkTypeMacro(HoleFillingImageFilter, ImageToImageFilter); + itkOverrideGetNameOfClassMacro(HoleFillingImageFilter); using InputImageType = TInputImage; using OutputImageType = TOutputImage; diff --git a/include/pctMostLikelyPathFunction.h b/include/pctMostLikelyPathFunction.h index 7d56e15..90db6f9 100644 --- a/include/pctMostLikelyPathFunction.h +++ b/include/pctMostLikelyPathFunction.h @@ -10,6 +10,8 @@ # include #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 b42812d..31befb6 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) @@ -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 32c461e..472fd21 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; @@ -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) { 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();