[Elastix] How to use UseComplement in MultiMetric scenarios

Fitze Thomas (fitz) fitz at zhaw.ch
Thu Apr 23 14:12:38 CEST 2015


Alright, i figured it out. For some reason i did assume the complement should be negative, which of course it is not as stated in the documentation: http://elastix.isi.uu.nl/doxygen/classelastix_1_1AdvancedKappaStatisticMetric.html

Thank your for your patience,
Thomas

On 23.04.2015, at 13:55, Fitze Thomas (fitz) <fitz at zhaw.ch<mailto:fitz at zhaw.ch>> wrote:

Thank you very much for your answers. But this does not seem to work. Consider this config:

(FixedInternalImagePixelType "short")
(MovingInternalImagePixelType "short")
(FixedImageDimension 3)
(MovingImageDimension 3)
(UseDirectionCosines "true")

// Main Components
(Registration "MultiMetricMultiResolutionRegistration")
(Transform "AffineTransform")

// Multiresolution
(FixedImagePyramid "FixedSmoothingImagePyramid" "FixedSmoothingImagePyramid")
(MovingImagePyramid "MovingSmoothingImagePyramid" "MovingSmoothingImagePyramid")
(NumberOfResolutions 3 )
(ImagePyramidSchedule 4 4 1  2 2 1  1 1 1 )

// initial transformation
(AutomaticScalesEstimation "true")
(AutomaticTransformInitialization "true")
(AutomaticTransformInitializationMethod "GeometricalCenter")
(HowToCombineTransforms "Compose")

// ******************* Optimizer ****************************
(Optimizer "AdaptiveStochasticGradientDescent")
(MaximumNumberOfIterations 1000)
(MaximumStepLength 10.0)

// ****************** Metric *********************
(Metric "AdvancedMattesMutualInformation" "AdvancedKappaStatistic")
(UseForegroundValue "false")
(Metric0UseComplement "false")
(Metric1UseComplement "true")
(Metric0Weight 0.75)
(Metric1Weight 0.25)
(NumberOfHistogramBins 64)
(ErodeMask "false")

// **************** Image sampling **********************
(NumberOfSpatialSamples 10000)
(ImageSampler "RandomCoordinate" "RandomCoordinate")
(NewSamplesEveryIteration "true")
(CheckNumberOfSamples "false")

// ************* Interpolation and Resampling ****************
(Interpolator "LinearInterpolator" "NearestNeighborInterpolator")
(ResampleInterpolator "FinalBSplineInterpolator" "FinalBSplineInterpolator")
(Resampler "DefaultResampler" "DefaultResampler")
(BSplineInterpolationOrder 1)
(FinalBSplineInterpolationOrder 3)
(FixedImageBSplineInterpolationOrder 3)
(DefaultPixelValue 0)
(WriteResultImage "true")
(ResultImagePixelType "short")
(ResultImageFormat "nrrd”)

Running this, i’ll get log output like the following:
1:ItNr 2:Metric 2:Metric0 2:Metric1 3a:Time 3b:StepSize 4:||Gradient0|| 4:||Gradient1|| 4:||Gradient|| Time0[ms] Time1[ms] Time[ms]
0 -0.303953 -0.529348 0.372231 0.000000 51.907354 0.965093 0.090056 0.019009

Note how Metric1 is positive.

What am i doing wrong?

PS: Sorry for the duplicate mail Stefan, i missclicked

Cheers,
Thomas

On 22.04.2015, at 22:00, S. Klein <s.klein at erasmusmc.nl<mailto:s.klein at erasmusmc.nl>> wrote:

In fact the default value for this parameter is "true", so you could just omit it.

In the theorteical case that you would want to specify it different for each metric, it works like this:

(Metric0UseComplement "false")
(Metric1UseComplement "true")
(Metric2UseComplement "false")

etc.
So you add a prefix. This works for most parameters.

Cheers,
Stefan

On 22-4-2015 19:29, Polfliet Mathias wrote:
The KappaStatistic is always a positive value between 0 and 1. Since all optimisers try to minimise the metric value it is a good idea to set the UseComplement to "true". In the case of no foreground alignment, the KappaStatistic would return 0 and increase to 1 for a perfect registration if the UseComplement is set to "false". The solution to your problem would be:

(UseComplement "true”)

Since the AdvancedMattesMutualInformation metric does not have this option/setting.

With kind regards,

Mathias Polfliet


On 22 Apr 2015, at 17:11, Fitze Thomas (fitz) <fitz at zhaw.ch<mailto:fitz at zhaw.ch>> wrote:

Hi there!

Im trying to do a multi metric registration with (Metric "AdvancedMattesMutualInformation" "AdvancedKappaStatistic”). As far as i understand those 2 metric, i’ll have to use the complement of the KappaStatistic but not of the MMI. I tried to do this by using (UseComplement "false" "true”), but it appears that this does not work. The registration log always reports metric 2 as positive value, regardless of the UseComplement setting.

Am i doing this wrong? Here’s the full config:
(FixedInternalImagePixelType "short")
(MovingInternalImagePixelType "short")
(FixedImageDimension 3)
(MovingImageDimension 3)
(UseDirectionCosines "true")

// Main Components
(Registration "MultiMetricMultiResolutionRegistration")
(Transform "AffineTransform")

// Multiresolution
(FixedImagePyramid "FixedSmoothingImagePyramid" "FixedSmoothingImagePyramid")
(MovingImagePyramid "MovingSmoothingImagePyramid" "MovingSmoothingImagePyramid")
(NumberOfResolutions 3 )
(ImagePyramidSchedule 4 4 1  2 2 1  1 1 1 )

// initial transformation
(AutomaticScalesEstimation "true")
(AutomaticTransformInitialization "true")
(AutomaticTransformInitializationMethod "GeometricalCenter")
//(HowToCombineTransforms "Compose")
(HowToCombineTransforms "Add")

// ******************* Optimizer ****************************
(Optimizer "AdaptiveStochasticGradientDescent")
(MaximumNumberOfIterations 500)
(MaximumStepLength 10.0)

// ****************** Metric *********************
(Metric "AdvancedMattesMutualInformation" "AdvancedKappaStatistic")
(UseForegroundValue "false")
(UseComplement "false" "true")
(UseRelativeWeights "false")
(Metric0Weight 0.3)
(Metric1Weight 0.7)
(NumberOfHistogramBins 32)
(ErodeMask "false")

// **************** Image sampling **********************
(NumberOfSpatialSamples 10000)
(ImageSampler "RandomCoordinate" "RandomCoordinate")
(UseRandomSampleRegion "false")
(NewSamplesEveryIteration "true")
(CheckNumberOfSamples "false")

// ************* Interpolation and Resampling ****************
(Interpolator "LinearInterpolator" "NearestNeighborInterpolator")
(ResampleInterpolator "FinalBSplineInterpolator" "FinalBSplineInterpolator")
(Resampler "DefaultResampler" "DefaultResampler")
(BSplineInterpolationOrder 1)
(FinalBSplineInterpolationOrder 3)
(FixedImageBSplineInterpolationOrder 3)
(DefaultPixelValue 0)
(WriteResultImage "true")
(ResultImagePixelType "short")
(ResultImageFormat "nrrd”)

And this is the CLI call:
elastix -f0 ${FIX_IMGP0} -f1 ${FIX_IMGP1} -m0 ${MOV_IMGP0} -m1 ${MOV_IMGP1} -p Affine.txt -out "${DATA_RESULT}0"

Thanks,
Thomas
_______________________________________________
Elastix mailing list
Elastix at bigr.nl<mailto:Elastix at bigr.nl>
http://lists.bigr.nl/cgi-bin/mailman/listinfo/elastix




_______________________________________________
Elastix mailing list
Elastix at bigr.nl<mailto:Elastix at bigr.nl>
http://lists.bigr.nl/cgi-bin/mailman/listinfo/elastix


_______________________________________________
Elastix mailing list
Elastix at bigr.nl<mailto:Elastix at bigr.nl>
http://lists.bigr.nl/cgi-bin/mailman/listinfo/elastix

_______________________________________________
Elastix mailing list
Elastix at bigr.nl<mailto:Elastix at bigr.nl>
http://lists.bigr.nl/cgi-bin/mailman/listinfo/elastix

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bigr.nl/pipermail/elastix/attachments/20150423/fd823f77/attachment-0001.html>


More information about the Elastix mailing list