Image types for ImageFileWriter - only itk.UC?

It seems that ImageFileWriter from itk-python is only available for itk.UC. Is this right?

This means I can’t even write out a typical CT volume!

KeyError: 'itkTemplate : No template (<itkCType unsigned int>, 3) for the itk::Image class'

Hi @fedorov,

The ImageFileWriter is wrapped for multiple types – we can find out what types with the .GetTypes() method:

In [1]: import itk

In [2]: itk.ImageFileWriter.GetTypes()
<itkTemplate itk::ImageFileWriter>
Options:
  [<class 'itkImagePython.itkImageCF2'>,]
  [<class 'itkImagePython.itkImageCF3'>,]
  [<class 'itkImagePython.itkImageCVF22'>,]
  [<class 'itkImagePython.itkImageCVF23'>,]
  [<class 'itkImagePython.itkImageCVF32'>,]
  [<class 'itkImagePython.itkImageCVF33'>,]
  [<class 'itkImagePython.itkImageCVF42'>,]
  [<class 'itkImagePython.itkImageCVF43'>,]
  [<class 'itkImagePython.itkImageF2'>,]
  [<class 'itkImagePython.itkImageF3'>,]
  [<class 'itkImagePython.itkImageRGBAUC2'>,]
  [<class 'itkImagePython.itkImageRGBAUC3'>,]
  [<class 'itkImagePython.itkImageRGBUC2'>,]
  [<class 'itkImagePython.itkImageRGBUC3'>,]
  [<class 'itkImagePython.itkImageSS2'>,]
  [<class 'itkImagePython.itkImageSS3'>,]
  [<class 'itkImagePython.itkImageUC2'>,]
  [<class 'itkImagePython.itkImageUC3'>,]
  [<class 'itkImagePython.itkImageUS2'>,]
  [<class 'itkImagePython.itkImageUS3'>,]
  [<class 'itkImagePython.itkImageVF22'>,]
  [<class 'itkImagePython.itkImageVF23'>,]
  [<class 'itkImagePython.itkImageVF32'>,]
  [<class 'itkImagePython.itkImageVF33'>,]
  [<class 'itkImagePython.itkImageVF42'>,]
  [<class 'itkImagePython.itkImageVF43'>,]
  [<class 'itkVectorImagePython.itkVectorImageF2'>,]
  [<class 'itkVectorImagePython.itkVectorImageF3'>,]
  [<class 'itkVectorImagePython.itkVectorImageSS2'>,]
  [<class 'itkVectorImagePython.itkVectorImageSS3'>,]
  [<class 'itkVectorImagePython.itkVectorImageUC2'>,]
  [<class 'itkVectorImagePython.itkVectorImageUC3'>,]
  [<class 'itkVectorImagePython.itkVectorImageUS2'>,]
  [<class 'itkVectorImagePython.itkVectorImageUS3'>,]

In [3]:

So, there is support for 3D signed short, which should be common for CT volumes. There is not support for unsigned int. Generally, we wrap just 64-bit integer pixel types to keep the package size down, instead of 32-bit integer pixel types. We could add unsigned long long wrapping for ImageFileWriter. Would this address your use case?

Thanks,
Matt

1 Like

Matt, thank you for the explanation. Somehow I missed signed short. This should be sufficient, I don’t think any changes are needed, at least not for me!

1 Like