I have a similarity metric that I’d like to use in ImageRegistrationMethod in itk python, is there any way to do so?
Hi @sedghi,
Yes. If it is an existing method in ITK, it can be used from Python with the ImageRegistrationMethod.
If it is a new method you created your self, you can quickly wrap it in Python, and create an installable Python Package. More information:
- The ITK Module Template. This will get you going with a skeleton module in two commands.
- The ITK Software Guide’s chapter on How to Create A Module. This includes instruction on how to add wrapping.
Please let us know if you have any questions.
Thanks @matt
actually my custom made metric is implemented in python. Do I still need to create an installable python package?
@matt.mccormick
I was wondering if there is any update on this issue?
Is there any python callable (function) for the optimizer interface right now?
@sedghi There is not a python callable (function) interface to supply your own method right now, but that is a great idea. @pieper has been thinking about it, too.
I don’t think it is that hard to implement. What do you think about an itk.PythonImageRegistrationMetricv4 class? This class would be similar to itk.ImageToImageMetricv4, but it would have additional methods,
GetValuePythonCallbackGetDerivativePythonCallbackGetValueAndDerivativePythonCallback
These methods would be passed Python functions that accept the ImageToImageMetricv4 as an argument and would need to return required value and derivative values.
Sounds great @matt.mccormick! Yes, @sedghi and I worked together looking into this so hopefully he can let us know if these methods would be enough to cover the use case.
Any progress on this front?
I created this issue for tracking:
Note that we have similar functionality to define an image filter in Python: