I'm performing image registration with simpleITK (python) using ImageRegistrationMethod.Execute()
approach.
The purpose is to collect some statistics of the image registration process (e.g. find out when it succeeds and when it fails), so I initialize the ImageRegistrationMethod
instance with different initial transformations, including ones that will not lead to registration success.
Upon execution simpleITK would sometimes throw an exception, which is fine, since I can catch that. But sometimes I get warnings in stderr like this
WARNING: In /mnt/emptyplaceholder/projects/elastix/build/ITK-prefix/include/ITK-4.12/itkObjectToObjectMetric.hxx, line 529
Self (0x3a0af70): No valid points were found during metric evaluation. For image metrics, verify that the images overlap appropriately. For instance, you can align the image centers by translation. For point-set metrics, verify that the fixed points, once transformed into the virtual domain space, actually lie within the virtual domain.
or this
WARNING: In /mnt/emptyplaceholder/projects/elastix/build/ITK-prefix/include/ITK-4.12/itkCorrelationImageToImageMetricv4HelperThreader.hxx, line 85
CorrelationImageToImageMetricv4HelperThreader (0x3a01370): collected only zero points
but registration proceeds.
The question is how can I distinguish (from python) instances when registration went completely smoothly from such cases with warnings. A simple and stupid option is to monitor stderr, but maybe there is some ITK functionality to report these occurrences?