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

Operating system: Linux Mint 18
Slicer version:
Expected behavior: Import and read images through Itk Pack
Actual behavior: It gives some errors

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…

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

  • at the end, I post the Error Message!

Thanks for yout comensts!
hugs!

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

If you use Slicer and you end up calling code in /home/leonardo/anaconda3/lib/python3.6/site-packages/radiomics then it’s an issue. Any idea how that could have happened? Have you installed SlicerRadiomics extension and trying to use that?

If you only use ITK/SimpleITK/pyradiomics in anaconda and not in Slicer then you may get your questions answered in the ITK forum.

1 Like

If I understood the issue correctly, you are getting this error because the output of itk-python image read and SimpleITK image read is not the same. I thought I saw somewhere a recipe to go between the two outputs, but I can’t find it. I would suggest to ask on ITK forum how to convert output of imread to a SimpleITK image. You could probably do it by copying the buffer and initializing attributes, or using numpy array as an intermediate, but maybe there is already a convenience function that does everything.

1 Like

Thank you Guys…
Yeah… the point is that I am using outside SlicerRadiomics extension… I’m using PyRadiomics directly trhough pythoin script… abd 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…

I’ll try Itk Forum… but that was helpful anyway… thank you!