Commit fc3a4525 authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: added NumberOfIterations component setting and shortened some tests

by using 1 iteration (instead of default 100)
parent aa848e3c
......@@ -61,6 +61,28 @@ ItkGradientDescentOptimizerv4Component< InternalComputationValueType>
}
}
}
else if (criterion.first == "NumberOfIterations") //Supports this?
{
if (criterion.second.size() != 1)
{
meetsCriteria = false;
//itkExceptionMacro("The criterion Sigma may have only 1 value");
}
else
{
auto const & criterionValue = *criterion.second.begin();
try
{
this->m_Optimizer->SetNumberOfIterations(std::stoi(criterionValue));
meetsCriteria = true;
}
catch (itk::ExceptionObject & err)
{
//TODO log the error message?
meetsCriteria = false;
}
}
}
return meetsCriteria;
}
......
......@@ -220,6 +220,7 @@ TEST_F(RegistrationItkv4Test, WithANTSCCMetric)
ParameterMapType component5Parameters;
component5Parameters["NameOfClass"] = { "ItkGradientDescentOptimizerv4Component" };
component5Parameters["NumberOfIterations"] = { "1" };
blueprint->AddComponent("Optimizer", component5Parameters);
ParameterMapType connection1Parameters;
......@@ -303,6 +304,10 @@ TEST_F(RegistrationItkv4Test, WithMeanSquaresMetric)
component4Parameters["Dimensionality"] = { "3" }; // should be derived from the inputs
blueprint->AddComponent("Metric", component4Parameters);
ParameterMapType component5Parameters;
component5Parameters["NameOfClass"] = { "ItkGradientDescentOptimizerv4Component" };
component5Parameters["NumberOfIterations"] = { "1" };
blueprint->AddComponent("Optimizer", component5Parameters);
ParameterMapType connection1Parameters;
connection1Parameters["NameOfInterface"] = { "itkImageFixedInterface" };
......@@ -320,6 +325,10 @@ TEST_F(RegistrationItkv4Test, WithMeanSquaresMetric)
connection4Parameters["NameOfInterface"] = { "itkMetricv4Interface" };
blueprint->AddConnection("Metric", "RegistrationMethod", connection4Parameters);
ParameterMapType connection5Parameters;
connection5Parameters["NameOfInterface"] = { "itkOptimizerv4Interface" };
blueprint->AddConnection("Optimizer", "RegistrationMethod", connection5Parameters);
// Instantiate SuperElastix
SuperElastixFilterType::Pointer superElastixFilter;
EXPECT_NO_THROW(superElastixFilter = SuperElastixFilterType::New());
......@@ -392,6 +401,11 @@ TEST_F(RegistrationItkv4Test, DisplacementField)
component6Parameters["Dimensionality"] = { "3" }; // should be derived from the outputs
blueprint->AddComponent("TransformDisplacementFilter", component6Parameters);
ParameterMapType component7Parameters;
component7Parameters["NameOfClass"] = { "ItkGradientDescentOptimizerv4Component" };
component7Parameters["NumberOfIterations"] = { "1" };
blueprint->AddComponent("Optimizer", component7Parameters);
ParameterMapType connection1Parameters;
connection1Parameters["NameOfInterface"] = { "itkImageFixedInterface" };
blueprint->AddConnection("FixedImageSource", "RegistrationMethod", connection1Parameters);
......@@ -414,6 +428,7 @@ TEST_F(RegistrationItkv4Test, DisplacementField)
blueprint->AddConnection("RegistrationMethod", "TransformDisplacementFilter", { {} });
blueprint->AddConnection("FixedImageSource", "TransformDisplacementFilter", { {} });
blueprint->AddConnection("Optimizer", "RegistrationMethod", { {} });
// Instantiate SuperElastix
SuperElastixFilterType::Pointer superElastixFilter;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment