Itk or SimpleItk for PyRadiomics (in python, of course)

Hey guys… what up?

I am working with PyRadiomics in some python scripts and I saw that the examples use SimpleITK for leading the images into the processing pipeline… I’ve tried doing the same with whole ITK pack (imread() function),
but it dioesn’t work propperly…
the problem sounds to be that PyRadiomics input images HAVE TO BE SimpleITK::ImageType… and if I use a ITK::ImageType it gets that error…

Is there any constraint on the usage of SimpleITK for Pyradiomics operations?

  • at the end, I post the Error Message!

Thanks for yout comensts!

 Traceback (most recent call last):
 File "", line 49, in <module>
 firstOrderFeatures = radiomics.firstorder.RadiomicsFirstOrder(image, mask, **settings)
 File "/home/leonardo/anaconda3/lib/python3.6/site-packages/radiomics/", line 32, in __init__
 super(RadiomicsFirstOrder, self).__init__(inputImage, inputMask, **kwargs)
 File "/home/leonardo/anaconda3/lib/python3.6/site-packages/radiomics/", line 88, in __init__
 File "/home/leonardo/anaconda3/lib/python3.6/site-packages/radiomics/", line 91, in  
 self.imageArray = sitk.GetArrayFromImage(self.inputImage)
 File "/home/leonardo/anaconda3/lib/python3.6/site-packages/SimpleITK/", line 3412, in 
 arrayView = GetArrayViewFromImage(image)
 File "/home/leonardo/anaconda3/lib/python3.6/site-packages/SimpleITK/", line 3388, in 
 pixelID = image.GetPixelIDValue()
AttributeError: 'itkImageSS3' object has no attribute 'GetPixelIDValue'

Why not just use SimpleITK like the example? SimpleITK has great ImageIO, add great support for many pixel types!

Hi @blowekamp

actually I was just getting ready for working whith more delicated applications with ITK/python…

Then I tried to use ITK rather than SImpleITK…

In a near future I’ll be performing pixel wise operations… and with ITK I already have a glance on how to… but I don’t know if SimpleITK has struch ITK:ImageIterators… and sounds that ITK has more documentation (in Python) than simple ITK… am I wrong in my thinking?

Thanks for the clues on that!

Hi @machadoL,

I don’t think ITK has more documentation in Python (maybe I am mistaken).

In any case, the question mark operator will show you the SimpleITK docstring for API documentation.


With respect to examples and detailed workflows please take a look at the SimpleITK read-the-docs examples and at the Jupyter Notebooks repository.

Finally, with respect to iteration, I’d avoid iterating in Python as much as possible. As a side note, you can iterate over a SimpleITK image, but I have never had to do this:

for px in img:

In a pinch I will get a numpy array view of the SimpleITK image (sitk.GetArrayViewFromImage) and work with numpy broadcasting operations (don’t iterate).

Hope this helps

1 Like