Skip to content

Commit

Permalink
PERF: Call FastEvaluateMovingImageValueAndDerivative in 6 more metrics
Browse files Browse the repository at this point in the history
Replace `this->EvaluateMovingImageValueAndDerivative(...)` calls by `this->FastEvaluateMovingImageValueAndDerivative(..., threadId)` in the "Threaded" member functions of six more metrics:

    itkAdvancedKappaStatisticImageToImageMetric
    itkAdvancedMeanSquaresImageToImageMetric
    itkParzenWindowHistogramImageToImageMetric
    itkParzenWindowMutualInformationImageToImageMetric
    itkPCAMetric_F_multithreaded
    itkSumSquaredTissueVolumeDifferenceImageToImageMetric

Expected a significant performance gain on the run-time duration.

Follow-up to pull request #556 commit c8c4a6a "PERF: Make AdvancedNormalizedCorrelationImageToImageMetric faster"
  • Loading branch information
N-Dekker committed Nov 27, 2021
1 parent 9462491 commit 00e810e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ ParzenWindowHistogramImageToImageMetric<TFixedImage, TMovingImage>::ThreadedComp
*/
if (sampleOk)
{
sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr);
sampleOk = this->FastEvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr, threadId);
}

if (sampleOk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,8 @@ AdvancedKappaStatisticImageToImageMetric<TFixedImage, TMovingImage>::ThreadedGet
MovingImageDerivativeType movingImageDerivative;
if (sampleOk)
{
sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative);
sampleOk = this->FastEvaluateMovingImageValueAndDerivative(
mappedPoint, movingImageValue, &movingImageDerivative, threadId);
}

/** Do the actual calculation of the metric value. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ ParzenWindowMutualInformationImageToImageMetric<TFixedImage, TMovingImage>::Thre
*/
if (sampleOk)
{
sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative);
sampleOk = this->FastEvaluateMovingImageValueAndDerivative(
mappedPoint, movingImageValue, &movingImageDerivative, threadId);
}

if (sampleOk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ AdvancedMeanSquaresImageToImageMetric<TFixedImage, TMovingImage>::ThreadedGetVal
*/
if (sampleOk)
{
sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr);
sampleOk = this->FastEvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr, threadId);
}

if (sampleOk)
Expand Down Expand Up @@ -677,7 +677,8 @@ AdvancedMeanSquaresImageToImageMetric<TFixedImage, TMovingImage>::ThreadedGetVal
*/
if (sampleOk)
{
sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative);
sampleOk = this->FastEvaluateMovingImageValueAndDerivative(
mappedPoint, movingImageValue, &movingImageDerivative, threadId);
}

if (sampleOk)
Expand Down
4 changes: 2 additions & 2 deletions Components/Metrics/PCAMetric/itkPCAMetric_F_multithreaded.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ PCAMetric<TFixedImage, TMovingImage>::ThreadedGetSamples(ThreadIdType threadId)
if (sampleOk)

{
sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr);
sampleOk = this->FastEvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr, threadId);
}

if (sampleOk)
Expand Down Expand Up @@ -991,7 +991,7 @@ PCAMetric<TFixedImage, TMovingImage>::ThreadedComputeDerivative(ThreadIdType thr
this->GetFixedImage()->TransformContinuousIndexToPhysicalPoint(voxelCoord, fixedPoint);
this->TransformPoint(fixedPoint, mappedPoint);

this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative);
this->FastEvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative, threadId);

/** Get the TransformJacobian dT/dmu */
this->EvaluateTransformJacobian(fixedPoint, jacobian, nzjis);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ SumSquaredTissueVolumeDifferenceImageToImageMetric<TFixedImage, TMovingImage>::T
*/
if (sampleOk)
{
sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr);
sampleOk = this->FastEvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, nullptr, threadId);
}

if (sampleOk)
Expand Down Expand Up @@ -581,7 +581,7 @@ SumSquaredTissueVolumeDifferenceImageToImageMetric<TFixedImage, TMovingImage>::T
*/
if (sampleOk)
{
sampleOk = this->EvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative);
sampleOk = this->FastEvaluateMovingImageValueAndDerivative(mappedPoint, movingImageValue, &movingImageDerivative, threadId);
}

if (sampleOk)
Expand Down

0 comments on commit 00e810e

Please sign in to comment.