pythonitk

Python error: module 'itk' has no attribute 'ParameterObject'


I use ITK in python (https://itkpythonpackage.readthedocs.io/en/master/Quick_start_guide.html) and the package seems to work, but when I want to use a code I found on github (https://github.com/InsightSoftwareConsortium/ITKElastix/blob/master/wrapping/test/itkElastixRegistrationMethodTest.py) it gives me an error:

import itk
parameter_object = itk.ParameterObject.New()

module 'itk' has no attribute 'ParameterObject'

unfortunately I could not find out why my itk has no ParameterObject attribute, but I found other code that also used this attribute. I tried to upgrade itk:

Requirement already satisfied: itk in /.../miniconda3/lib/python3.9/site-packages (5.2.1.post1)

I am new to ITK and I am not quite sure what I did wrong, can someone help me?


Solution

  • You need ITKElastix. Get it via pip install itk-elastix.

    If you are building ITK from source, you need to build ITKElastix from source and point to the main ITK build.