Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metric outcome "AdvancedNormalizedCorrelation" -1 for the same images #1185

Closed
han050 opened this issue Jul 4, 2024 · 5 comments
Closed

Comments

@han050
Copy link

han050 commented Jul 4, 2024

I am experiencing an issue with the AdvancedNormalizedCorrelation metric in elastix. Specifically, the metric consistently returns a value of -1, even when the input images are identical. Given that the images are exactly the same, I would expect the metric to return a value of 1, indicating perfect correlation.

I have tried multiple combinations of parameters in the parameter file. However, the metric outcome remains -1. One of the parameter files is given below.

I would appreciate any insights or suggestions on why the AdvancedNormalizedCorrelation metric might be returning -1 for identical images and how to resolve this issue. Is there a known bug, or are there additional configurations or steps I might be missing?

Thank you in advance!

Example of parameter file:

(FixedInternalImagePixelType "float")
(MovingInternalImagePixelType "float")
(FixedImageDimension 3)
(MovingImageDimension 3)

(Registration "MultiResolutionRegistration")
(Transform "TranslationTransform")
(Metric "AdvancedNormalizedCorrelation")
(Optimizer "AdaptiveStochasticGradientDescent")
(Interpolator "LinearInterpolator")

(ImageSampler "Full")

(NumberOfResolutions 1)
(ImagePyramidSchedule 1 1 1)

(MaximumNumberOfIterations 10)

// Output settings
(WriteResultImage "true")
(ResultImageFormat "mhd")

// Debugging options
(WriteTransformParametersEachIteration "true")
(WriteResultImageAfterEachResolution "true")
(WriteLogFile "true")
(LogToConsole "true")
(LogToFile "true")

@N-Dekker
Copy link
Member

N-Dekker commented Jul 4, 2024

Interesting! I do indeed see the text appear, saying:

Final metric value = -1

@mstaring
Copy link
Member

mstaring commented Jul 4, 2024

Since elastix, like ITK, only minimizes an objective, the objective is here the negative correlation. Same for mutual information.

@N-Dekker
Copy link
Member

N-Dekker commented Jul 5, 2024

OK, thanks @mstaring so -1 means 100% correlation. @han050 Does that answer your question?

@han050
Copy link
Author

han050 commented Jul 8, 2024

Thank you both for your quick response. As I understand it, a correlation coefficient of -1 indicates a perfect negative correlation, meaning that low intensity values in scan 1 correspond to high intensity values in scan 2, and vice versa. However, given that the inputs are two identical CT scans with the same HU values (the same intensity values), I would expect a perfect positive correlation, which would be indicated by a correlation coefficient of 1.

Therefore, I am still confused about how the outcome could be -1 instead of 1 in this context. Can you provide further clarification on why this might be happening or do I misunderstand the answer of @mstaring?

Thanks again!

@jasper-tms
Copy link

A correlation coefficient of 1 (two identical images) means the correlation metric will be -1. The key is understanding that the correlation metric is not the correlation coefficient, it's the negative of it.

As Marius mentioned, the reason for this is that optimizers are typically built to minimize things. In order to maximize a correlation, you ask the optimizer to try to minimize the correlation metric (which is just the negative of the correlation coefficient). By minimizing the correlation metric, the optimizer will maximize the image correlation, which is what you want.

@han050 han050 closed this as completed Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants