ChangeInformationImageFilter missing from Pip-installed ITK 5.3rc4post3

When I try to use ChangeInformationImageFilter I get attributeError: module 'itk' has no attribute 'ChangeInformationImageFilter' after upgrading to ITK5.3rc4. I’m trying to use it with code that worked with 5.2.1.

I ran pip install --upgrade --pre itk
and the Python code is basically:

import itk
import numpy as np
.
.
.
// create 3d numpy array  named image3d
itkimage =  itk.GetImageFromArray(image3d)
change_filter = itk.ChangeInformationImageFilter.New(itkimage)

Full error:

Traceback (most recent call last):
  File "C:\Users\mchinander\Documents\Python\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3457, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-6-1f555431e995>", line 1, in <module>
    change_filter = itk.ChangeInformationImageFilter(itkimage)
  File "C:\Users\mchinander\Documents\Python\venv\lib\site-packages\itk\support\lazy.py", line 131, in __getattribute__
    value = types.ModuleType.__getattribute__(self, attr)
AttributeError: module 'itk' has no attribute 'ChangeInformationImageFilter'

Was it intentionally removed? According to the C++ documentation, the filter still exists in 5.3. Is there a workaround available or should I just downgrade to 5.2.1?

The usual problem here is some leftover of earlier versions. Purging all traces of ITK from Lib/site-packages (including manual browsing and deletions, just pip uninstall itk is usually not enough), and then pip install --upgrade --pre itk should fix that.

1 Like

Thanks, that (deleting the itk directory in Lib/site-packages after pip uninstalling the previous itk version) seems to have worked.

1 Like