diff --git a/reg23Topograms/itkDTRrecon/CMakeLists.txt b/reg23Topograms/itkDTRrecon/CMakeLists.txt index dff2dd7..23d2510 100644 --- a/reg23Topograms/itkDTRrecon/CMakeLists.txt +++ b/reg23Topograms/itkDTRrecon/CMakeLists.txt @@ -20,6 +20,7 @@ SET(SRCS vtkContourTopogramProjectionFilter.cxx DRTMetaInformation.cpp itkReg23.cpp + itkReg23MetaInformation.cpp ) SET(HDR @@ -31,6 +32,7 @@ SET(HDR vtkContourTopogramProjectionFilter.h DRTMetaInformation.h itkReg23.h + itkReg23MetaInformation.h ) ADD_LIBRARY(${LIB_NAME} ${SRCS} ${HDR}) diff --git a/reg23Topograms/itkDTRrecon/DRTMetaInformation.cpp b/reg23Topograms/itkDTRrecon/DRTMetaInformation.cpp index 0b354a3..8702d59 100644 --- a/reg23Topograms/itkDTRrecon/DRTMetaInformation.cpp +++ b/reg23Topograms/itkDTRrecon/DRTMetaInformation.cpp @@ -551,7 +551,6 @@ R23MetaInformation (){ m_DegreeOfFreedom = tDegreeOfFreedomEnum::UNKNOWN; m_OptimizerType = tOptimizerTypeEnum::POWELL; m_MetricType = tMetricTypeEnum::NCC; - m_MaxIterations = 6; } diff --git a/reg23Topograms/itkDTRrecon/DRTMetaInformation.h b/reg23Topograms/itkDTRrecon/DRTMetaInformation.h index 6c71b5c..1aa2f5c 100644 --- a/reg23Topograms/itkDTRrecon/DRTMetaInformation.h +++ b/reg23Topograms/itkDTRrecon/DRTMetaInformation.h @@ -24,6 +24,13 @@ typedef enum eImageOrientationType{ FFS = 2 } tPatOrientation; + +typedef enum eHandlingRotImpTransform { + ALWAYS_USE = 0, + NEVER_USE, + STATION_DEPENDENT +} tHandlingRotImpTransform; + typedef enum eDegreeOfFreedomType { UNKNOWN = 0, THREE_DOF, @@ -428,6 +435,11 @@ public: itkSetMacro(UseRotationsForHiddenTransform, bool); itkGetMacro(UseRotationsForHiddenTransform, bool); + itkSetEnumMacro(DegreeOfFreedom, tDegreeOfFreedomEnum); + itkGetEnumMacro(DegreeOfFreedom, tDegreeOfFreedomEnum); + + itkSetEnumMacro(HandleRotationImpOffset, tHandlingRotImpTransform); + itkGetEnumMacro(HandleRotationImpOffset, tHandlingRotImpTransform); protected: @@ -462,7 +474,7 @@ protected: PointType /* center of projection in an IEC reference at - * Patient Origin of fixed images. Positioning scanner */ + * Patient Origin of fixed images. Positionin scanner */ m_ProjectionCenter, m_ProjectionCenterOffset1, m_ProjectionCenterOffset2; @@ -471,6 +483,12 @@ protected: bool m_UseRotationsForHiddenTransform; + tDegreeOfFreedomEnum + m_DegreeOfFreedom; + + tHandlingRotImpTransform + m_HandleRotationImpOffset; + /** Default Constructor **/ DRTProjectionGeometryImageMetaInformation (); /** Default Destructor **/ @@ -626,8 +644,7 @@ public: itkSetEnumMacro(MetricType, tMetricTypeEnum); itkGetEnumMacro(MetricType, tMetricTypeEnum); - itkSetEnumMacro(MaxIterations, int); - itkGetEnumMacro(MaxIterations, int); + protected: @@ -641,9 +658,6 @@ protected: tMetricTypeEnum m_MetricType; - int - m_MaxIterations; - /** Default Constructor **/ R23MetaInformation (); /** Default Destructor **/ diff --git a/reg23Topograms/itkDTRrecon/autoreg/itkMutualInformationTwoImageToOneImageMetric.h b/reg23Topograms/itkDTRrecon/autoreg/itkMutualInformationTwoImageToOneImageMetric.h index 678d7c0..bed071c 100644 --- a/reg23Topograms/itkDTRrecon/autoreg/itkMutualInformationTwoImageToOneImageMetric.h +++ b/reg23Topograms/itkDTRrecon/autoreg/itkMutualInformationTwoImageToOneImageMetric.h @@ -95,6 +95,7 @@ public: * typically results in narrower valleys in the cost fucntion. * Default value is false. */ itkSetMacro(SubtractMean, bool); + itkSetMacro(NumberOfHistogramBins, int); itkGetConstReferenceMacro(SubtractMean, bool); itkBooleanMacro(SubtractMean); @@ -106,6 +107,7 @@ protected: private: bool m_SubtractMean; + int m_NumberOfHistogramBins; }; } // end namespace itk diff --git a/reg23Topograms/itkDTRrecon/autoreg/itkMutualInformationTwoImageToOneImageMetric.hxx b/reg23Topograms/itkDTRrecon/autoreg/itkMutualInformationTwoImageToOneImageMetric.hxx index b7c03a7..070f6ba 100644 --- a/reg23Topograms/itkDTRrecon/autoreg/itkMutualInformationTwoImageToOneImageMetric.hxx +++ b/reg23Topograms/itkDTRrecon/autoreg/itkMutualInformationTwoImageToOneImageMetric.hxx @@ -36,6 +36,7 @@ MutualInformationTwoImageToOneImageMetric::MutualInformationTwoImageToOneImageMetric() { m_SubtractMean = false; + m_NumberOfHistogramBins = 50; } template @@ -147,7 +148,8 @@ MutualInformationTwoImageToOneImageMetric::GetValue() //auto numberOfSamples = static_cast(numberOfPixels * 0.50); //100% // since we have a ROI, then we should not set allPixels to TRUE. //metric1->UseAllPixelsOn(); - metric1->SetNumberOfHistogramBins(50); + std::cout << "m_NumberOfHistogramBins " << m_NumberOfHistogramBins << std::endl; + metric1->SetNumberOfHistogramBins(m_NumberOfHistogramBins); // InternalImageType::IndexType pIndex; // pIndex[0]=200; @@ -183,7 +185,7 @@ MutualInformationTwoImageToOneImageMetric::GetValue() //numberOfSamples = static_cast(numberOfPixels * 0.50); //100% //metric2->SetNumberOfSpatialSamples(numberOfSamples); //metric2->UseAllPixelsOn(); - metric2->SetNumberOfHistogramBins(50); + metric2->SetNumberOfHistogramBins(m_NumberOfHistogramBins); metric2->SetFixedImage(fixedImage2); metric2->SetMovingImage(this->m_Filter2->GetOutput()); metric2->Initialize(); diff --git a/reg23Topograms/itkDTRrecon/itkImageProcessor.cpp b/reg23Topograms/itkDTRrecon/itkImageProcessor.cpp index e8e173f..4229fca 100644 --- a/reg23Topograms/itkDTRrecon/itkImageProcessor.cpp +++ b/reg23Topograms/itkDTRrecon/itkImageProcessor.cpp @@ -98,6 +98,18 @@ itkImageProcessor::itkImageProcessor() m_r23MetaInfo = NULL; m_r23MetaInfo = R23MetaInformation::New(); + m_PowellOptimizerMetaInfo = NULL; + m_PowellOptimizerMetaInfo = PowellOptimizerMetaInformation::New(); + + m_AmoebaOptimizerMetaInfo = NULL; + m_AmoebaOptimizerMetaInfo = AmoebaOptimizerMetaInformation::New(); + + m_MIMetricMetaInfo = NULL; + m_MIMetricMetaInfo = MIMetricMetaInformation::New(); + + m_NCCMetricMetaInfo = NULL; + m_NCCMetricMetaInfo = NCCMetricMetaInformation::New(); + /* Initialise the projection geoemtry with defaults */ m_DRTGeometryMetaInfo = NULL; m_DRTGeometryMetaInfo @@ -136,6 +148,8 @@ itkImageProcessor::itkImageProcessor() m_DRTGeometryMetaInfo->SetProjectionCenterOffset1(Point3D); m_DRTGeometryMetaInfo->SetProjectionCenterOffset2(Point3D); + m_DRTGeometryMetaInfo->SetDegreeOfFreedom(eDegreeOfFreedomType::THREE_DOF); + m_DRTGeometryMetaInfo->SetHandleRotationImpOffset(eHandlingRotImpTransform::ALWAYS_USE); optimizerObserver = CommandIterationUpdate::New(); ExhaustiveOptimizerObserver = ExhaustiveCommandIterationUpdate::New(); @@ -1114,18 +1128,20 @@ itkImageProcessor::GetFinalR23Parameters(){ break; case SIX_DOF: - pPars[0] = currentPosition[0] - - m_TransformMetaInfo->GetHiddenRotations()[0]; - pPars[1] = currentPosition[1] - - m_TransformMetaInfo->GetHiddenRotations()[1]; - pPars[2] = currentPosition[2] - - m_TransformMetaInfo->GetHiddenRotations()[2]; - pPars[3] = currentPosition[3] + pPars[3] = currentPosition[0] - m_TransformMetaInfo->GetHiddenTranslations()[0]; - pPars[4] = currentPosition[4] + pPars[4] = currentPosition[1] - m_TransformMetaInfo->GetHiddenTranslations()[1]; - pPars[5] = currentPosition[5] + pPars[5] = currentPosition[2] - m_TransformMetaInfo->GetHiddenTranslations()[2]; + + pPars[0] = currentPosition[3] + - m_TransformMetaInfo->GetHiddenRotations()[0]; + pPars[1] = currentPosition[4] + - m_TransformMetaInfo->GetHiddenRotations()[1]; + pPars[2] = currentPosition[5] + - m_TransformMetaInfo->GetHiddenRotations()[2]; + break; default: @@ -1190,11 +1206,59 @@ void itkImageProcessor::SetMetric(std::string metric) } -void itkImageProcessor::SetMaxNumberOfIterations(int iNum) -{ - m_r23MetaInfo->SetMaxIterations(iNum); +void itkImageProcessor::SetDegreeOfFreedom(tDegreeOfFreedomEnum dof){ + + m_DRTGeometryMetaInfo->SetDegreeOfFreedom(dof); + m_r23MetaInfo->SetDegreeOfFreedom(dof); + } +void itkImageProcessor::SetHandleRotationImportOffset(eHandlingRotImpTransform hrio){ + + m_DRTGeometryMetaInfo->SetHandleRotationImpOffset(hrio); + +} + + + +void itkImageProcessor::SetPowellOptimParameters( + double dStepT, + double dValTol, + double dStepL, + int iMaxLinI, + int iMaxIter){ + + m_PowellOptimizerMetaInfo->SetStepTolerance(dStepT); + m_PowellOptimizerMetaInfo->SetValueTolerance(dValTol); + m_PowellOptimizerMetaInfo->SetStepLength(dStepL); + m_PowellOptimizerMetaInfo->SetMaximumLineInteration(iMaxLinI); + m_PowellOptimizerMetaInfo->SetMaxIterations(iMaxIter); + +} + +void itkImageProcessor::SetAmoebaOptimParameters( + double dParConvTol, + double dFuntConvTol, + double dSimplex, + int iMaxIter){ + m_AmoebaOptimizerMetaInfo->SetParametersConvergenceTolerance(dParConvTol); + m_AmoebaOptimizerMetaInfo->SetFunctionConvergenceTolerance(dFuntConvTol); + m_AmoebaOptimizerMetaInfo->SetSimplexDelta(dSimplex); + m_AmoebaOptimizerMetaInfo->SetMaxIterations(iMaxIter); + +} + +void itkImageProcessor::SetMIMetricParameters(double dMaxT,int iNhb){ + m_MIMetricMetaInfo->SetMaxTranslation(dMaxT); + m_MIMetricMetaInfo->SetNumberOfHistogramBins(iNhb); +} + +void itkImageProcessor::SetNCCMetricParameters(double dMaxT,bool bSm){ + m_NCCMetricMetaInfo->SetMaxTranslation(dMaxT); + m_NCCMetricMetaInfo->SetSubtractMean(bSm); +} + + void itkImageProcessor::InitializeProjector() { @@ -2523,15 +2587,18 @@ void itkImageProcessor::ResetROIRegions(){ } -void itkImageProcessor::InizializeRegistration(double stepLength, - double maxTranslation, - eDegreeOfFreedomType dof){ +void itkImageProcessor::InizializeRegistration(){ - m_r23MetaInfo->SetDegreeOfFreedom(dof); m_R23->SetPA(m_PASourceDupli->GetOutput()); m_R23->SetLAT(m_LATSourceDupli->GetOutput()); m_R23->SetVolume(m_VolumeSourceDupli->GetOutput()); + m_R23->Setr23Meta(m_r23MetaInfo); + m_R23->SetPowellMeta(m_PowellOptimizerMetaInfo); + m_R23->SetAmoebaMeta(m_AmoebaOptimizerMetaInfo); + m_R23->SetMIMeta(m_MIMetricMetaInfo); + m_R23->SetNCCMeta(m_NCCMetricMetaInfo); + m_R23->SetInternalTransf1(m_InternalTransf1); m_R23->SetInternalTransf2(m_InternalTransf2); m_R23->Setfilter1(filter1); @@ -2540,8 +2607,7 @@ void itkImageProcessor::InizializeRegistration(double stepLength, m_R23->Setinterpolator2(interpolator2); m_R23->SetTransformMetaInfo(m_TransformMetaInfo); - m_R23->InitializeRegistration( - stepLength,maxTranslation,dof); + m_R23->InitializeRegistration(); } diff --git a/reg23Topograms/itkDTRrecon/itkImageProcessor.h b/reg23Topograms/itkDTRrecon/itkImageProcessor.h index cb7b22d..8939750 100644 --- a/reg23Topograms/itkDTRrecon/itkImageProcessor.h +++ b/reg23Topograms/itkDTRrecon/itkImageProcessor.h @@ -47,6 +47,7 @@ gfattori 08.11.2021 #include "itkImageProcessorHelpers.h" #include "itkReg23.h" +#include "itkReg23MetaInformation.h" namespace itk { @@ -86,12 +87,9 @@ public: void SetRegionFixed1(int,int,int,int); void SetRegionFixed2(int,int,int,int); void ResetROIRegions(); - void InizializeRegistration(double stepLength, - double maxTranslation, - eDegreeOfFreedomType dof); + void InizializeRegistration(); /** Maximum number of iterations for the optimizer */ - void SetMaxNumberOfIterations(int); itkGetMacro(R23, itkReg23::Pointer); @@ -103,6 +101,24 @@ public: void SetMetric(std::string); void SetMetric(tMetricTypeEnum); + /** Set DOF */ + void SetDegreeOfFreedom(tDegreeOfFreedomEnum); + + /** Set Handle Of Rotation Import Offset */ + void SetHandleRotationImportOffset(tHandlingRotImpTransform); + + /** Set PowellOptimizer */ + void SetPowellOptimParameters(double,double,double,int,int); + + /** Set AmoebaOptimizer */ + void SetAmoebaOptimParameters(double,double,double,int); + + /** Set MI */ + void SetMIMetricParameters(double,int); + + /** Set NCC */ + void SetNCCMetricParameters(double,bool); + /** Set number of logic CPU to be made available to interpolators*/ void SetNumberOfWorkingUnits(int iN); @@ -390,6 +406,18 @@ private: R23MetaInformation::Pointer m_r23MetaInfo; + PowellOptimizerMetaInformation::Pointer + m_PowellOptimizerMetaInfo; + + AmoebaOptimizerMetaInformation::Pointer + m_AmoebaOptimizerMetaInfo; + + MIMetricMetaInformation::Pointer + m_MIMetricMetaInfo; + + NCCMetricMetaInformation::Pointer + m_NCCMetricMetaInfo; + InternalTransformMetaInformation::Pointer m_InternalTransf1, m_InternalTransf2; diff --git a/reg23Topograms/itkDTRrecon/itkImageProcessorHelpers.cpp b/reg23Topograms/itkDTRrecon/itkImageProcessorHelpers.cpp index bb93324..8d0760b 100644 --- a/reg23Topograms/itkDTRrecon/itkImageProcessorHelpers.cpp +++ b/reg23Topograms/itkDTRrecon/itkImageProcessorHelpers.cpp @@ -100,6 +100,7 @@ CalculateInternalTransformV3( const char* queryStationName(const char* pcFName){ static std::string buffer; + buffer.clear(); /* Check if we can open the file */ gdcm::Reader R; @@ -112,10 +113,8 @@ const char* queryStationName(const char* pcFName){ const gdcm::File &file = R.GetFile(); const gdcm::DataSet &ds = file.GetDataSet(); - std::string s (gGetStringValueFromTag(gdcm::Tag(0x0008,0x1010), ds)); - std::copy(s.rbegin(), s.rend(), std::back_inserter(buffer)); - - std::reverse(buffer.begin(),buffer.end()); + std::string s(gGetStringValueFromTag(gdcm::Tag(0x0008,0x1010), ds)); + std::copy(s.begin(), s.end(), buffer.begin()); return buffer.c_str(); @@ -134,10 +133,12 @@ int query2DimageReconstructionDiameter(const char *pcFName){ const gdcm::File &file = R.GetFile(); const gdcm::DataSet &ds = file.GetDataSet(); - char* sTmpString = new char [255]; - strcpy( sTmpString,gGetStringValueFromTag(gdcm::Tag(0x0018,0x1100), ds)); + std::string buffer; - return std::atoi(sTmpString); + std::string s(gGetStringValueFromTag(gdcm::Tag(0x0018,0x1100), ds)); + std::copy(s.begin(), s.end(), buffer.begin()); + + return std::stoi(buffer); } diff --git a/reg23Topograms/itkDTRrecon/itkReg23.cpp b/reg23Topograms/itkDTRrecon/itkReg23.cpp index 85c81c1..4ba0e29 100644 --- a/reg23Topograms/itkDTRrecon/itkReg23.cpp +++ b/reg23Topograms/itkDTRrecon/itkReg23.cpp @@ -13,6 +13,7 @@ itkReg23::itkReg23() NCCmetric = MetricType::New(); MImetric = MIMetricType::New(); + // Optimizers PowellOptimizer = PowellOptimizerType::New(); AmoebaOptimizer = AmoebaOptimizerType::New(); @@ -71,10 +72,7 @@ void itkReg23::PrintSelf(std::ostream& os, Indent indent) const Superclass::PrintSelf(os, indent); } -void itkReg23::InitializeRegistration( - double stepLength, - double maxTranslation, - eDegreeOfFreedomType dof) +void itkReg23::InitializeRegistration() { std::cout << "*" << __COMPACT_PRETTY_FUNCTION__ << std::endl; @@ -126,6 +124,17 @@ void itkReg23::InitializeRegistration( itkExceptionMacro(<< "m_interpolator2 data not present"); } +// std::cout << "Print r23" << +// m_r23Meta->GetMetricType() << " " << m_r23Meta->GetDegreeOfFreedom() << std::endl; +// std::cout << "Print Powell" << +// m_PowellMeta->GetStepLength() << " " << m_PowellMeta->GetStepTolerance() << std::endl; +// std::cout << "Print Amoeba" << +// m_AmoebaMeta->GetFunctionConvergenceTolerance() << " " << m_AmoebaMeta->GetSimplexDelta() << std::endl; +// std::cout << "Print NCC" << +// m_NCCMeta->GetSubtractMean() << " " << m_NCCMeta->GetMaxTranslation() << std::endl; +// std::cout << "Print MI" << +// m_MIMeta->GetMaxTranslation() << std::endl; + AmoebaOptimizerType::ParametersType simplexDelta(3); ExhaustiveOptimizerType::StepsType steps(3); const int numberOfSteps = 25; //In each direction. Total number of steps is ((2*numberOfSteps+1))^3. For 25 -> 132651. @@ -137,11 +146,11 @@ void itkReg23::InitializeRegistration( std::cout<< "Using POWELL Optimizer" <SetMaximize(false); // for NCC and MI - PowellOptimizer->SetMaximumIteration(m_r23Meta->GetMaxIterations()); - PowellOptimizer->SetMaximumLineIteration(4); // for Powell's method - PowellOptimizer->SetStepLength(stepLength); - PowellOptimizer->SetStepTolerance(0.01); - PowellOptimizer->SetValueTolerance(0.000002); + PowellOptimizer->SetMaximumIteration(m_PowellMeta->GetMaxIterations()); + PowellOptimizer->SetMaximumLineIteration(m_PowellMeta->GetMaximumLineInteration()); // for Powell's method + PowellOptimizer->SetStepLength(m_PowellMeta->GetStepLength()); + PowellOptimizer->SetStepTolerance(m_PowellMeta->GetStepTolerance()); + PowellOptimizer->SetValueTolerance(m_PowellMeta->GetValueTolerance()); PowellOptimizer->RemoveAllObservers(); PowellOptimizer->AddObserver(itk::IterationEvent(), m_OptimizerObserver); @@ -153,17 +162,17 @@ void itkReg23::InitializeRegistration( std::cout<< "Using AMOEBA Optimizer" <SetMinimize(true); - AmoebaOptimizer->SetMaximumNumberOfIterations(m_r23Meta->GetMaxIterations()); - AmoebaOptimizer->SetParametersConvergenceTolerance(0.1); - AmoebaOptimizer->SetFunctionConvergenceTolerance(0.000002); + AmoebaOptimizer->SetMaximumNumberOfIterations(m_AmoebaMeta->GetMaxIterations()); + AmoebaOptimizer->SetParametersConvergenceTolerance(m_AmoebaMeta->GetParametersConvergenceTolerance()); + AmoebaOptimizer->SetFunctionConvergenceTolerance(m_AmoebaMeta->GetFunctionConvergenceTolerance()); AmoebaOptimizer->SetAutomaticInitialSimplex(false); //Initial size of the simplex (otherwise it is a very small number and optimizer stops immeditaly) // 2 mm / 2 degrees seems to be a good value which performs well. - if (GetNumberOfDOF(dof) == 0) { + if (GetNumberOfDOF(m_r23Meta->GetDegreeOfFreedom()) == 0) { itkExceptionMacro(<< "Unkown or unsupported degree of freedom"); } - for (int i = 0; i < GetNumberOfDOF(dof); i++) { - simplexDelta[i] = 2.0; + for (int i = 0; i < GetNumberOfDOF(m_r23Meta->GetDegreeOfFreedom()); i++) { + simplexDelta[i] = m_AmoebaMeta->GetSimplexDelta(); } AmoebaOptimizer->SetInitialSimplexDelta(simplexDelta); AmoebaOptimizer->RemoveAllObservers(); @@ -176,13 +185,13 @@ void itkReg23::InitializeRegistration( case tOptimizerTypeEnum::EXHAUSTIVE: std::cout<< "Using Extensive Optimizer" <SetNumberOfSteps(steps); - ExhaustiveOptimizer->SetStepLength(stepLength); +// steps[0] = numberOfSteps; +// steps[1] = numberOfSteps; +// steps[2] = numberOfSteps; +// ExhaustiveOptimizer->SetNumberOfSteps(steps); +// ExhaustiveOptimizer->SetStepLength(stepLength); - registration->SetOptimizer(ExhaustiveOptimizer); +// registration->SetOptimizer(ExhaustiveOptimizer); break; @@ -197,8 +206,9 @@ void itkReg23::InitializeRegistration( std::cout<< "Using MI Metric" <SetMetric(MImetric); + MImetric->SetNumberOfHistogramBins(m_MIMeta->GetNumberOfHistogramBins()); MImetric->ComputeGradientOff(); - MImetric->SetMaxTranslation(maxTranslation); + MImetric->SetMaxTranslation(m_MIMeta->GetMaxTranslation()); break; @@ -207,7 +217,7 @@ void itkReg23::InitializeRegistration( registration->SetMetric(NCCmetric); NCCmetric->ComputeGradientOff(); NCCmetric->SetSubtractMean(true); - NCCmetric->SetMaxTranslation(maxTranslation); + NCCmetric->SetMaxTranslation(m_NCCMeta->GetMaxTranslation()); break; diff --git a/reg23Topograms/itkDTRrecon/itkReg23.h b/reg23Topograms/itkDTRrecon/itkReg23.h index f885cc0..1a6f62e 100644 --- a/reg23Topograms/itkDTRrecon/itkReg23.h +++ b/reg23Topograms/itkDTRrecon/itkReg23.h @@ -18,6 +18,8 @@ #include "itkImageProcessorHelpers.h" #include "itkQtIterationUpdate.h" +#include "itkReg23MetaInformation.h" + namespace itk{ @@ -50,6 +52,19 @@ public: itkSetMacro(r23Meta, R23MetaInformation::Pointer); itkGetMacro(r23Meta, R23MetaInformation::Pointer); + itkSetMacro(PowellMeta, PowellOptimizerMetaInformation::Pointer); + itkGetMacro(PowellMeta, PowellOptimizerMetaInformation::Pointer); + + itkSetMacro(AmoebaMeta, AmoebaOptimizerMetaInformation::Pointer); + itkGetMacro(AmoebaMeta, AmoebaOptimizerMetaInformation::Pointer); + + itkSetMacro(MIMeta, MIMetricMetaInformation::Pointer); + itkGetMacro(MIMeta, MIMetricMetaInformation::Pointer); + + itkSetMacro(NCCMeta, NCCMetricMetaInformation::Pointer); + itkGetMacro(NCCMeta, NCCMetricMetaInformation::Pointer); + + itkSetMacro(Volume, InternalImageType::Pointer); itkGetMacro(Volume, InternalImageType::Pointer); @@ -92,9 +107,7 @@ public: /** Auto Reg23 methods */ /** Initialize the registration pipeline*/ - void InitializeRegistration(double stepLength, - double maxTranslation, - eDegreeOfFreedomType dof); + void InitializeRegistration(); /** Start the registration process*/ int StartRegistration(std::string extraInfo); /** Get the current cost function value from the optimizer*/ @@ -151,6 +164,18 @@ private: R23MetaInformation::Pointer m_r23Meta; + PowellOptimizerMetaInformation::Pointer + m_PowellMeta; + + AmoebaOptimizerMetaInformation::Pointer + m_AmoebaMeta; + + MIMetricMetaInformation::Pointer + m_MIMeta; + + NCCMetricMetaInformation::Pointer + m_NCCMeta; + InternalImageType::Pointer m_Volume, m_PA, diff --git a/reg23Topograms/itkDTRrecon/itkReg23MetaInformation.cpp b/reg23Topograms/itkDTRrecon/itkReg23MetaInformation.cpp new file mode 100644 index 0000000..32d94a7 --- /dev/null +++ b/reg23Topograms/itkDTRrecon/itkReg23MetaInformation.cpp @@ -0,0 +1,104 @@ +#include "itkReg23MetaInformation.h" + + +namespace itk { + +PowellOptimizerMetaInformation:: +PowellOptimizerMetaInformation(){ + + this->m_MaximumLineInteration = 4; + this->m_StepLength = 2.0; + this->m_StepTolerance = 0.01; + this->m_ValueTolerance = 0.000002; + + this->m_MaxIterations = 6; +} + +void +PowellOptimizerMetaInformation +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + + +PowellOptimizerMetaInformation +::~PowellOptimizerMetaInformation () +{ + +} + + +AmoebaOptimizerMetaInformation:: +AmoebaOptimizerMetaInformation(){ + + this->m_ParametersConvergenceTolerance = 0.1; + this->m_FunctionConvergenceTolerance = 0.000002; + this->m_SimplexDelta = 2.0; + + this->m_MaxIterations = 100; +} + + +void +AmoebaOptimizerMetaInformation +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + + +AmoebaOptimizerMetaInformation +::~AmoebaOptimizerMetaInformation () +{ + +} + + +MIMetricMetaInformation:: +MIMetricMetaInformation(){ + + this->m_MaxTranslation = 100.0; + this->m_NumberOfHistogramBins = 50; + +} + + +void +MIMetricMetaInformation +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + + +MIMetricMetaInformation +::~MIMetricMetaInformation () +{ + +} + +NCCMetricMetaInformation:: +NCCMetricMetaInformation(){ + + this->m_MaxTranslation = 100.0; + this->m_SubtractMean = true; + +} + + +void +NCCMetricMetaInformation +::PrintSelf(std::ostream& os, itk::Indent indent) const +{ + Superclass::PrintSelf(os, indent); +} + + +NCCMetricMetaInformation +::~NCCMetricMetaInformation () +{ + +} + +} diff --git a/reg23Topograms/itkDTRrecon/itkReg23MetaInformation.h b/reg23Topograms/itkDTRrecon/itkReg23MetaInformation.h new file mode 100644 index 0000000..45d1c5c --- /dev/null +++ b/reg23Topograms/itkDTRrecon/itkReg23MetaInformation.h @@ -0,0 +1,232 @@ +#ifndef ITKREG23METAINFORMATION_H +#define ITKREG23METAINFORMATION_H + +#include "itkObject.h" +#include "itkObjectFactory.h" +#include "itkSmartPointer.h" +#include "itkMacro.h" + + +namespace itk { + + +class PowellOptimizerMetaInformation : + public itk::Object{ + +public: + /** standard typedefs **/ + typedef PowellOptimizerMetaInformation Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer Pointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(PowellOptimizerMetaInformation, itk::Object); + + /** object information streaming **/ + void PrintSelf(std::ostream& os, itk::Indent indent) const; + + + itkSetMacro(StepTolerance,double); + itkGetMacro(StepTolerance,double); + + itkSetMacro(ValueTolerance,double); + itkGetMacro(ValueTolerance,double); + + itkSetMacro(StepLength,double); + itkGetMacro(StepLength,double); + + itkSetMacro(MaximumLineInteration,int); + itkGetMacro(MaximumLineInteration,int); + + itkSetEnumMacro(MaxIterations, int); + itkGetEnumMacro(MaxIterations, int); + + +protected: + + double m_StepTolerance; + + double m_ValueTolerance; + + double m_StepLength; + + int m_MaximumLineInteration; + + int + m_MaxIterations; + + /** Default Constructor **/ + PowellOptimizerMetaInformation (); + /** Default Destructor **/ + virtual ~PowellOptimizerMetaInformation (); + +private: + /** purposely not implemented **/ + PowellOptimizerMetaInformation (const Self&); + + /** purposely not implemented **/ + void operator=(const Self&); +}; + + +class AmoebaOptimizerMetaInformation : + public itk::Object{ + +public: + /** standard typedefs **/ + typedef AmoebaOptimizerMetaInformation Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer Pointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(AmoebaOptimizerMetaInformation, itk::Object); + + /** object information streaming **/ + void PrintSelf(std::ostream& os, itk::Indent indent) const; + + + itkSetMacro(ParametersConvergenceTolerance,double); + itkGetMacro(ParametersConvergenceTolerance,double); + + itkSetMacro(FunctionConvergenceTolerance,double); + itkGetMacro(FunctionConvergenceTolerance,double); + + itkSetMacro(SimplexDelta,double); + itkGetMacro(SimplexDelta,double); + + itkSetEnumMacro(MaxIterations, int); + itkGetEnumMacro(MaxIterations, int); + +protected: + + double m_ParametersConvergenceTolerance; + + double m_FunctionConvergenceTolerance; + + double m_SimplexDelta; + + int + m_MaxIterations; + + /** Default Constructor **/ + AmoebaOptimizerMetaInformation (); + /** Default Destructor **/ + virtual ~AmoebaOptimizerMetaInformation (); + +private: + /** purposely not implemented **/ + AmoebaOptimizerMetaInformation (const Self&); + + /** purposely not implemented **/ + void operator=(const Self&); +}; + + +class MIMetricMetaInformation : + public itk::Object{ + +public: + /** standard typedefs **/ + typedef MIMetricMetaInformation Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer Pointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(MIMetricMetaInformation, itk::Object); + + /** object information streaming **/ + void PrintSelf(std::ostream& os, itk::Indent indent) const; + + + itkSetMacro(MaxTranslation,double); + itkGetMacro(MaxTranslation,double); + + itkSetMacro(NumberOfHistogramBins,int); + itkGetMacro(NumberOfHistogramBins,int); + +protected: + + double m_MaxTranslation; + + int m_NumberOfHistogramBins; + + + /** Default Constructor **/ + MIMetricMetaInformation (); + /** Default Destructor **/ + virtual ~MIMetricMetaInformation (); + +private: + /** purposely not implemented **/ + MIMetricMetaInformation (const Self&); + + /** purposely not implemented **/ + void operator=(const Self&); +}; + + +class NCCMetricMetaInformation : + public itk::Object{ + +public: + /** standard typedefs **/ + typedef NCCMetricMetaInformation Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer Pointer; + + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(NCCMetricMetaInformation, itk::Object); + + /** object information streaming **/ + void PrintSelf(std::ostream& os, itk::Indent indent) const; + + + itkSetMacro(MaxTranslation,double); + itkGetMacro(MaxTranslation,double); + + itkSetMacro(SubtractMean,bool); + itkGetMacro(SubtractMean,bool); + +protected: + + double m_MaxTranslation; + + bool m_SubtractMean; + + + + /** Default Constructor **/ + NCCMetricMetaInformation (); + /** Default Destructor **/ + virtual ~NCCMetricMetaInformation (); + +private: + /** purposely not implemented **/ + NCCMetricMetaInformation (const Self&); + + /** purposely not implemented **/ + void operator=(const Self&); +}; + +} + + + + + + + + +#endif