Changes In ITK Mattes Mutual Information Metric

If you started your modification from ITKv5 master, that’s the version you should get ImageRegistration4.cpp from. If you started from ITKv4, you should use examples from there. Preferably the exact same version.

Please copy-paste the entire error message.

Finally, the only files with word Tsallis in the name on my computer are related to itk::JensenHavrdaCharvatTsallisPointSet. Which version of ITK are you working with, and where did you get it?

Sorry… I did not make my goals much clear.
I’m inserting other entropy definitions, instead of Shannon’s Entropy (in Mattes classes). I guess I made a complete mess with ITK versions.*

I just downloaded .h and .hxx from master… But I guess now I’ll have to build the ITKv5… Did not realize all that until now.

The screenshot I posted in the earlier message refers to my edited classes. Makes completely no sense since they are part from ItkV5, part from Itkv4. I just compared with the ones in master and I got all that. Hence, the error messages has no much meaning.

I’ll make the proper corrections and let you know if it did work.

Thanks again!

@dzenanz,

I double-checked all the files. I downloaded the Master folder from Git and then built that. Then, I realized that the examples’ folder do not contain Registration ITK5, only the ITK4-fashion examples. Am I correct?
Is there any set of ITK5 Registration examples?

There are two registration frameworks. They are currently called v3 and v4. v4 was introduced with version 4, v3 existed prior to version 4. Both are still supported. But you can’t really mix classes from these two frameworks.

v3 is simpler, v4 is more flexible and powerful. Pick one, and go entirely with that one.

I got it. So, I picked the .h and .hxx classes from ITK master, which is ITK5, I suppose. Therein, I found Registration V4, it means they are compatible. Is that right?

Thanks!

v4 classes are mostly in Registration/Metricsv4, while v3 classes are mostly in Registration/Common. There was no significant registration refactoring between ITKv4 and ITKv5. But registration was affected by multi-threading refactoring done in v5 [migration guide].

Fine. Now, I guess I can do it right. Thanks!

Hey Guys!!!
A lotta progress down here! Thank you guys again for the help. I would not give any step without it!

Now, I am trying to understand the way through which the .hxx class calculates the (jointPDF) derivatives.
I’m a bit confuse.
And why exactly it needs a gradient Image In this process…
Do I have access to the marginal moving PDF derivative according to the parameters?

Thanks.

@hjmjohnson might know that. Also you could look at the blame for the file to see who has been editing it.

You mean at git hub?

You could look at the files’ blame on your local computer. But yes, GitHub has an integrated blame tool as well.

I’m not familiar with that tool. I looked it over, but did not get the point.
How can I use blame to help me?
Thanks again!

Looking at the blame tells you that @stnava contributed to that class. If you can find more people who wrote the class, they might be able to help you better than me.

Auhh, I got it!
Makes sense!
Yeah lets see if anyone else can help me!
Thanks.

@dzenanz, can you please confirm the following question:

1- The bool member (this->m_UseExplicitPDFDerivatives) means that it will use b-spline functions as the kernel density function when it is TRUE? I’m guessing that because the papers say that b-splines have explicit derivatives.

I don’t know. Somebody else might know :smiley:

That’s ok… Hahah that code is a lot of organized mess!

@dzenanz, I’m getting further.
I need to understand the this->m_UseExplicitPDFDerivatives, but it is not so demanding right now.

Now, I need to know some aspects related to C++ and ITK architecture. If you can help me again, I’ll be grateful.

1 - I need to know how to pass an additional variable to the metric class (.hxx) from my main .cpp during the execution. The new entropy needs an additional variable x. And I want to send the x value during the execution.

2 - I created the new .h and .hxx by editing itkMattes[…].h and itkMattes[…].h.
Now, I include the new .h class in the beggining of the main file (.cpp) and create the objects and so on… everything nice and smooth. But, in the main class, when I set the metric to the registration object, it shows an error:

ImageRegistration4.cxx:153: error: no matching function for call to 
‘itk::ImageRegistrationMethodv4<itk::Image<float, 2u>, itk::Image<float, 2u>, 
itk::TranslationTransform<double, 2u> 
>::SetMetric(itk::MachadoMutualInformationImageToImageMetric<itk::Image<float, 2u>, 
itk::Image<float, 2u> >::Pointer&)’
registration->SetMetric(metric);
                              ^

Thanks again!

  1. make m_X a member, and add public setter and getter (SetX and GetX). You can use macros for that.
  2. your metric must derive from ObjectToObjectMetricBaseTemplate. MattesMutualInformationImageToImageMetricv4 derives from ImageToImageMetricv4, which derives from ObjectToObjectMetric, which derives from ObjectToObjectMetricBaseTemplate.

Beware that MattesMutualInformationImageToImageMetric (without v4 in the name) derives from ImageToImageMetric, which derives from SingleValuedCostFunction, which derives from CostFunction, which derives from CostFunctionTemplate, which derives from Object. This means that v4 registration framework is largely incompatible with v3 framework.

1 Like

Perfect. I’ll work on those details carefully.
I thought I was already sure that I was working with V4 versions, but now I have to double check.

make m_X a member, and add public setter and getter ( SetX and GetX ). You can use [macros] for that.

You mean, create a variable in the “.h” class and create getters and setters in both “.h” and “.hxx” classes?

I’ll work on that.
Thanks!