diff --git a/Components/Transforms/AffineLogStackTransform/elxAffineLogStackTransform.hxx b/Components/Transforms/AffineLogStackTransform/elxAffineLogStackTransform.hxx index 4d0f63df7..5906961b6 100644 --- a/Components/Transforms/AffineLogStackTransform/elxAffineLogStackTransform.hxx +++ b/Components/Transforms/AffineLogStackTransform/elxAffineLogStackTransform.hxx @@ -21,6 +21,7 @@ #include "elxAffineLogStackTransform.h" #include "itkImageRegionExclusionConstIteratorWithIndex.h" +#include #include namespace elastix @@ -100,11 +101,12 @@ AffineLogStackTransform::ReadFromFile() { if (!this->HasITKTransformParameters()) { + const Configuration & configuration = itk::Deref(Superclass2::GetConfiguration()); + /** Read stack-spacing, stack-origin and number of sub-transforms. */ - this->GetConfiguration()->ReadParameter( - m_NumberOfSubTransforms, "NumberOfSubTransforms", this->GetComponentLabel(), 0, 0); - this->GetConfiguration()->ReadParameter(m_StackOrigin, "StackOrigin", this->GetComponentLabel(), 0, 0); - this->GetConfiguration()->ReadParameter(m_StackSpacing, "StackSpacing", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_NumberOfSubTransforms, "NumberOfSubTransforms", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_StackOrigin, "StackOrigin", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_StackSpacing, "StackSpacing", this->GetComponentLabel(), 0, 0); ReducedDimensionInputPointType RDcenterOfRotationPoint{}; @@ -184,17 +186,19 @@ AffineLogStackTransform::InitializeTransform() SizeType fixedImageSize = this->m_Registration->GetAsITKBaseType()->GetFixedImage()->GetLargestPossibleRegion().GetSize(); + const Configuration & configuration = itk::Deref(Superclass2::GetConfiguration()); + for (unsigned int i = 0; i < ReducedSpaceDimension; ++i) { /** Check COR index: Returns zero when parameter was in the parameter file. */ - bool foundI = this->m_Configuration->ReadParameter(centerOfRotationIndex[i], "CenterOfRotation", i, false); + bool foundI = configuration.ReadParameter(centerOfRotationIndex[i], "CenterOfRotation", i, false); if (!foundI) { centerGivenAsIndex = false; } /** Check COR point: Returns zero when parameter was in the parameter file. */ - bool foundP = this->m_Configuration->ReadParameter(RDcenterOfRotationPoint[i], "CenterOfRotationPoint", i, false); + bool foundP = configuration.ReadParameter(RDcenterOfRotationPoint[i], "CenterOfRotationPoint", i, false); if (!foundP) { centerGivenAsPoint = false; @@ -207,7 +211,7 @@ AffineLogStackTransform::InitializeTransform() */ bool automaticTransformInitialization = false; bool tmpBool = false; - this->m_Configuration->ReadParameter(tmpBool, "AutomaticTransformInitialization", 0); + configuration.ReadParameter(tmpBool, "AutomaticTransformInitialization", 0); if (tmpBool && this->Superclass1::GetInitialTransform() == nullptr) { automaticTransformInitialization = true; @@ -270,17 +274,19 @@ template void AffineLogStackTransform::SetScales() { + const Configuration & configuration = itk::Deref(Superclass2::GetConfiguration()); + /** Create the new scales. */ const NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); ScalesType newscales(numberOfParameters); /** Check if automatic scales estimation is desired. */ bool automaticScalesEstimation = false; - this->m_Configuration->ReadParameter(automaticScalesEstimation, "AutomaticScalesEstimation", 0); + configuration.ReadParameter(automaticScalesEstimation, "AutomaticScalesEstimation", 0); /** Check also AutomaticScalesEstimationStackTransform for backwards compatability. */ bool automaticScalesEstimationStackTransform = false; - this->m_Configuration->ReadParameter( + configuration.ReadParameter( automaticScalesEstimationStackTransform, "AutomaticScalesEstimationStackTransform", 0, false); if (automaticScalesEstimationStackTransform) @@ -327,7 +333,7 @@ AffineLogStackTransform::SetScales() const unsigned int rotationPart = (ReducedSpaceDimension) * (ReducedSpaceDimension); const unsigned int totalPart = (SpaceDimension) * (ReducedSpaceDimension); - /** this->m_Configuration->ReadParameter() returns 0 if there is a value given + /** configuration.ReadParameter() returns 0 if there is a value given * in the parameter-file, and returns 1 if there is no value given in the * parameter-file. * Check which option is used: @@ -343,7 +349,7 @@ AffineLogStackTransform::SetScales() int sizeLastDimension = this->GetElastix()->GetFixedImage()->GetLargestPossibleRegion().GetSize()[SpaceDimension - 1]; - std::size_t count = this->m_Configuration->CountNumberOfParameterEntries("Scales"); + std::size_t count = configuration.CountNumberOfParameterEntries("Scales"); /** Check which of the above options is used. */ if (count == 0) @@ -363,7 +369,7 @@ AffineLogStackTransform::SetScales() { /** In this case the second option is used. */ double scale = defaultScalingvalue; - this->m_Configuration->ReadParameter(scale, "Scales", 0); + configuration.ReadParameter(scale, "Scales", 0); newscales.Fill(scale); /** The non-rotation scales are set to 1.0 */ @@ -379,7 +385,7 @@ AffineLogStackTransform::SetScales() /** In this case the third option is used. */ for (unsigned int i = 0; i < numberOfParameters; ++i) { - this->m_Configuration->ReadParameter(newscales[i], "Scales", i); + configuration.ReadParameter(newscales[i], "Scales", i); } } else diff --git a/Components/Transforms/BSplineStackTransform/elxBSplineStackTransform.hxx b/Components/Transforms/BSplineStackTransform/elxBSplineStackTransform.hxx index ed1ad9c7b..ebcfd1bc1 100644 --- a/Components/Transforms/BSplineStackTransform/elxBSplineStackTransform.hxx +++ b/Components/Transforms/BSplineStackTransform/elxBSplineStackTransform.hxx @@ -21,6 +21,7 @@ #include "elxBSplineStackTransform.h" #include "itkImageRegionExclusionConstIteratorWithIndex.h" +#include #include namespace elastix @@ -224,16 +225,18 @@ BSplineStackTransform::PreComputeGridInformation() * Which is the default schedule, if no GridSpacingSchedule is supplied. */ + const Configuration & configuration = itk::Deref(Superclass2::GetConfiguration()); + /** Determine which method is used. */ bool method1 = false; - std::size_t count1 = this->m_Configuration->CountNumberOfParameterEntries("FinalGridSpacingInVoxels"); + std::size_t count1 = configuration.CountNumberOfParameterEntries("FinalGridSpacingInVoxels"); if (count1 > 0) { method1 = true; } bool method2 = false; - std::size_t count2 = this->m_Configuration->CountNumberOfParameterEntries("FinalGridSpacingInPhysicalUnits"); + std::size_t count2 = configuration.CountNumberOfParameterEntries("FinalGridSpacingInPhysicalUnits"); if (count2 > 0) { method2 = true; @@ -257,7 +260,7 @@ BSplineStackTransform::PreComputeGridInformation() { for (unsigned int dim = 0; dim < ReducedSpaceDimension; ++dim) { - this->m_Configuration->ReadParameter( + configuration.ReadParameter( finalGridSpacingInVoxels[dim], "FinalGridSpacingInVoxels", this->GetComponentLabel(), dim, 0); } @@ -274,7 +277,7 @@ BSplineStackTransform::PreComputeGridInformation() { for (unsigned int dim = 0; dim < ReducedSpaceDimension; ++dim) { - this->m_Configuration->ReadParameter( + configuration.ReadParameter( finalGridSpacingInPhysicalUnits[dim], "FinalGridSpacingInPhysicalUnits", this->GetComponentLabel(), dim, 0); } } @@ -285,7 +288,7 @@ BSplineStackTransform::PreComputeGridInformation() m_GridScheduleComputer->GetSchedule(gridSchedule); /** Read what the user has specified. This overrules everything. */ - count2 = this->m_Configuration->CountNumberOfParameterEntries("GridSpacingSchedule"); + count2 = configuration.CountNumberOfParameterEntries("GridSpacingSchedule"); unsigned int entry_nr = 0; if (count2 == 0) { @@ -297,7 +300,7 @@ BSplineStackTransform::PreComputeGridInformation() { for (unsigned int dim = 0; dim < ReducedSpaceDimension; ++dim) { - this->m_Configuration->ReadParameter(gridSchedule[res][dim], "GridSpacingSchedule", entry_nr, false); + configuration.ReadParameter(gridSchedule[res][dim], "GridSpacingSchedule", entry_nr, false); } ++entry_nr; } @@ -308,7 +311,7 @@ BSplineStackTransform::PreComputeGridInformation() { for (unsigned int dim = 0; dim < ReducedSpaceDimension; ++dim) { - this->m_Configuration->ReadParameter(gridSchedule[res][dim], "GridSpacingSchedule", entry_nr, false); + configuration.ReadParameter(gridSchedule[res][dim], "GridSpacingSchedule", entry_nr, false); ++entry_nr; } } @@ -444,16 +447,17 @@ BSplineStackTransform::ReadFromFile() { if (!this->HasITKTransformParameters()) { + const Configuration & configuration = itk::Deref(Superclass2::GetConfiguration()); + /** Read spline order settings and initialize BSplineTransform. */ m_SplineOrder = 3; - this->GetConfiguration()->ReadParameter( - m_SplineOrder, "BSplineTransformSplineOrder", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_SplineOrder, "BSplineTransformSplineOrder", this->GetComponentLabel(), 0, 0); /** Read stack-spacing, stack-origin and number of sub-transforms. */ - bool dummy = this->GetConfiguration()->ReadParameter( - m_NumberOfSubTransforms, "NumberOfSubTransforms", this->GetComponentLabel(), 0, 0); - dummy |= this->GetConfiguration()->ReadParameter(m_StackOrigin, "StackOrigin", this->GetComponentLabel(), 0, 0); - dummy |= this->GetConfiguration()->ReadParameter(m_StackSpacing, "StackSpacing", this->GetComponentLabel(), 0, 0); + bool dummy = + configuration.ReadParameter(m_NumberOfSubTransforms, "NumberOfSubTransforms", this->GetComponentLabel(), 0, 0); + dummy |= configuration.ReadParameter(m_StackOrigin, "StackOrigin", this->GetComponentLabel(), 0, 0); + dummy |= configuration.ReadParameter(m_StackSpacing, "StackSpacing", this->GetComponentLabel(), 0, 0); /** Initialize the right B-spline transform. */ this->InitializeBSplineTransform(); @@ -475,13 +479,13 @@ BSplineStackTransform::ReadFromFile() /** Get GridSize, GridIndex, GridSpacing and GridOrigin. */ for (unsigned int i = 0; i < ReducedSpaceDimension; ++i) { - dummy |= this->m_Configuration->ReadParameter(gridsize[i], "GridSize", i); - dummy |= this->m_Configuration->ReadParameter(gridindex[i], "GridIndex", i); - dummy |= this->m_Configuration->ReadParameter(gridspacing[i], "GridSpacing", i); - dummy |= this->m_Configuration->ReadParameter(gridorigin[i], "GridOrigin", i); + dummy |= configuration.ReadParameter(gridsize[i], "GridSize", i); + dummy |= configuration.ReadParameter(gridindex[i], "GridIndex", i); + dummy |= configuration.ReadParameter(gridspacing[i], "GridSpacing", i); + dummy |= configuration.ReadParameter(gridorigin[i], "GridOrigin", i); for (unsigned int j = 0; j < ReducedSpaceDimension; ++j) { - this->m_Configuration->ReadParameter(griddirection(j, i), "GridDirection", i * ReducedSpaceDimension + j); + configuration.ReadParameter(griddirection(j, i), "GridDirection", i * ReducedSpaceDimension + j); } } diff --git a/Components/Transforms/EulerStackTransform/elxEulerStackTransform.hxx b/Components/Transforms/EulerStackTransform/elxEulerStackTransform.hxx index 4f878b3d2..027d8b206 100644 --- a/Components/Transforms/EulerStackTransform/elxEulerStackTransform.hxx +++ b/Components/Transforms/EulerStackTransform/elxEulerStackTransform.hxx @@ -19,6 +19,7 @@ #define elxEulerStackTransform_hxx #include "elxEulerStackTransform.h" +#include namespace elastix { @@ -96,11 +97,12 @@ EulerStackTransform::ReadFromFile() { if (!this->HasITKTransformParameters()) { + const Configuration & configuration = itk::Deref(Superclass2::GetConfiguration()); + /** Read stack-spacing, stack-origin and number of sub-transforms. */ - this->GetConfiguration()->ReadParameter( - m_NumberOfSubTransforms, "NumberOfSubTransforms", this->GetComponentLabel(), 0, 0); - this->GetConfiguration()->ReadParameter(m_StackOrigin, "StackOrigin", this->GetComponentLabel(), 0, 0); - this->GetConfiguration()->ReadParameter(m_StackSpacing, "StackSpacing", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_NumberOfSubTransforms, "NumberOfSubTransforms", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_StackOrigin, "StackOrigin", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_StackSpacing, "StackSpacing", this->GetComponentLabel(), 0, 0); ReducedDimensionInputPointType RDcenterOfRotationPoint{}; @@ -163,6 +165,7 @@ template void EulerStackTransform::InitializeTransform() { + const Configuration & configuration = itk::Deref(Superclass2::GetConfiguration()); /** Set all parameters to zero (no rotations, no translation). */ m_DummySubTransform->SetIdentity(); @@ -185,15 +188,14 @@ EulerStackTransform::InitializeTransform() for (unsigned int i = 0; i < ReducedSpaceDimension; ++i) { /** Check COR index: Returns zero when parameter was in the parameter file. */ - const bool foundI = this->m_Configuration->ReadParameter(centerOfRotationIndex[i], "CenterOfRotation", i, false); + const bool foundI = configuration.ReadParameter(centerOfRotationIndex[i], "CenterOfRotation", i, false); if (!foundI) { centerGivenAsIndex = false; } /** Check COR point: Returns zero when parameter was in the parameter file. */ - const bool foundP = - this->m_Configuration->ReadParameter(redDimCenterOfRotationPoint[i], "CenterOfRotationPoint", i, false); + const bool foundP = configuration.ReadParameter(redDimCenterOfRotationPoint[i], "CenterOfRotationPoint", i, false); if (!foundP) { centerGivenAsPoint = false; @@ -221,7 +223,7 @@ EulerStackTransform::InitializeTransform() /** FIX: why may the cop not work when using direction cosines? */ bool UseDirectionCosines = true; - this->m_Configuration->ReadParameter(UseDirectionCosines, "UseDirectionCosines", 0); + configuration.ReadParameter(UseDirectionCosines, "UseDirectionCosines", 0); if (!UseDirectionCosines) { log::info(std::ostringstream{} @@ -325,6 +327,7 @@ template void EulerStackTransform::SetScales() { + const Configuration & configuration = itk::Deref(Superclass2::GetConfiguration()); /** Create the new scales. */ const NumberOfParametersType numberOfParameters = this->GetNumberOfParameters(); @@ -332,11 +335,11 @@ EulerStackTransform::SetScales() /** Check if automatic scales estimation is desired. */ bool automaticScalesEstimation = false; - this->m_Configuration->ReadParameter(automaticScalesEstimation, "AutomaticScalesEstimation", 0); + configuration.ReadParameter(automaticScalesEstimation, "AutomaticScalesEstimation", 0); /** Check also AutomaticScalesEstimationStackTransform for backwards compatability. */ bool automaticScalesEstimationStackTransform = false; - this->m_Configuration->ReadParameter( + configuration.ReadParameter( automaticScalesEstimationStackTransform, "AutomaticScalesEstimationStackTransform", 0, false); if (automaticScalesEstimationStackTransform) @@ -382,7 +385,7 @@ EulerStackTransform::SetScales() const unsigned int numRotationParsPerDimension = ReducedSpaceDimension == 2 ? 1 : 3; const unsigned int numTotalParsPerDimension = ReducedSpaceDimension == 2 ? 3 : 6; - /** this->m_Configuration->ReadParameter() returns 0 if there is a value given + /** configuration.ReadParameter() returns 0 if there is a value given * in the parameter-file, and returns 1 if there is no value given in the * parameter-file. * @@ -399,7 +402,7 @@ EulerStackTransform::SetScales() const int sizeLastDimension = this->GetElastix()->GetFixedImage()->GetLargestPossibleRegion().GetSize()[SpaceDimension - 1]; - std::size_t count = this->m_Configuration->CountNumberOfParameterEntries("Scales"); + std::size_t count = configuration.CountNumberOfParameterEntries("Scales"); /** Check which of the above options is used. */ if (count == 0) @@ -421,7 +424,7 @@ EulerStackTransform::SetScales() { /** In this case the second option is used. */ double scale = defaultScalingvalue; - this->m_Configuration->ReadParameter(scale, "Scales", 0); + configuration.ReadParameter(scale, "Scales", 0); newscales.Fill(scale); /** The non-rotation scales are set to 1.0 for all dimensions */ @@ -440,7 +443,7 @@ EulerStackTransform::SetScales() /** In this case the third option is used. */ for (unsigned int i = 0; i < numberOfParameters; ++i) { - this->m_Configuration->ReadParameter(newscales[i], "Scales", i); + configuration.ReadParameter(newscales[i], "Scales", i); } } else diff --git a/Components/Transforms/TranslationStackTransform/elxTranslationStackTransform.hxx b/Components/Transforms/TranslationStackTransform/elxTranslationStackTransform.hxx index d6bc2a848..fb12d3dfe 100644 --- a/Components/Transforms/TranslationStackTransform/elxTranslationStackTransform.hxx +++ b/Components/Transforms/TranslationStackTransform/elxTranslationStackTransform.hxx @@ -21,6 +21,7 @@ #include "elxTranslationStackTransform.h" #include "itkImageRegionExclusionConstIteratorWithIndex.h" +#include #include namespace elastix @@ -125,11 +126,12 @@ TranslationStackTransform::ReadFromFile() if (!this->HasITKTransformParameters()) { + const Configuration & configuration = itk::Deref(Superclass2::GetConfiguration()); + /** Read stack-spacing, stack-origin and number of sub-transforms. */ - this->GetConfiguration()->ReadParameter( - m_NumberOfSubTransforms, "NumberOfSubTransforms", this->GetComponentLabel(), 0, 0); - this->GetConfiguration()->ReadParameter(m_StackOrigin, "StackOrigin", this->GetComponentLabel(), 0, 0); - this->GetConfiguration()->ReadParameter(m_StackSpacing, "StackSpacing", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_NumberOfSubTransforms, "NumberOfSubTransforms", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_StackOrigin, "StackOrigin", this->GetComponentLabel(), 0, 0); + configuration.ReadParameter(m_StackSpacing, "StackSpacing", this->GetComponentLabel(), 0, 0); /** Initialize translation transform. */ InitializeTranslationTransform();