SuperElastix / elastix

Official elastix repository
http://elastix.dev
Apache License 2.0
483 stars 118 forks source link

Multiple metrics and regularization #481

Open alvarez-pa opened 3 years ago

alvarez-pa commented 3 years ago

Hello all,

I would like to use a combination of two image-based metrics and a regularization term for the elastic registration of CT lung images. This is defined in the elastix parameter file as follows:

(Registration "MultiMetricMultiResolutionRegistration")
(Metric "AdvancedNormalizedCorrelation" "AdvancedNormalizedCorrelation" "TransformBendingEnergyPenalty")

(FixedImagePyramid "FixedRecursiveImagePyramid" "FixedRecursiveImagePyramid")
(MovingImagePyramid "MovingRecursiveImagePyramid" "MovingRecursiveImagePyramid")
(ImageSampler "Random" "Random")
(Interpolator "BSplineInterpolator" "BSplineInterpolator")

I provide elastix with two moving images (-m0 -m1) and two fixed images (-f0 -f1) as well as the typical input/output parameters, but I obtain an error at execution:

Description: itk::ERROR: itk::ERROR: MultiMetricMultiResolutionRegistration(0000025A5C22BED0): The NumberOfInterpolators should equal 1 or equal the NumberOfMetrics

If I try to add interpolator, image sampler and image pyramid descriptions for the penalty term it gives me another error:

Description: itk::ERROR: FixedRecursivePyramid(000002A2B81755C0): Input Primary is required but not set.

I have implemented this multi metric with penalization feature by adding some logic to count separately the "image based", "transformation based" and "point set based" metrics. This allows to check for the number of image pyramids and interpolators according to the specified metrics, since it seems to me that such components are needed only for the "image based" metrics.

I will make a pull request with a link to this issue to facilitate tracking.

Best,

N-Dekker commented 3 years ago

@alvarez-pa Thank you for your carefully written issue and pull request, Pablo! We will have a closer look this month. As it appears such a fundamental issue, we may need some more time.

ishaanb92 commented 1 year ago

Hello all,

I seem to have run into the same issue! I want to provide Elastix with multi-channel data (-f0 ... -f5 and -m0 ... -m5) and want to use two regularizers (transform bending penalty and corresponding points penalty) alongside an image similarity metric (normalized mutual information).

I understand it might be hard to merge the fix described within a stable release. I was wondering if @alvarez-pa had a compiled binary with his local fix that could be shared. Thanks in advance!

Cheers, Ishaan

alvarez-pa commented 1 year ago

Hello @ishaanb92,

I do not have access anymore to the machine where I compiled Elastix with the fix to this problem. Therefore, I unfortunately cannot give you any binaries. However, you may try to recompile the code yourself with the fix applied.

If you decide to recompile, you may proceed in two ways:

There may be other ways, but those are the two I am aware of. I hope it helps.

Best, Pablo