InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.41k stars 663 forks source link

Class to enable a custom image similarity metric defined in Python #1411

Open thewtex opened 4 years ago

thewtex commented 4 years ago

Description

Enable creation of a custom similarity metric in Python. See the discussion here:

https://discourse.itk.org/t/is-there-a-way-to-set-custom-metric-in-itk-registration-in-python/705/7

Expected behavior

A convenient way to define an image similarity metric in Python that re-uses the ITK image registration frame, i.e. optimizers, transformations, multi-resolution capabilities, regularization.

Actual behavior

The registration metric must be implemented in C++.

Additional Information

Possible implementation:

An itk.PythonImageRegistrationMetricv4 class would be similar to itk.ImageToImageMetricv4, but it would have additional methods,

These methods would be passed Python functions that accept the ImageToImageMetricv4 as an argument and would need to return required value and derivative values.

See also the class for defining a custom ITK filter in Python:

https://github.com/InsightSoftwareConsortium/ITK/blob/master/Wrapping/Generators/Python/PyUtils/itkPyImageFilter.h

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

JaroKuiken commented 5 months ago

Hi developers, for my thesis I would like to perform registration with my own custom metric (Frechet distance function). I have looked around online and this issue seems to be the only place that really mentions anything close to what I want. Though I have been using SimpleITK and not ITK itself. I see that this has been on the backlog for some years, do you think that this will by any chance be finished soon? Or if not, does anyone have a suggestion on an alternative method I could use?

zivy commented 5 months ago

Hello @JaroKuiken,

This discussion describes how to add a metric to ITK and then to SimpleITK. Unfortunately, it requires implementation in C++ and you appear to be looking for a path forward in Python. If you are able to implement it in C++ then you have an immediate path forward. If not, I don't think the timeline for this feature will be short enough so that you can use it in your work. I may be wrong here, @thewtex will have a better idea with respect to timeline for ITK 6.0.0.