3D multi-modal medical image registration using user defined function for similarity metric computation

You might be running into a mismatch between versions of ITK and SimpleITK. It is best to see which version of ITK SimpleITK’s superbuild uses.

1 Like

If you are rebuilding SimpleITK super build, and recently updated the source code from git, the ITK git tag may be out of sync. The easiest is to start with an empty build directly for the super build.

The ITK that I cloned from Github has GIT_TAG = c44a7731f22bd5d241ac8f9369018671800f5cd9, as mentioned in the ITK\.git\logs\HEAD file.

The GIT_TAG mentioned in SITK\SuperBuild\External_ITK.cmake file is ee664da6bb1a83cdf82e2582126e65119a4de1a4.

Where can I get ITK with GIT_TAG = ee664da6bb1a83cdf82e2582126e65119a4de1a4 ?

I cloned ITK from here and SimpleITK (SITK) from here

Hello @debapriya,

You already have it. This is just an older commit. You can branch off this commit add your new ITK code, build it and then point SimpleITK to that.

git branch new_branch_name ee664da6bb1a83cdf82e2582126e65119a4de1a4
git checkout new_branch_name

Thank you @zivy, @dzenanz and @blowekamp. I could match versions of ITK and SITK. I have configured and generated SITK, pointing to my modified version of ITK. While building SITK on Visual Studio 2019, however, a few errors are showing. Below is a screenshot of the error page.

As far as the last error is concerned, sitkDICOMOrientImageFilter.h is indeed not present anywhere in the SITK folder. I have no idea what the other errors mean. Please help.

Hello @debapriya,

When you say SITK folder, I assume you mean the SimpleITK source directory.

You will not find this file there because it is automatically generated from its json description (see figure 1 in “The Design of SimpleITK” paper for details).

You should be able to find it in your build directory (assuming you are doing an out of source build).

Yes, by SITK folder I meant the SimpleITK source directory. I am doing an out of source build. I checked the SITK build directory also. sitkDICOMOrientImageFilter.h is not generated.

In the CMakeCache.txt file, however, I found this line:

What might have gone wrong? Did I miss to put values in some variables during configuration?

This filter is contained in the ITK remote module “SimpleITKFilter”. The CMake variable “Module_SimpleITKFilters” should be set to ON in the ITK build to enable the remote module.

It is strongly recommended to use the SimpleITK Superbuild with the ITK configured for SimpleITK, you can see the Superbuild script here which may give some insights as to how to configure your ITK build manually.


Thank you @blowekamp . I could build SITK with 0 error this time :grinning:

I want to run 3D image registration codes in python, for example, the ones given in SITK tutorial jupyter notebook 05_basic_registration, but using my own metric.

Please tell me the process.

1 Like

Hello @debapriya,

If you followed the guidance from the post above, then all you need to do is replace the current SetMetricAsX invocation in the code with the one you have added.

Yes, I have done the changes given here.

My query is,
in SITK tutorial jupyter notebook, import SimpleITK as sitk, does not point to my modified SITK. How can I make it point to my modified version?

Hello @debapriya,

If you used the environment.yml or requirements.txt files that are part of the notebook repository to create a virtual environment, those will use/install an official SimpleITK version (>=2.1.0).

To install the custom SimpleITK version you built, activate the virtual environment and install as described here.

Done that. It is recognizing my metric now.
However, ModuleNotFoundError is showing for downloaddata, gui and registration_gui. Hence, I cannot see the output of registration.

Hello @debapriya,

Those are utility modules that are part of the SimpleITK jupyter notebook repository. Just copy them to the location where you have your notebook (assuming you are not working with a clone of the notebook repository - that should work out of the box without any changes in which case I’m not sure what is causing the problem).

It worked!! :innocent:

Thank you @zivy, @blowekamp and @dzenanz. Your help was vital at each step.


Congratulations on your success! :partying_face: :tada:

1 Like

I am trying to configure ITK and SimpleITK in another laptop (different configuration). I followed the same procedure as I did the previous time. ITK configuration happened smoothly. However, SimpleITK configuration is showing the following error

Please tell me what is going wrong.

That error message does not look familiar to me.

Have you tried creating a new and empty binary directory to do an initial configuration?

Source and Build directories for SimpleITK are respectively D:\SimpleITK and D:\SITK_Build

Source and Build directories for ITK are D:\ITK and D:\ITK_Build respectively.

Lua, Swig and GTest are located in D:\

Still I am getting same error.

I have been able to resolve the above error. I uninstalled CMake and Python, and reinstalled older versions of them (CMake 3.23.3 and Python 3.10.5). With these versions, no error is showing, though I do not know what actually went wrong.

However, I am stuck again. During Build Solution, I am getting out of memory error in Visual Studio 2022. I have tried a few solutions suggested on the internet, but none helped. Please help.