Installation of ITKElastix with pip

Hello!

I tried to look into ITKElastix. As posted on the repository, I did

pip install itk-elastix

but I also installed TubeTK, ITKStrain, SciPy, Scikit-image and Scikit-learn

pip install itk-tubetk itk-strain
pip install scipy
pip install scikit-image scikit-learn

The last command gave me

ERROR: imageio 2.17.0 has requirement pillow>=8.3.2, but you'll have pillow 7.0.0 which is incompatible.
ERROR: tifffile 2022.4.22 has requirement numpy>=1.19.2, but you'll have numpy 1.17.4 which is incompatible.

Thus, I upgraded

pip install -U pillow
pip install -U numpy

Now, I have these (among others):

itk                       5.3rc4              
itk-core                  5.3rc4              
itk-elastix               0.13.0              
itk-filtering             5.3rc4              
itk-io                    5.3rc4              
itk-minimalpathextraction 1.2.0               
itk-numerics              5.3rc4              
itk-registration          5.3rc4              
itk-segmentation          5.3rc4              
itk-strain                0.3.5               
itk-tubetk                1.1
numpy                     1.22.3
Pillow                    9.1.0
scikit-image              0.19.2              
scikit-learn              1.0.2               
scipy                     1.8.0

However (or may be because of that), I get this error:

registered_image, params = itk.elastix_registration_method(fixed_image, moving_image)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/edgar/.local/lib/python3.8/site-packages/itk/support/lazy.py", line 138, in __getattribute__
    base.itk_load_swig_module(module, namespace)
  File "/home/edgar/.local/lib/python3.8/site-packages/itk/support/base.py", line 96, in itk_load_swig_module
    itk_load_swig_module(dep, namespace)
  File "/home/edgar/.local/lib/python3.8/site-packages/itk/support/base.py", line 96, in itk_load_swig_module
    itk_load_swig_module(dep, namespace)
  File "/home/edgar/.local/lib/python3.8/site-packages/itk/support/base.py", line 92, in itk_load_swig_module
    l_data = itk_base_global_module_data[name]
KeyError: 'ITKImageSources'

What should I try to make it work? Thanks!

Newer numpy shouldn’t be a problem for ITK. I think we require 1.20.3 or something. What I suggest is uninstall ITK, then manually remove all the mentions of it in relevant site-packages, and then install again. If this doesn’t fix it, try it again, but with version 5.2.1.

1 Like

Oh, ok. I was getting an error message from itk-tubetk about the version. This is what worked for me:

# Uninstall current ITK packages
pip uninstall itk-elastix itk-tubetk itk-strain itk itk-core itk-filtering itk-io itk-minimalpathextraction itk-numerics itk-registration itk-segmentation
# Upgrade pip (to enable pip cache purge)
pip install -U pip
# Get rid of pip cache
pip cache purge
# Re-install ITK, ITKElastix and TubeTK (a version compatible with ITK: 5.2 is the latest on pip, and itk-tubetk 1.1 requires 5.3)
pip install itk{,-{elastix,strain,tubetk==1.0.0}}

Thank you (:

2 Likes