MattesMutualInformationImageToImageMetricv4 sampling heuristics

As has been discussed on the ANTs issue tracker https://github.com/ANTsX/ANTs/issues/543, the existing heuristics for the MI overlap are not very good.

Right now, its based on a ratio of points at https://github.com/hinerm/ITK/blob/master/Modules/Registration/Metricsv4/include/itkMattesMutualInformationImageToImageMetricv4.hxx#L218

This really a good heuristic as it makes the success/failure depend on things like having an uncropped image with lots of background (where the background is unimportant). It also causes failures where you want to use a mask to do some finer adjustments to an affine registration to match specific anatomy, but the mask is “too small” according to the fraction.

The idea as a replacement is something based on the size/number of samples for the joint histogram.

I’d like to open this up for discussion as to how to implement.

Too many samples map outside of [something] is message quite a few people have encountered. Mostly it appears when the initial transformation for registration is wrong, but sometimes simply because overlap is not big enough. An improvement to that would be welcome. I have not participated in writing the metric so I am a bit short on implementation proposals.

Indeed @dzenanz this is specifically address the point where the overlap is very good by either manual or some other initialization, but due to this heuristic the registration bails out.

Another way to understand the problem here is, if I had resampled the images and cropped them rather than passing the initialization and mask into the registration, it would work, but because I’ve doing this in the middle of the pipeline, ratio heuristic bails out.

@stnava has proposed a fix for this:

http://review.source.kitware.com/#/c/23580/

Wow, well that’s totally the simplest implementation. Clearly one sample wouldn’t actually work, but is it work figuring out the range 1-N where Mattes fails, or is this fix good enough.

I’m down for just accepting this.

xref: https://github.com/InsightSoftwareConsortium/ITK/pull/49

Yes, agreed – it is a good step forward.

Thanks to Brian for proposing a patch.