Skip to content

Commit

Permalink
STYLE: FUTURE_LEGACY_REMOVE ImageToImageMetric::m_InterpolatorIsBSpline
Browse files Browse the repository at this point in the history
m_InterpolatorIsBSpline is just equal to `m_BSplineInterpolator != nullptr`,
so it is redundant and not really necessary.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Mar 17, 2024
1 parent db9cfea commit 8515928
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 6 additions & 1 deletion Modules/Registration/Common/include/itkImageToImageMetric.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,13 @@ class ITK_TEMPLATE_EXPORT ImageToImageMetric : public SingleValuedCostFunction
ImageDerivativesType & movingImageGradient,
ThreadIdType threadId) const;

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

/** Pointer to BSplineInterpolator. */
typename BSplineInterpolatorType::Pointer m_BSplineInterpolator{};

Expand Down
16 changes: 9 additions & 7 deletions Modules/Registration/Common/include/itkImageToImageMetric.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,9 @@ ImageToImageMetric<TFixedImage, TMovingImage>::MultiThreadingInitialize()
// Otherwise, we instantiate an external central difference
// derivative calculator.
//
m_InterpolatorIsBSpline = true;

auto * testPtr = dynamic_cast<BSplineInterpolatorType *>(this->m_Interpolator.GetPointer());
if (!testPtr)
{
m_InterpolatorIsBSpline = false;

m_DerivativeCalculator = DerivativeFunctionType::New();
m_DerivativeCalculator->UseImageDirectionOn();

Expand All @@ -360,6 +356,10 @@ ImageToImageMetric<TFixedImage, TMovingImage>::MultiThreadingInitialize()
itkDebugMacro("Interpolator is BSpline");
}

#ifndef ITK_FUTURE_LEGACY_REMOVE
m_InterpolatorIsBSpline = m_BSplineInterpolator != nullptr;
#endif

//
// Check if the transform is of type BSplineTransform.
//
Expand Down Expand Up @@ -839,7 +839,7 @@ ImageToImageMetric<TFixedImage, TMovingImage>::TransformPoint(unsigned int
sampleOk = sampleOk && m_MovingImageMask->IsInsideInWorldSpace(mappedPoint);
}

if (m_InterpolatorIsBSpline)
if (m_BSplineInterpolator)
{
// Check if mapped point inside image buffer
sampleOk = sampleOk && m_BSplineInterpolator->IsInsideBuffer(mappedPoint);
Expand Down Expand Up @@ -951,7 +951,7 @@ ImageToImageMetric<TFixedImage, TMovingImage>::TransformPointWithDerivatives(uns
sampleOk = sampleOk && m_MovingImageMask->IsInsideInWorldSpace(mappedPoint);
}

if (m_InterpolatorIsBSpline)
if (m_BSplineInterpolator)
{
// Check if mapped point inside image buffer
sampleOk = sampleOk && m_BSplineInterpolator->IsInsideBuffer(mappedPoint);
Expand Down Expand Up @@ -980,7 +980,7 @@ ImageToImageMetric<TFixedImage, TMovingImage>::ComputeImageDerivatives(const Mov
ImageDerivativesType & gradient,
ThreadIdType threadId) const
{
if (m_InterpolatorIsBSpline)
if (m_BSplineInterpolator)
{
// Computed moving image gradient using derivative BSpline kernel.
gradient = m_BSplineInterpolator->EvaluateDerivative(mappedPoint, threadId);
Expand Down Expand Up @@ -1301,7 +1301,9 @@ ImageToImageMetric<TFixedImage, TMovingImage>::PrintSelf(std::ostream & os, Inde
os << "(null)" << std::endl;
}

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

itkPrintSelfObjectMacro(BSplineInterpolator);
itkPrintSelfObjectMacro(DerivativeCalculator);
Expand Down

0 comments on commit 8515928

Please sign in to comment.