Skip to content

Commit

Permalink
STYLE: FUTURE_LEGACY_REMOVE ImageToImageMetric::m_TransformIsBSpline
Browse files Browse the repository at this point in the history
m_TransformIsBSpline is just equal to `m_BSplineTransform != nullptr`,
so it is redundant and not really necessary.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Mar 17, 2024
1 parent 8515928 commit 2ff0480
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Modules/Registration/Common/include/itkImageToImageMetric.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,12 @@ class ITK_TEMPLATE_EXPORT ImageToImageMetric : public SingleValuedCostFunction
* only inspecting the parameters within the support region
* of a mapped point. */

/** Boolean to indicate if the transform is BSpline deformable. */
#ifndef ITK_FUTURE_LEGACY_REMOVE
/** Boolean to indicate if the transform is BSpline deformable.
\deprecated `m_TransformIsBSpline` is intended to be removed, in the future. Please use `m_BSplineTransform`
instead. For example, `if (m_TransformIsBSpline)` may be rewritten as `if (m_BSplineTransform)`. */
bool m_TransformIsBSpline{ false };
#endif

/** The number of BSpline transform weights is the number of
* of parameter in the support region (per dimension ). */
Expand Down
16 changes: 10 additions & 6 deletions Modules/Registration/Common/include/itkImageToImageMetric.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,9 @@ ImageToImageMetric<TFixedImage, TMovingImage>::MultiThreadingInitialize()
// [3] Precomputing the indices of the parameters within the
// the support region of each sample point.
//
m_TransformIsBSpline = true;

auto * testPtr2 = dynamic_cast<BSplineTransformType *>(this->m_Transform.GetPointer());
if (!testPtr2)
{
m_TransformIsBSpline = false;
m_BSplineTransform = nullptr;
itkDebugMacro("Transform is not BSplineDeformable");
}
Expand All @@ -386,7 +383,11 @@ ImageToImageMetric<TFixedImage, TMovingImage>::MultiThreadingInitialize()
itkDebugMacro("Transform is BSplineDeformable");
}

if (this->m_TransformIsBSpline)
#ifndef ITK_FUTURE_LEGACY_REMOVE
m_TransformIsBSpline = m_BSplineTransform != nullptr;
#endif

if (m_BSplineTransform)
{
// First, deallocate memory that may have been used from previous run of the Metric
this->m_BSplineTransformWeightsArray.SetSize(1, 1);
Expand Down Expand Up @@ -772,7 +773,7 @@ ImageToImageMetric<TFixedImage, TMovingImage>::TransformPoint(unsigned int
transform = this->m_Transform;
}

if (!m_TransformIsBSpline)
if (!m_BSplineTransform)
{
// Use generic transform to compute mapped position
mappedPoint = transform->TransformPoint(m_FixedImageSamples[sampleNumber].point);
Expand Down Expand Up @@ -882,7 +883,7 @@ ImageToImageMetric<TFixedImage, TMovingImage>::TransformPointWithDerivatives(uns
transform = this->m_Transform;
}

if (!m_TransformIsBSpline)
if (!m_BSplineTransform)
{
// Use generic transform to compute mapped position
mappedPoint = transform->TransformPoint(m_FixedImageSamples[sampleNumber].point);
Expand Down Expand Up @@ -1257,7 +1258,10 @@ ImageToImageMetric<TFixedImage, TMovingImage>::PrintSelf(std::ostream & os, Inde
os << indent << "UseSequentialSampling: " << (m_UseSequentialSampling ? "On" : "Off") << std::endl;
os << indent << "ReseedIterator: " << (m_ReseedIterator ? "On" : "Off") << std::endl;
os << indent << "RandomSeed: " << m_RandomSeed << std::endl;

#ifndef ITK_FUTURE_LEGACY_REMOVE
os << indent << "TransformIsBSpline: " << (m_TransformIsBSpline ? "On" : "Off") << std::endl;
#endif

os << indent
<< "NumBSplineWeights: " << static_cast<typename NumericTraits<SizeValueType>::PrintType>(m_NumBSplineWeights)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ MattesMutualInformationImageToImageMetric<TFixedImage, TMovingImage>::ComputePDF
precomputedWeight = this->m_PRatioArray[pdfFixedIndex][pdfMovingIndex];
}

if (!this->m_TransformIsBSpline)
if (!this->m_BSplineTransform)
{
/**
* Generic version which works for all transforms.
Expand Down

0 comments on commit 2ff0480

Please sign in to comment.