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

**URL:** https://discourse.itk.org/t/itk-or-simpleitk-for-pyradiomics-in-python-of-course/1478
**Category:** Algorithms
**Created:** [December 13, 2018, 6:23pm UTC](https://discourse.itk.org/t/itk-or-simpleitk-for-pyradiomics-in-python-of-course/1478 "2018-12-13T18:23:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![machadoL](https://discourse.itk.org/user_avatar/discourse.itk.org/machadol/32/662_2.png) [@machadoL](https://discourse.itk.org/u/machadoL)
#### Post date: [December 13, 2018, 6:23pm UTC](https://discourse.itk.org/t/itk-or-simpleitk-for-pyradiomics-in-python-of-course/1478/1 "2018-12-13T18:23:07Z")

</div>

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!  
hugs!

```auto
 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'

```

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [December 13, 2018, 6:46pm UTC](https://discourse.itk.org/t/itk-or-simpleitk-for-pyradiomics-in-python-of-course/1478/2 "2018-12-13T18:46:14Z")

</div>

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

---

<div class="post-metadata">

### Author: ![machadoL](https://discourse.itk.org/user_avatar/discourse.itk.org/machadol/32/662_2.png) [@machadoL](https://discourse.itk.org/u/machadoL)
#### Post date: [December 13, 2018, 8:03pm UTC](https://discourse.itk.org/t/itk-or-simpleitk-for-pyradiomics-in-python-of-course/1478/3 "2018-12-13T20:03:18Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [December 13, 2018, 8:49pm UTC](https://discourse.itk.org/t/itk-or-simpleitk-for-pyradiomics-in-python-of-course/1478/4 "2018-12-13T20:49:29Z")

</div>

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.

```auto
sitk.ResampleImageFilter? 

```

With respect to examples and detailed workflows please take a look at the SimpleITK [read-the-docs examples](https://simpleitk.readthedocs.io/en/master/Examples/index.html) and at the [Jupyter Notebooks repository](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks).

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:

```auto
for px in img:
  print(px)

```

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  
Ziv
