Merge branch 'ScoutRTUIDevel' of https://git.psi.ch/cpt_bioeng/drt into ScoutRTUIDevel

This commit is contained in:
Proton local user
2023-05-27 00:46:34 +02:00
12 changed files with 549 additions and 64 deletions

View File

@ -20,6 +20,7 @@ SET(SRCS
vtkContourTopogramProjectionFilter.cxx vtkContourTopogramProjectionFilter.cxx
DRTMetaInformation.cpp DRTMetaInformation.cpp
itkReg23.cpp itkReg23.cpp
itkReg23MetaInformation.cpp
) )
SET(HDR SET(HDR
@ -31,6 +32,7 @@ SET(HDR
vtkContourTopogramProjectionFilter.h vtkContourTopogramProjectionFilter.h
DRTMetaInformation.h DRTMetaInformation.h
itkReg23.h itkReg23.h
itkReg23MetaInformation.h
) )
ADD_LIBRARY(${LIB_NAME} ${SRCS} ${HDR}) ADD_LIBRARY(${LIB_NAME} ${SRCS} ${HDR})

View File

@ -551,7 +551,6 @@ R23MetaInformation (){
m_DegreeOfFreedom = tDegreeOfFreedomEnum::UNKNOWN; m_DegreeOfFreedom = tDegreeOfFreedomEnum::UNKNOWN;
m_OptimizerType = tOptimizerTypeEnum::POWELL; m_OptimizerType = tOptimizerTypeEnum::POWELL;
m_MetricType = tMetricTypeEnum::NCC; m_MetricType = tMetricTypeEnum::NCC;
m_MaxIterations = 6;
} }

View File

@ -24,6 +24,13 @@ typedef enum eImageOrientationType{
FFS = 2 FFS = 2
} tPatOrientation; } tPatOrientation;
typedef enum eHandlingRotImpTransform {
ALWAYS_USE = 0,
NEVER_USE,
STATION_DEPENDENT
} tHandlingRotImpTransform;
typedef enum eDegreeOfFreedomType { typedef enum eDegreeOfFreedomType {
UNKNOWN = 0, UNKNOWN = 0,
THREE_DOF, THREE_DOF,
@ -428,6 +435,11 @@ public:
itkSetMacro(UseRotationsForHiddenTransform, bool); itkSetMacro(UseRotationsForHiddenTransform, bool);
itkGetMacro(UseRotationsForHiddenTransform, bool); itkGetMacro(UseRotationsForHiddenTransform, bool);
itkSetEnumMacro(DegreeOfFreedom, tDegreeOfFreedomEnum);
itkGetEnumMacro(DegreeOfFreedom, tDegreeOfFreedomEnum);
itkSetEnumMacro(HandleRotationImpOffset, tHandlingRotImpTransform);
itkGetEnumMacro(HandleRotationImpOffset, tHandlingRotImpTransform);
protected: protected:
@ -462,7 +474,7 @@ protected:
PointType PointType
/* center of projection in an IEC reference at /* 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_ProjectionCenter,
m_ProjectionCenterOffset1, m_ProjectionCenterOffset1,
m_ProjectionCenterOffset2; m_ProjectionCenterOffset2;
@ -471,6 +483,12 @@ protected:
bool bool
m_UseRotationsForHiddenTransform; m_UseRotationsForHiddenTransform;
tDegreeOfFreedomEnum
m_DegreeOfFreedom;
tHandlingRotImpTransform
m_HandleRotationImpOffset;
/** Default Constructor **/ /** Default Constructor **/
DRTProjectionGeometryImageMetaInformation (); DRTProjectionGeometryImageMetaInformation ();
/** Default Destructor **/ /** Default Destructor **/
@ -626,8 +644,7 @@ public:
itkSetEnumMacro(MetricType, tMetricTypeEnum); itkSetEnumMacro(MetricType, tMetricTypeEnum);
itkGetEnumMacro(MetricType, tMetricTypeEnum); itkGetEnumMacro(MetricType, tMetricTypeEnum);
itkSetEnumMacro(MaxIterations, int);
itkGetEnumMacro(MaxIterations, int);
protected: protected:
@ -641,9 +658,6 @@ protected:
tMetricTypeEnum tMetricTypeEnum
m_MetricType; m_MetricType;
int
m_MaxIterations;
/** Default Constructor **/ /** Default Constructor **/
R23MetaInformation (); R23MetaInformation ();
/** Default Destructor **/ /** Default Destructor **/

View File

@ -95,6 +95,7 @@ public:
* typically results in narrower valleys in the cost fucntion. * typically results in narrower valleys in the cost fucntion.
* Default value is false. */ * Default value is false. */
itkSetMacro(SubtractMean, bool); itkSetMacro(SubtractMean, bool);
itkSetMacro(NumberOfHistogramBins, int);
itkGetConstReferenceMacro(SubtractMean, bool); itkGetConstReferenceMacro(SubtractMean, bool);
itkBooleanMacro(SubtractMean); itkBooleanMacro(SubtractMean);
@ -106,6 +107,7 @@ protected:
private: private:
bool m_SubtractMean; bool m_SubtractMean;
int m_NumberOfHistogramBins;
}; };
} // end namespace itk } // end namespace itk

View File

@ -36,6 +36,7 @@ MutualInformationTwoImageToOneImageMetric<TFixedImage,
TMovingImage>::MutualInformationTwoImageToOneImageMetric() TMovingImage>::MutualInformationTwoImageToOneImageMetric()
{ {
m_SubtractMean = false; m_SubtractMean = false;
m_NumberOfHistogramBins = 50;
} }
template <typename TFixedImage, typename TMovingImage> template <typename TFixedImage, typename TMovingImage>
@ -147,7 +148,8 @@ MutualInformationTwoImageToOneImageMetric<TFixedImage, TMovingImage>::GetValue()
//auto numberOfSamples = static_cast<unsigned int>(numberOfPixels * 0.50); //100% //auto numberOfSamples = static_cast<unsigned int>(numberOfPixels * 0.50); //100%
// since we have a ROI, then we should not set allPixels to TRUE. // since we have a ROI, then we should not set allPixels to TRUE.
//metric1->UseAllPixelsOn(); //metric1->UseAllPixelsOn();
metric1->SetNumberOfHistogramBins(50); std::cout << "m_NumberOfHistogramBins " << m_NumberOfHistogramBins << std::endl;
metric1->SetNumberOfHistogramBins(m_NumberOfHistogramBins);
// InternalImageType::IndexType pIndex; // InternalImageType::IndexType pIndex;
// pIndex[0]=200; // pIndex[0]=200;
@ -183,7 +185,7 @@ MutualInformationTwoImageToOneImageMetric<TFixedImage, TMovingImage>::GetValue()
//numberOfSamples = static_cast<unsigned int>(numberOfPixels * 0.50); //100% //numberOfSamples = static_cast<unsigned int>(numberOfPixels * 0.50); //100%
//metric2->SetNumberOfSpatialSamples(numberOfSamples); //metric2->SetNumberOfSpatialSamples(numberOfSamples);
//metric2->UseAllPixelsOn(); //metric2->UseAllPixelsOn();
metric2->SetNumberOfHistogramBins(50); metric2->SetNumberOfHistogramBins(m_NumberOfHistogramBins);
metric2->SetFixedImage(fixedImage2); metric2->SetFixedImage(fixedImage2);
metric2->SetMovingImage(this->m_Filter2->GetOutput()); metric2->SetMovingImage(this->m_Filter2->GetOutput());
metric2->Initialize(); metric2->Initialize();

View File

@ -98,6 +98,18 @@ itkImageProcessor::itkImageProcessor()
m_r23MetaInfo = NULL; m_r23MetaInfo = NULL;
m_r23MetaInfo = R23MetaInformation::New(); 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 */ /* Initialise the projection geoemtry with defaults */
m_DRTGeometryMetaInfo = NULL; m_DRTGeometryMetaInfo = NULL;
m_DRTGeometryMetaInfo m_DRTGeometryMetaInfo
@ -136,6 +148,8 @@ itkImageProcessor::itkImageProcessor()
m_DRTGeometryMetaInfo->SetProjectionCenterOffset1(Point3D); m_DRTGeometryMetaInfo->SetProjectionCenterOffset1(Point3D);
m_DRTGeometryMetaInfo->SetProjectionCenterOffset2(Point3D); m_DRTGeometryMetaInfo->SetProjectionCenterOffset2(Point3D);
m_DRTGeometryMetaInfo->SetDegreeOfFreedom(eDegreeOfFreedomType::THREE_DOF);
m_DRTGeometryMetaInfo->SetHandleRotationImpOffset(eHandlingRotImpTransform::ALWAYS_USE);
optimizerObserver = CommandIterationUpdate::New(); optimizerObserver = CommandIterationUpdate::New();
ExhaustiveOptimizerObserver = ExhaustiveCommandIterationUpdate::New(); ExhaustiveOptimizerObserver = ExhaustiveCommandIterationUpdate::New();
@ -1114,18 +1128,20 @@ itkImageProcessor::GetFinalR23Parameters(){
break; break;
case SIX_DOF: case SIX_DOF:
pPars[0] = currentPosition[0] pPars[3] = 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]
- m_TransformMetaInfo->GetHiddenTranslations()[0]; - m_TransformMetaInfo->GetHiddenTranslations()[0];
pPars[4] = currentPosition[4] pPars[4] = currentPosition[1]
- m_TransformMetaInfo->GetHiddenTranslations()[1]; - m_TransformMetaInfo->GetHiddenTranslations()[1];
pPars[5] = currentPosition[5] pPars[5] = currentPosition[2]
- m_TransformMetaInfo->GetHiddenTranslations()[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; break;
default: default:
@ -1190,11 +1206,59 @@ void itkImageProcessor::SetMetric(std::string metric)
} }
void itkImageProcessor::SetMaxNumberOfIterations(int iNum) void itkImageProcessor::SetDegreeOfFreedom(tDegreeOfFreedomEnum dof){
{
m_r23MetaInfo->SetMaxIterations(iNum); 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() void itkImageProcessor::InitializeProjector()
{ {
@ -2523,15 +2587,18 @@ void itkImageProcessor::ResetROIRegions(){
} }
void itkImageProcessor::InizializeRegistration(double stepLength, void itkImageProcessor::InizializeRegistration(){
double maxTranslation,
eDegreeOfFreedomType dof){
m_r23MetaInfo->SetDegreeOfFreedom(dof);
m_R23->SetPA(m_PASourceDupli->GetOutput()); m_R23->SetPA(m_PASourceDupli->GetOutput());
m_R23->SetLAT(m_LATSourceDupli->GetOutput()); m_R23->SetLAT(m_LATSourceDupli->GetOutput());
m_R23->SetVolume(m_VolumeSourceDupli->GetOutput()); m_R23->SetVolume(m_VolumeSourceDupli->GetOutput());
m_R23->Setr23Meta(m_r23MetaInfo); 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->SetInternalTransf1(m_InternalTransf1);
m_R23->SetInternalTransf2(m_InternalTransf2); m_R23->SetInternalTransf2(m_InternalTransf2);
m_R23->Setfilter1(filter1); m_R23->Setfilter1(filter1);
@ -2540,8 +2607,7 @@ void itkImageProcessor::InizializeRegistration(double stepLength,
m_R23->Setinterpolator2(interpolator2); m_R23->Setinterpolator2(interpolator2);
m_R23->SetTransformMetaInfo(m_TransformMetaInfo); m_R23->SetTransformMetaInfo(m_TransformMetaInfo);
m_R23->InitializeRegistration( m_R23->InitializeRegistration();
stepLength,maxTranslation,dof);
} }

View File

@ -47,6 +47,7 @@ gfattori 08.11.2021
#include "itkImageProcessorHelpers.h" #include "itkImageProcessorHelpers.h"
#include "itkReg23.h" #include "itkReg23.h"
#include "itkReg23MetaInformation.h"
namespace itk namespace itk
{ {
@ -86,12 +87,9 @@ public:
void SetRegionFixed1(int,int,int,int); void SetRegionFixed1(int,int,int,int);
void SetRegionFixed2(int,int,int,int); void SetRegionFixed2(int,int,int,int);
void ResetROIRegions(); void ResetROIRegions();
void InizializeRegistration(double stepLength, void InizializeRegistration();
double maxTranslation,
eDegreeOfFreedomType dof);
/** Maximum number of iterations for the optimizer */ /** Maximum number of iterations for the optimizer */
void SetMaxNumberOfIterations(int);
itkGetMacro(R23, itkReg23::Pointer); itkGetMacro(R23, itkReg23::Pointer);
@ -103,6 +101,24 @@ public:
void SetMetric(std::string); void SetMetric(std::string);
void SetMetric(tMetricTypeEnum); 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*/ /** Set number of logic CPU to be made available to interpolators*/
void SetNumberOfWorkingUnits(int iN); void SetNumberOfWorkingUnits(int iN);
@ -390,6 +406,18 @@ private:
R23MetaInformation::Pointer R23MetaInformation::Pointer
m_r23MetaInfo; m_r23MetaInfo;
PowellOptimizerMetaInformation::Pointer
m_PowellOptimizerMetaInfo;
AmoebaOptimizerMetaInformation::Pointer
m_AmoebaOptimizerMetaInfo;
MIMetricMetaInformation::Pointer
m_MIMetricMetaInfo;
NCCMetricMetaInformation::Pointer
m_NCCMetricMetaInfo;
InternalTransformMetaInformation::Pointer InternalTransformMetaInformation::Pointer
m_InternalTransf1, m_InternalTransf1,
m_InternalTransf2; m_InternalTransf2;

View File

@ -100,6 +100,7 @@ CalculateInternalTransformV3(
const char* queryStationName(const char* pcFName){ const char* queryStationName(const char* pcFName){
static std::string buffer; static std::string buffer;
buffer.clear();
/* Check if we can open the file */ /* Check if we can open the file */
gdcm::Reader R; gdcm::Reader R;
@ -112,10 +113,8 @@ const char* queryStationName(const char* pcFName){
const gdcm::File &file = R.GetFile(); const gdcm::File &file = R.GetFile();
const gdcm::DataSet &ds = file.GetDataSet(); const gdcm::DataSet &ds = file.GetDataSet();
std::string s (gGetStringValueFromTag(gdcm::Tag(0x0008,0x1010), ds)); std::string s(gGetStringValueFromTag(gdcm::Tag(0x0008,0x1010), ds));
std::copy(s.rbegin(), s.rend(), std::back_inserter(buffer)); std::copy(s.begin(), s.end(), buffer.begin());
std::reverse(buffer.begin(),buffer.end());
return buffer.c_str(); return buffer.c_str();
@ -134,10 +133,12 @@ int query2DimageReconstructionDiameter(const char *pcFName){
const gdcm::File &file = R.GetFile(); const gdcm::File &file = R.GetFile();
const gdcm::DataSet &ds = file.GetDataSet(); const gdcm::DataSet &ds = file.GetDataSet();
char* sTmpString = new char [255]; std::string buffer;
strcpy( sTmpString,gGetStringValueFromTag(gdcm::Tag(0x0018,0x1100), ds));
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);
} }

View File

@ -13,6 +13,7 @@ itkReg23::itkReg23()
NCCmetric = MetricType::New(); NCCmetric = MetricType::New();
MImetric = MIMetricType::New(); MImetric = MIMetricType::New();
// Optimizers // Optimizers
PowellOptimizer = PowellOptimizerType::New(); PowellOptimizer = PowellOptimizerType::New();
AmoebaOptimizer = AmoebaOptimizerType::New(); AmoebaOptimizer = AmoebaOptimizerType::New();
@ -71,10 +72,7 @@ void itkReg23::PrintSelf(std::ostream& os, Indent indent) const
Superclass::PrintSelf(os, indent); Superclass::PrintSelf(os, indent);
} }
void itkReg23::InitializeRegistration( void itkReg23::InitializeRegistration()
double stepLength,
double maxTranslation,
eDegreeOfFreedomType dof)
{ {
std::cout << "*" << __COMPACT_PRETTY_FUNCTION__ << std::endl; std::cout << "*" << __COMPACT_PRETTY_FUNCTION__ << std::endl;
@ -126,6 +124,17 @@ void itkReg23::InitializeRegistration(
itkExceptionMacro(<< "m_interpolator2 data not present"); 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); AmoebaOptimizerType::ParametersType simplexDelta(3);
ExhaustiveOptimizerType::StepsType steps(3); ExhaustiveOptimizerType::StepsType steps(3);
const int numberOfSteps = 25; //In each direction. Total number of steps is ((2*numberOfSteps+1))^3. For 25 -> 132651. 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" <<std::endl; std::cout<< "Using POWELL Optimizer" <<std::endl;
PowellOptimizer->SetMaximize(false); // for NCC and MI PowellOptimizer->SetMaximize(false); // for NCC and MI
PowellOptimizer->SetMaximumIteration(m_r23Meta->GetMaxIterations()); PowellOptimizer->SetMaximumIteration(m_PowellMeta->GetMaxIterations());
PowellOptimizer->SetMaximumLineIteration(4); // for Powell's method PowellOptimizer->SetMaximumLineIteration(m_PowellMeta->GetMaximumLineInteration()); // for Powell's method
PowellOptimizer->SetStepLength(stepLength); PowellOptimizer->SetStepLength(m_PowellMeta->GetStepLength());
PowellOptimizer->SetStepTolerance(0.01); PowellOptimizer->SetStepTolerance(m_PowellMeta->GetStepTolerance());
PowellOptimizer->SetValueTolerance(0.000002); PowellOptimizer->SetValueTolerance(m_PowellMeta->GetValueTolerance());
PowellOptimizer->RemoveAllObservers(); PowellOptimizer->RemoveAllObservers();
PowellOptimizer->AddObserver(itk::IterationEvent(), m_OptimizerObserver); PowellOptimizer->AddObserver(itk::IterationEvent(), m_OptimizerObserver);
@ -153,17 +162,17 @@ void itkReg23::InitializeRegistration(
std::cout<< "Using AMOEBA Optimizer" <<std::endl; std::cout<< "Using AMOEBA Optimizer" <<std::endl;
AmoebaOptimizer->SetMinimize(true); AmoebaOptimizer->SetMinimize(true);
AmoebaOptimizer->SetMaximumNumberOfIterations(m_r23Meta->GetMaxIterations()); AmoebaOptimizer->SetMaximumNumberOfIterations(m_AmoebaMeta->GetMaxIterations());
AmoebaOptimizer->SetParametersConvergenceTolerance(0.1); AmoebaOptimizer->SetParametersConvergenceTolerance(m_AmoebaMeta->GetParametersConvergenceTolerance());
AmoebaOptimizer->SetFunctionConvergenceTolerance(0.000002); AmoebaOptimizer->SetFunctionConvergenceTolerance(m_AmoebaMeta->GetFunctionConvergenceTolerance());
AmoebaOptimizer->SetAutomaticInitialSimplex(false); AmoebaOptimizer->SetAutomaticInitialSimplex(false);
//Initial size of the simplex (otherwise it is a very small number and optimizer stops immeditaly) //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. // 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"); itkExceptionMacro(<< "Unkown or unsupported degree of freedom");
} }
for (int i = 0; i < GetNumberOfDOF(dof); i++) { for (int i = 0; i < GetNumberOfDOF(m_r23Meta->GetDegreeOfFreedom()); i++) {
simplexDelta[i] = 2.0; simplexDelta[i] = m_AmoebaMeta->GetSimplexDelta();
} }
AmoebaOptimizer->SetInitialSimplexDelta(simplexDelta); AmoebaOptimizer->SetInitialSimplexDelta(simplexDelta);
AmoebaOptimizer->RemoveAllObservers(); AmoebaOptimizer->RemoveAllObservers();
@ -176,13 +185,13 @@ void itkReg23::InitializeRegistration(
case tOptimizerTypeEnum::EXHAUSTIVE: case tOptimizerTypeEnum::EXHAUSTIVE:
std::cout<< "Using Extensive Optimizer" <<std::endl; std::cout<< "Using Extensive Optimizer" <<std::endl;
steps[0] = numberOfSteps; // steps[0] = numberOfSteps;
steps[1] = numberOfSteps; // steps[1] = numberOfSteps;
steps[2] = numberOfSteps; // steps[2] = numberOfSteps;
ExhaustiveOptimizer->SetNumberOfSteps(steps); // ExhaustiveOptimizer->SetNumberOfSteps(steps);
ExhaustiveOptimizer->SetStepLength(stepLength); // ExhaustiveOptimizer->SetStepLength(stepLength);
registration->SetOptimizer(ExhaustiveOptimizer); // registration->SetOptimizer(ExhaustiveOptimizer);
break; break;
@ -197,8 +206,9 @@ void itkReg23::InitializeRegistration(
std::cout<< "Using MI Metric" <<std::endl; std::cout<< "Using MI Metric" <<std::endl;
registration->SetMetric(MImetric); registration->SetMetric(MImetric);
MImetric->SetNumberOfHistogramBins(m_MIMeta->GetNumberOfHistogramBins());
MImetric->ComputeGradientOff(); MImetric->ComputeGradientOff();
MImetric->SetMaxTranslation(maxTranslation); MImetric->SetMaxTranslation(m_MIMeta->GetMaxTranslation());
break; break;
@ -207,7 +217,7 @@ void itkReg23::InitializeRegistration(
registration->SetMetric(NCCmetric); registration->SetMetric(NCCmetric);
NCCmetric->ComputeGradientOff(); NCCmetric->ComputeGradientOff();
NCCmetric->SetSubtractMean(true); NCCmetric->SetSubtractMean(true);
NCCmetric->SetMaxTranslation(maxTranslation); NCCmetric->SetMaxTranslation(m_NCCMeta->GetMaxTranslation());
break; break;

View File

@ -18,6 +18,8 @@
#include "itkImageProcessorHelpers.h" #include "itkImageProcessorHelpers.h"
#include "itkQtIterationUpdate.h" #include "itkQtIterationUpdate.h"
#include "itkReg23MetaInformation.h"
namespace itk{ namespace itk{
@ -50,6 +52,19 @@ public:
itkSetMacro(r23Meta, R23MetaInformation::Pointer); itkSetMacro(r23Meta, R23MetaInformation::Pointer);
itkGetMacro(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); itkSetMacro(Volume, InternalImageType::Pointer);
itkGetMacro(Volume, InternalImageType::Pointer); itkGetMacro(Volume, InternalImageType::Pointer);
@ -92,9 +107,7 @@ public:
/** Auto Reg23 methods */ /** Auto Reg23 methods */
/** Initialize the registration pipeline*/ /** Initialize the registration pipeline*/
void InitializeRegistration(double stepLength, void InitializeRegistration();
double maxTranslation,
eDegreeOfFreedomType dof);
/** Start the registration process*/ /** Start the registration process*/
int StartRegistration(std::string extraInfo); int StartRegistration(std::string extraInfo);
/** Get the current cost function value from the optimizer*/ /** Get the current cost function value from the optimizer*/
@ -151,6 +164,18 @@ private:
R23MetaInformation::Pointer R23MetaInformation::Pointer
m_r23Meta; m_r23Meta;
PowellOptimizerMetaInformation::Pointer
m_PowellMeta;
AmoebaOptimizerMetaInformation::Pointer
m_AmoebaMeta;
MIMetricMetaInformation::Pointer
m_MIMeta;
NCCMetricMetaInformation::Pointer
m_NCCMeta;
InternalImageType::Pointer InternalImageType::Pointer
m_Volume, m_Volume,
m_PA, m_PA,

View File

@ -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 ()
{
}
}

View File

@ -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<Self> 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<Self> 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<Self> 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<Self> 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