InsightSoftwareConsortium / ITKElastix

An ITK Python interface to elastix, a toolbox for rigid and nonrigid registration of images
Apache License 2.0
213 stars 23 forks source link

Issue with image format #283

Closed omaghsoudi closed 7 months ago

omaghsoudi commented 7 months ago

Everything was working for me, but I tried to install pandas and itk on top of itk-elastix. I kept getting error for opening parameter file. But If fixed the problem using your suggestions: itk-elastix==0.19.1 itk==5.4rc2

But now the code which was working getting error if I provide UC format:

    _, transform_parameters = itk.elastix_registration_method(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/elastix2/lib/python3.11/site-packages/itk/support/helpers.py", line 176, in image_filter_wrapper
    return image_filter(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/elastix2/lib/python3.11/site-packages/itk/itkElastixRegistrationMethodPython.py", line 756, in elastix_registration_method
    instance = itk.ElastixRegistrationMethod.New(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/elastix2/lib/python3.11/site-packages/itk/support/template_class.py", line 734, in New
    raise itk.TemplateTypeError(self, input_type)
itk.support.extras.TemplateTypeError: itk.ElastixRegistrationMethod is not wrapped for input type `None`.

To limit the size of the package, only a limited number of
types are available in ITK Python. To print the supported
types, run the following command in your python environment:

    itk.ElastixRegistrationMethod.GetTypes()

Possible solutions:
* If you are an application user:
** Convert your input image into a supported format (see below).
** Contact developer to report the issue.
* If you are an application developer, force input images to be
loaded in a supported pixel type.

    e.g.: instance = itk.ElastixRegistrationMethod[itk.Image[itk.F,2], itk.Image[itk.F,2]].New(my_input)

* (Advanced) If you are an application developer, build ITK Python yourself and
turned to `ON` the corresponding CMake option to wrap the pixel type or image
dimension you need. When configuring ITK with CMake, you can set
`ITK_WRAP_${type}` (replace ${type} with appropriate pixel type such as
`double`). If you need to support images with 4 or 5 dimensions, you can add
these dimensions to the list of dimensions in the CMake variable
`ITK_WRAP_IMAGE_DIMS`.

Supported input types:

itk.Image[itk.F,2]
itk.Image[itk.F,3]
itk.Image[itk.F,4]
itk.Image[itk.D,2]
itk.Image[itk.D,3]
itk.Image[itk.D,4]

python-BaseException

AND if I provide the float image, I get this error:

Traceback (most recent call last):
  File "/home/ubuntu/github/radutils/examples/register_image_mask_itk.py", line 307, in <module>
    _run_workflow(
  File "/home/ubuntu/github/radutils/examples/register_image_mask_itk.py", line 251, in _run_workflow
    transformed_rigid_images_list = _run_registration_on_image_mask_label(
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/github/radutils/examples/register_image_mask_itk.py", line 143, in _run_registration_on_image_mask_label
    _, transform_parameters = itk.elastix_registration_method(
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/elastix2/lib/python3.11/site-packages/itk/support/helpers.py", line 176, in image_filter_wrapper
    return image_filter(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/elastix2/lib/python3.11/site-packages/itk/itkElastixRegistrationMethodPython.py", line 756, in elastix_registration_method
    instance = itk.ElastixRegistrationMethod.New(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/elastix2/lib/python3.11/site-packages/itk/support/template_class.py", line 735, in New
    return self[list(keys)[0]].New(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/elastix2/lib/python3.11/site-packages/itk/itkElastixRegistrationMethodPython.py", line 626, in New
    template_class.New(obj, *args, **kargs)
  File "/opt/conda/envs/elastix2/lib/python3.11/site-packages/itk/support/template_class.py", line 800, in New
    itk.set_inputs(self, args, kargs)
  File "/opt/conda/envs/elastix2/lib/python3.11/site-packages/itk/support/extras.py", line 1580, in set_inputs
    attrib(itk.output(value))
TypeError: Expecting argument of type itkImageUC3 or itkImageSourceIUC3.

Can you please help to resolve this issue?

omaghsoudi commented 7 months ago

Resolved the issue by setting the image formate into float and mask format into UC.