From cee3df58cebb180df28b71c7ead1792398eab31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=9Clgen?= Date: Fri, 23 Feb 2024 11:34:14 +0000 Subject: [PATCH] Rename Measure as MeasureCreator --- niftyreg_build_version.txt | 2 +- reg-lib/CMakeLists.txt | 2 +- reg-lib/{Measure.cpp => MeasureCreator.cpp} | 6 ++-- reg-lib/{Measure.h => MeasureCreator.hpp} | 2 +- reg-lib/MeasureCreatorFactory.hpp | 8 +++++ reg-lib/MeasureFactory.h | 8 ----- reg-lib/Platform.cpp | 12 +++---- reg-lib/Platform.h | 8 ++--- reg-lib/_reg_base.cpp | 36 +++++++++---------- reg-lib/_reg_base.h | 4 +-- reg-lib/_reg_f3d2.cpp | 14 ++++---- reg-lib/cuda/CMakeLists.txt | 2 +- ...CudaMeasure.cpp => CudaMeasureCreator.cpp} | 6 ++-- .../{CudaMeasure.h => CudaMeasureCreator.hpp} | 4 +-- reg-lib/cuda/CudaMeasureCreatorFactory.hpp | 8 +++++ reg-lib/cuda/CudaMeasureFactory.h | 8 ----- reg-test/reg_test_lncc.cpp | 8 ++--- reg-test/reg_test_nmi.cpp | 8 ++--- reg-test/reg_test_nmi_gradient.cpp | 8 ++--- reg-test/reg_test_regr_measure.cpp | 6 ++-- 20 files changed, 80 insertions(+), 80 deletions(-) rename reg-lib/{Measure.cpp => MeasureCreator.cpp} (89%) rename reg-lib/{Measure.h => MeasureCreator.hpp} (93%) create mode 100644 reg-lib/MeasureCreatorFactory.hpp delete mode 100644 reg-lib/MeasureFactory.h rename reg-lib/cuda/{CudaMeasure.cpp => CudaMeasureCreator.cpp} (93%) rename reg-lib/cuda/{CudaMeasure.h => CudaMeasureCreator.hpp} (71%) create mode 100644 reg-lib/cuda/CudaMeasureCreatorFactory.hpp delete mode 100644 reg-lib/cuda/CudaMeasureFactory.h diff --git a/niftyreg_build_version.txt b/niftyreg_build_version.txt index 53c86ff4..29aae8ee 100644 --- a/niftyreg_build_version.txt +++ b/niftyreg_build_version.txt @@ -1 +1 @@ -417 +418 diff --git a/reg-lib/CMakeLists.txt b/reg-lib/CMakeLists.txt index e319f92a..ac7a34b1 100755 --- a/reg-lib/CMakeLists.txt +++ b/reg-lib/CMakeLists.txt @@ -103,7 +103,7 @@ add_library(_reg_compute ${NIFTYREG_LIBRARY_TYPE} F3dContent.cpp Optimiser.cpp Platform.cpp - Measure.cpp + MeasureCreator.cpp ) target_link_libraries(_reg_compute _reg_measure) install(TARGETS _reg_compute diff --git a/reg-lib/Measure.cpp b/reg-lib/MeasureCreator.cpp similarity index 89% rename from reg-lib/Measure.cpp rename to reg-lib/MeasureCreator.cpp index bd586b8b..6ff56f71 100644 --- a/reg-lib/Measure.cpp +++ b/reg-lib/MeasureCreator.cpp @@ -1,4 +1,4 @@ -#include "Measure.h" +#include "MeasureCreator.hpp" #include "_reg_nmi.h" #include "_reg_ssd.h" #include "_reg_dti.h" @@ -7,7 +7,7 @@ #include "_reg_mind.h" /* *************************************************************** */ -reg_measure* Measure::Create(const MeasureType measureType) { +reg_measure* MeasureCreator::Create(const MeasureType measureType) { switch (measureType) { case MeasureType::Nmi: return new reg_nmi(); @@ -29,7 +29,7 @@ reg_measure* Measure::Create(const MeasureType measureType) { } } /* *************************************************************** */ -void Measure::Initialise(reg_measure& measure, DefContent& con, DefContent *conBw) { +void MeasureCreator::Initialise(reg_measure& measure, DefContent& con, DefContent *conBw) { measure.InitialiseMeasure(con.GetReference(), con.GetFloating(), con.GetReferenceMask(), diff --git a/reg-lib/Measure.h b/reg-lib/MeasureCreator.hpp similarity index 93% rename from reg-lib/Measure.h rename to reg-lib/MeasureCreator.hpp index c20989d7..c0dfde67 100644 --- a/reg-lib/Measure.h +++ b/reg-lib/MeasureCreator.hpp @@ -5,7 +5,7 @@ enum class MeasureType { Nmi, Ssd, Dti, Lncc, Kld, Mind, MindSsc }; -class Measure { +class MeasureCreator { public: virtual reg_measure* Create(const MeasureType measureType); virtual void Initialise(reg_measure& measure, DefContent& con, DefContent *conBw = nullptr); diff --git a/reg-lib/MeasureCreatorFactory.hpp b/reg-lib/MeasureCreatorFactory.hpp new file mode 100644 index 00000000..d51b6db1 --- /dev/null +++ b/reg-lib/MeasureCreatorFactory.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include "MeasureCreator.hpp" + +class MeasureCreatorFactory { +public: + virtual MeasureCreator* Produce() { return new MeasureCreator(); } +}; diff --git a/reg-lib/MeasureFactory.h b/reg-lib/MeasureFactory.h deleted file mode 100644 index 9c1927a9..00000000 --- a/reg-lib/MeasureFactory.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "Measure.h" - -class MeasureFactory { -public: - virtual Measure* Produce() { return new Measure(); } -}; diff --git a/reg-lib/Platform.cpp b/reg-lib/Platform.cpp index e9b6d4ed..482089fa 100755 --- a/reg-lib/Platform.cpp +++ b/reg-lib/Platform.cpp @@ -6,7 +6,7 @@ #include "CudaComputeFactory.h" #include "CudaContentCreatorFactory.h" #include "CudaKernelFactory.h" -#include "CudaMeasureFactory.h" +#include "CudaMeasureCreatorFactory.hpp" #include "CudaOptimiser.hpp" #endif #ifdef USE_OPENCL @@ -24,7 +24,7 @@ Platform::Platform(const PlatformType platformTypeIn) { computeFactory = new ComputeFactory(); contentCreatorFactory = new ContentCreatorFactory(); kernelFactory = new CpuKernelFactory(); - measureFactory = new MeasureFactory(); + measureCreatorFactory = new MeasureCreatorFactory(); } #ifdef USE_CUDA else if (platformType == PlatformType::Cuda) { @@ -33,7 +33,7 @@ Platform::Platform(const PlatformType platformTypeIn) { computeFactory = new CudaComputeFactory(); contentCreatorFactory = new CudaContentCreatorFactory(); kernelFactory = new CudaKernelFactory(); - measureFactory = new CudaMeasureFactory(); + measureCreatorFactory = new CudaMeasureCreatorFactory(); } #endif #ifdef USE_OPENCL @@ -52,7 +52,7 @@ Platform::~Platform() { delete computeFactory; delete contentCreatorFactory; delete kernelFactory; - delete measureFactory; + delete measureCreatorFactory; } /* *************************************************************** */ std::string Platform::GetName() const { @@ -104,8 +104,8 @@ Kernel* Platform::CreateKernel(const std::string& name, Content *con) const { return kernelFactory->Produce(name, con); } /* *************************************************************** */ -Measure* Platform::CreateMeasure() const { - return measureFactory->Produce(); +MeasureCreator* Platform::CreateMeasureCreator() const { + return measureCreatorFactory->Produce(); } /* *************************************************************** */ template diff --git a/reg-lib/Platform.h b/reg-lib/Platform.h index ee82a04e..9e2ca5ad 100755 --- a/reg-lib/Platform.h +++ b/reg-lib/Platform.h @@ -4,7 +4,7 @@ #include "ComputeFactory.h" #include "ContentCreatorFactory.h" #include "KernelFactory.h" -#include "MeasureFactory.h" +#include "MeasureCreatorFactory.hpp" #include "Optimiser.hpp" enum class PlatformType { Cpu, Cuda, OpenCl }; @@ -34,7 +34,7 @@ class Platform { Compute* CreateCompute(Content& con) const; ContentCreator* CreateContentCreator(const ContentType conType = ContentType::Base) const; Kernel* CreateKernel(const std::string& name, Content *con) const; - Measure* CreateMeasure() const; + MeasureCreator* CreateMeasureCreator() const; template Optimiser* CreateOptimiser(F3dContent& con, InterfaceOptimiser& opt, @@ -62,8 +62,8 @@ class Platform { ComputeFactory *computeFactory = nullptr; ContentCreatorFactory *contentCreatorFactory = nullptr; KernelFactory *kernelFactory = nullptr; - MeasureFactory *measureFactory = nullptr; + MeasureCreatorFactory *measureCreatorFactory = nullptr; std::string platformName; PlatformType platformType; - unsigned gpuIdx; + unsigned gpuIdx = 0; }; diff --git a/reg-lib/_reg_base.cpp b/reg-lib/_reg_base.cpp index 2190241f..cc5e8be5 100644 --- a/reg-lib/_reg_base.cpp +++ b/reg-lib/_reg_base.cpp @@ -267,7 +267,7 @@ void reg_base::CheckParameters() { // Set the default similarity measure if none has been set if (!measure_nmi && !measure_ssd && !measure_dti && !measure_lncc && !measure_kld && !measure_mind && !measure_mindssc) { - measure_nmi.reset(dynamic_cast(measure->Create(MeasureType::Nmi))); + measure_nmi.reset(dynamic_cast(measureCreator->Create(MeasureType::Nmi))); for (int i = 0; i < inputReference->nt; ++i) measure_nmi->SetTimePointWeight(i, 1.0); } @@ -360,25 +360,25 @@ void reg_base::InitialiseSimilarity() { DefContent& con = dynamic_cast(*this->con); if (measure_nmi) - measure->Initialise(*measure_nmi, con); + measureCreator->Initialise(*measure_nmi, con); if (measure_ssd) - measure->Initialise(*measure_ssd, con); + measureCreator->Initialise(*measure_ssd, con); if (measure_kld) - measure->Initialise(*measure_kld, con); + measureCreator->Initialise(*measure_kld, con); if (measure_lncc) - measure->Initialise(*measure_lncc, con); + measureCreator->Initialise(*measure_lncc, con); if (measure_dti) - measure->Initialise(*measure_dti, con); + measureCreator->Initialise(*measure_dti, con); if (measure_mind) - measure->Initialise(*measure_mind, con); + measureCreator->Initialise(*measure_mind, con); if (measure_mindssc) - measure->Initialise(*measure_mindssc, con); + measureCreator->Initialise(*measure_mindssc, con); NR_FUNC_CALLED(); } @@ -551,7 +551,7 @@ void reg_base::GetVoxelBasedGradient() { //void reg_base::ApproximateParzenWindow() //{ // if(!measure_nmi) -// measure_nmi.reset(dynamic_cast(measure->Create(MeasureType::Nmi))); +// measure_nmi.reset(dynamic_cast(measureCreator->Create(MeasureType::Nmi))); // measure_nmi=approxParzenWindow = true; //} ///* *************************************************************** */ @@ -559,14 +559,14 @@ void reg_base::GetVoxelBasedGradient() { //void reg_base::DoNotApproximateParzenWindow() //{ // if(!measure_nmi) -// measure_nmi.reset(dynamic_cast(measure->Create(MeasureType::Nmi))); +// measure_nmi.reset(dynamic_cast(measureCreator->Create(MeasureType::Nmi))); // measure_nmi=approxParzenWindow = false; //} /* *************************************************************** */ template void reg_base::UseNMISetReferenceBinNumber(int timePoint, int refBinNumber) { if (!measure_nmi) - measure_nmi.reset(dynamic_cast(measure->Create(MeasureType::Nmi))); + measure_nmi.reset(dynamic_cast(measureCreator->Create(MeasureType::Nmi))); measure_nmi->SetTimePointWeight(timePoint, 1.0);//weight initially set to default value of 1.0 // I am here adding 4 to the specified bin number to accommodate for // the spline support @@ -577,7 +577,7 @@ void reg_base::UseNMISetReferenceBinNumber(int timePoint, int refBinNumber) { template void reg_base::UseNMISetFloatingBinNumber(int timePoint, int floBinNumber) { if (!measure_nmi) - measure_nmi.reset(dynamic_cast(measure->Create(MeasureType::Nmi))); + measure_nmi.reset(dynamic_cast(measureCreator->Create(MeasureType::Nmi))); measure_nmi->SetTimePointWeight(timePoint, 1.0);//weight initially set to default value of 1.0 // I am here adding 4 to the specified bin number to accommodate for // the spline support @@ -588,7 +588,7 @@ void reg_base::UseNMISetFloatingBinNumber(int timePoint, int floBinNumber) { template void reg_base::UseSSD(int timePoint, bool normalise) { if (!measure_ssd) - measure_ssd.reset(dynamic_cast(measure->Create(MeasureType::Ssd))); + measure_ssd.reset(dynamic_cast(measureCreator->Create(MeasureType::Ssd))); measure_ssd->SetTimePointWeight(timePoint, 1.0);//weight initially set to default value of 1.0 measure_ssd->SetNormaliseTimePoint(timePoint, normalise); NR_FUNC_CALLED(); @@ -597,7 +597,7 @@ void reg_base::UseSSD(int timePoint, bool normalise) { template void reg_base::UseMIND(int timePoint, int offset) { if (!measure_mind) - measure_mind.reset(dynamic_cast(measure->Create(MeasureType::Mind))); + measure_mind.reset(dynamic_cast(measureCreator->Create(MeasureType::Mind))); measure_mind->SetTimePointWeight(timePoint, 1.0);//weight set to 1.0 to indicate time point is active measure_mind->SetDescriptorOffset(offset); NR_FUNC_CALLED(); @@ -606,7 +606,7 @@ void reg_base::UseMIND(int timePoint, int offset) { template void reg_base::UseMINDSSC(int timePoint, int offset) { if (!measure_mindssc) - measure_mindssc.reset(dynamic_cast(measure->Create(MeasureType::MindSsc))); + measure_mindssc.reset(dynamic_cast(measureCreator->Create(MeasureType::MindSsc))); measure_mindssc->SetTimePointWeight(timePoint, 1.0);//weight set to 1.0 to indicate time point is active measure_mindssc->SetDescriptorOffset(offset); NR_FUNC_CALLED(); @@ -615,7 +615,7 @@ void reg_base::UseMINDSSC(int timePoint, int offset) { template void reg_base::UseKLDivergence(int timePoint) { if (!measure_kld) - measure_kld.reset(dynamic_cast(measure->Create(MeasureType::Kld))); + measure_kld.reset(dynamic_cast(measureCreator->Create(MeasureType::Kld))); measure_kld->SetTimePointWeight(timePoint, 1.0);//weight initially set to default value of 1.0 NR_FUNC_CALLED(); } @@ -623,7 +623,7 @@ void reg_base::UseKLDivergence(int timePoint) { template void reg_base::UseLNCC(int timePoint, float stddev) { if (!measure_lncc) - measure_lncc.reset(dynamic_cast(measure->Create(MeasureType::Lncc))); + measure_lncc.reset(dynamic_cast(measureCreator->Create(MeasureType::Lncc))); measure_lncc->SetKernelStandardDeviation(timePoint, stddev); measure_lncc->SetTimePointWeight(timePoint, 1.0); // weight initially set to default value of 1.0 NR_FUNC_CALLED(); @@ -642,7 +642,7 @@ void reg_base::UseDTI(bool *timePoint) { NR_FATAL_ERROR("The use of DTI has been deactivated as it requires some refactoring"); if (!measure_dti) - measure_dti.reset(dynamic_cast(measure->Create(MeasureType::Dti))); + measure_dti.reset(dynamic_cast(measureCreator->Create(MeasureType::Dti))); for (int i = 0; i < inputReference->nt; ++i) { if (timePoint[i]) measure_dti->SetTimePointWeight(i, 1.0); // weight set to 1.0 to indicate time point is active diff --git a/reg-lib/_reg_base.h b/reg-lib/_reg_base.h index 3b4b91c3..26995020 100644 --- a/reg-lib/_reg_base.h +++ b/reg-lib/_reg_base.h @@ -42,7 +42,7 @@ class reg_base: public InterfaceOptimiser { unique_ptr compute; // Measure - unique_ptr measure; + unique_ptr measureCreator; // Optimiser-related variables unique_ptr> optimiser; @@ -143,7 +143,7 @@ class reg_base: public InterfaceOptimiser { // Platform virtual void SetPlatformType(const PlatformType platformType) { platform.reset(new Platform(platformType)); - measure.reset(platform->CreateMeasure()); + measureCreator.reset(platform->CreateMeasureCreator()); } virtual void SetGpuIdx(const unsigned gpuIdx) { platform->SetGpuIdx(gpuIdx); } diff --git a/reg-lib/_reg_f3d2.cpp b/reg-lib/_reg_f3d2.cpp index c994a471..eaa7a6f0 100644 --- a/reg-lib/_reg_f3d2.cpp +++ b/reg-lib/_reg_f3d2.cpp @@ -489,25 +489,25 @@ void reg_f3d2::InitialiseSimilarity() { F3dContent& con = dynamic_cast(*this->con); if (this->measure_nmi) - this->measure->Initialise(*this->measure_nmi, con, conBw.get()); + this->measureCreator->Initialise(*this->measure_nmi, con, conBw.get()); if (this->measure_ssd) - this->measure->Initialise(*this->measure_ssd, con, conBw.get()); + this->measureCreator->Initialise(*this->measure_ssd, con, conBw.get()); if (this->measure_kld) - this->measure->Initialise(*this->measure_kld, con, conBw.get()); + this->measureCreator->Initialise(*this->measure_kld, con, conBw.get()); if (this->measure_lncc) - this->measure->Initialise(*this->measure_lncc, con, conBw.get()); + this->measureCreator->Initialise(*this->measure_lncc, con, conBw.get()); if (this->measure_dti) - this->measure->Initialise(*this->measure_dti, con, conBw.get()); + this->measureCreator->Initialise(*this->measure_dti, con, conBw.get()); if (this->measure_mind) - this->measure->Initialise(*this->measure_mind, con, conBw.get()); + this->measureCreator->Initialise(*this->measure_mind, con, conBw.get()); if (this->measure_mindssc) - this->measure->Initialise(*this->measure_mindssc, con, conBw.get()); + this->measureCreator->Initialise(*this->measure_mindssc, con, conBw.get()); NR_FUNC_CALLED(); } diff --git a/reg-lib/cuda/CMakeLists.txt b/reg-lib/cuda/CMakeLists.txt index 9685b0b6..ad3e7c46 100755 --- a/reg-lib/cuda/CMakeLists.txt +++ b/reg-lib/cuda/CMakeLists.txt @@ -76,7 +76,7 @@ add_library(${NAME} ${NIFTYREG_LIBRARY_TYPE} CudaKernelFactory.cpp CudaLocalTransformation.cu CudaLtsKernel.cpp - CudaMeasure.cpp + CudaMeasureCreator.cpp CudaNormaliseGradient.cu CudaOptimiser.cu CudaResampleImageKernel.cpp diff --git a/reg-lib/cuda/CudaMeasure.cpp b/reg-lib/cuda/CudaMeasureCreator.cpp similarity index 93% rename from reg-lib/cuda/CudaMeasure.cpp rename to reg-lib/cuda/CudaMeasureCreator.cpp index 793aa61a..3795297d 100644 --- a/reg-lib/cuda/CudaMeasure.cpp +++ b/reg-lib/cuda/CudaMeasureCreator.cpp @@ -1,10 +1,10 @@ -#include "CudaMeasure.h" +#include "CudaMeasureCreator.hpp" #include "CudaDefContent.h" #include "_reg_nmi_gpu.h" #include "_reg_ssd_gpu.h" /* *************************************************************** */ -reg_measure* CudaMeasure::Create(const MeasureType measureType) { +reg_measure* CudaMeasureCreator::Create(const MeasureType measureType) { switch (measureType) { case MeasureType::Nmi: return new reg_nmi_gpu(); @@ -26,7 +26,7 @@ reg_measure* CudaMeasure::Create(const MeasureType measureType) { } } /* *************************************************************** */ -void CudaMeasure::Initialise(reg_measure& measure, DefContent& con, DefContent *conBw) { +void CudaMeasureCreator::Initialise(reg_measure& measure, DefContent& con, DefContent *conBw) { reg_measure_gpu& measureGpu = dynamic_cast(measure); CudaDefContent& cudaCon = dynamic_cast(con); CudaDefContent *cudaConBw = dynamic_cast(conBw); diff --git a/reg-lib/cuda/CudaMeasure.h b/reg-lib/cuda/CudaMeasureCreator.hpp similarity index 71% rename from reg-lib/cuda/CudaMeasure.h rename to reg-lib/cuda/CudaMeasureCreator.hpp index 76f73900..368914ef 100644 --- a/reg-lib/cuda/CudaMeasure.h +++ b/reg-lib/cuda/CudaMeasureCreator.hpp @@ -1,8 +1,8 @@ #pragma once -#include "Measure.h" +#include "MeasureCreator.hpp" -class CudaMeasure: public Measure { +class CudaMeasureCreator: public MeasureCreator { public: virtual reg_measure* Create(const MeasureType measureType) override; virtual void Initialise(reg_measure& measure, DefContent& con, DefContent *conBw = nullptr) override; diff --git a/reg-lib/cuda/CudaMeasureCreatorFactory.hpp b/reg-lib/cuda/CudaMeasureCreatorFactory.hpp new file mode 100644 index 00000000..d971855b --- /dev/null +++ b/reg-lib/cuda/CudaMeasureCreatorFactory.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include "CudaMeasureCreator.hpp" + +class CudaMeasureCreatorFactory: public MeasureCreatorFactory { +public: + virtual MeasureCreator* Produce() override { return new CudaMeasureCreator(); } +}; diff --git a/reg-lib/cuda/CudaMeasureFactory.h b/reg-lib/cuda/CudaMeasureFactory.h deleted file mode 100644 index 58061a23..00000000 --- a/reg-lib/cuda/CudaMeasureFactory.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "CudaMeasure.h" - -class CudaMeasureFactory: public MeasureFactory { -public: - virtual Measure* Produce() override { return new CudaMeasure(); } -}; diff --git a/reg-test/reg_test_lncc.cpp b/reg-test/reg_test_lncc.cpp index 528a1642..e1bcd0ad 100644 --- a/reg-test/reg_test_lncc.cpp +++ b/reg-test/reg_test_lncc.cpp @@ -151,13 +151,13 @@ class LnccTest { unique_ptr compute{ platform->CreateCompute(*content) }; compute->ResampleImage(0, 0); content->SetWarped(floating.disown()); - // Create the measure - unique_ptr measure{ platform->CreateMeasure() }; + // Create the measure creator + unique_ptr measureCreator{ platform->CreateMeasureCreator() }; // Use LNCC as a measure - unique_ptr measure_lncc{ dynamic_cast(measure->Create(MeasureType::Lncc)) }; + unique_ptr measure_lncc{ dynamic_cast(measureCreator->Create(MeasureType::Lncc)) }; measure_lncc->SetKernelStandardDeviation(0, sigma); measure_lncc->SetTimePointWeight(0, 1.0); // weight initially set to default value of 1.0 - measure->Initialise(*measure_lncc, *content); + measureCreator->Initialise(*measure_lncc, *content); const double lncc = measure_lncc->GetSimilarityMeasureValue(); // Save for testing testCases.push_back({ testName, lncc, expLncc }); diff --git a/reg-test/reg_test_nmi.cpp b/reg-test/reg_test_nmi.cpp index 12941952..d3a2770e 100644 --- a/reg-test/reg_test_nmi.cpp +++ b/reg-test/reg_test_nmi.cpp @@ -82,12 +82,12 @@ class NmiTest { unique_ptr content{ contentCreator->Create(reference, floating) }; // Initialise the warped image using floating image content->SetWarped(floating.disown()); - // Create the measure - unique_ptr measure{ platform->CreateMeasure() }; + // Create the measure creator + unique_ptr measureCreator{ platform->CreateMeasureCreator() }; // Use NMI as a measure - unique_ptr measure_nmi{ dynamic_cast(measure->Create(MeasureType::Nmi)) }; + unique_ptr measure_nmi{ dynamic_cast(measureCreator->Create(MeasureType::Nmi)) }; measure_nmi->SetTimePointWeight(0, 1.0); // weight initially set to default value of 1.0 - measure->Initialise(*measure_nmi, *content); + measureCreator->Initialise(*measure_nmi, *content); const double nmi = measure_nmi->GetSimilarityMeasureValue(); testCases.push_back({ testName + " " + platform->GetName(), nmi, expected }); diff --git a/reg-test/reg_test_nmi_gradient.cpp b/reg-test/reg_test_nmi_gradient.cpp index fdb769ba..5342e1b1 100644 --- a/reg-test/reg_test_nmi_gradient.cpp +++ b/reg-test/reg_test_nmi_gradient.cpp @@ -90,14 +90,14 @@ class NmiGradientTest { unique_ptr compute{ platform->CreateCompute(*content) }; compute->ResampleImage(1, padding); compute->GetImageGradient(1, padding, 0); - // Create the measure - unique_ptr measure{ platform->CreateMeasure() }; + // Create the measure creator + unique_ptr measureCreator{ platform->CreateMeasureCreator() }; // Use NMI as a measure - unique_ptr measure_nmi{ dynamic_cast(measure->Create(MeasureType::Nmi)) }; + unique_ptr measure_nmi{ dynamic_cast(measureCreator->Create(MeasureType::Nmi)) }; measure_nmi->DoNotApproximatePw(); measure_nmi->SetTimePointWeight(0, 1.0); // weight initially set to default value of 1.0 measure_nmi->SetRefAndFloatBinNumbers(binNumber, binNumber, 0); - measure->Initialise(*measure_nmi, *content); + measureCreator->Initialise(*measure_nmi, *content); // Compute the NMI gradient measure_nmi->GetVoxelBasedSimilarityMeasureGradient(0); // Create an image to store the gradient values diff --git a/reg-test/reg_test_regr_measure.cpp b/reg-test/reg_test_regr_measure.cpp index 6bcdf88e..08b25515 100644 --- a/reg-test/reg_test_regr_measure.cpp +++ b/reg-test/reg_test_regr_measure.cpp @@ -1,7 +1,7 @@ #include "reg_test_common.h" #include "_reg_nmi.h" #include "CudaF3dContent.h" -#include "CudaMeasure.h" +#include "CudaMeasureCreator.hpp" /** * Measure regression tests to ensure the CPU and CUDA versions yield the same output @@ -94,8 +94,8 @@ class MeasureTest { Platform platformCuda(PlatformType::Cuda); // Create the measures - unique_ptr measureCreatorCpu{ new Measure() }; - unique_ptr measureCreatorCuda{ new CudaMeasure() }; + unique_ptr measureCreatorCpu{ new MeasureCreator() }; + unique_ptr measureCreatorCuda{ new CudaMeasureCreator() }; // Create the content creators unique_ptr contentCreatorCpu{ dynamic_cast(platformCpu.CreateContentCreator(ContentType::F3d2)) };