From 3ec09e5744e6c097b171af58195c3c4a0d66017f Mon Sep 17 00:00:00 2001 From: stnava Date: Sat, 2 Jun 2018 19:45:07 -0400 Subject: [PATCH 1/2] PERF: less strict heuristic for valid points check The previous check was overly strict. For example, one may be using a small mask (e.g. hippocampus) to focus registration within a much larger image. The registration result can be valid in this case despite a relatively small number of points used. Another alternative to this request would be to remove this check entirely. --- .../itkMattesMutualInformationImageToImageMetricv4.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx index b905ba1cb7b..88d8e1898e9 100644 --- a/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx @@ -228,9 +228,9 @@ MattesMutualInformationImageToImageMetricv4GetNumberOfDomainPoints(); - if( this->GetNumberOfValidPoints() < numberOfPoints / 16 ) + if( this->GetNumberOfValidPoints() < this->m_NumberOfHistogramBins ) { - itkExceptionMacro("Too many samples map outside moving image buffer. There are only " + itkWarningMacro("Too many samples map outside moving image buffer. There are only " << this->m_NumberOfValidPoints << " valid points out of " << numberOfPoints << " total points. The images do not sufficiently " "overlap. They need to be initialized to have more overlap before this " From b3b6802953126e0f107eaaabdd3c539f600d88b7 Mon Sep 17 00:00:00 2001 From: stnava Date: Sun, 3 Jun 2018 09:59:53 -0400 Subject: [PATCH 2/2] PERF: Only throw exception if zero valid points I found some examples that work well with very few valid points at low resolution. Thus, I think this check should only be enforced when there are zero valid points. --- .../itkMattesMutualInformationImageToImageMetricv4.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx b/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx index 88d8e1898e9..4121f275dfd 100644 --- a/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx +++ b/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx @@ -228,9 +228,9 @@ MattesMutualInformationImageToImageMetricv4GetNumberOfDomainPoints(); - if( this->GetNumberOfValidPoints() < this->m_NumberOfHistogramBins ) + if( this->GetNumberOfValidPoints() == 0 ) { - itkWarningMacro("Too many samples map outside moving image buffer. There are only " + itkExceptionMacro("Too many samples map outside moving image buffer. There are only " << this->m_NumberOfValidPoints << " valid points out of " << numberOfPoints << " total points. The images do not sufficiently " "overlap. They need to be initialized to have more overlap before this "