# How to run Pyradiomics

**URL:** <https://discourse.slicer.org/t/how-to-run-pyradiomics/23047>\
**Category:** Radiomics\
**Tags:** python\
**Created:** [April 20, 2022, 11:28am UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047 "2022-04-20T11:28:36Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Van\_Tran\_Sang\_Huynh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/van_tran_sang_huynh/32/15043_2.png) [@Van\_Tran\_Sang\_Huynh](https://discourse.slicer.org/u/Van_Tran_Sang_Huynh)\
**Post date:** [April 20, 2022, 11:28am UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/1 "2022-04-20T11:28:36Z")

</div>

Hi. I am a student, I am practicing using pyrradiomics for feature extraction. I have installed pyradiomics in python 3.6 (64bit), but I don’t know how to run Pyradiomics, please help. Thank you

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/e/8ee2847b98f5dbdc042f3ee513a98be22e5910ad.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/e/8ee2847b98f5dbdc042f3ee513a98be22e5910ad.jpeg)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [April 20, 2022, 1:29pm UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/2 "2022-04-20T13:29:58Z")

</div>

Review the documentation and if there’s a specific step that’s not working for you describe exactly what you did and what didn’t work as you expect.

[https://pyradiomics.readthedocs.io/en/latest/index.html](https://pyradiomics.readthedocs.io/en/latest/index.html)

---

<div class="post-metadata">

**Author:** ![Van\_Tran\_Sang\_Huynh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/van_tran_sang_huynh/32/15043_2.png) [@Van\_Tran\_Sang\_Huynh](https://discourse.slicer.org/u/Van_Tran_Sang_Huynh)\
**Post date:** [April 23, 2022, 4:37am UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/3 "2022-04-23T04:37:56Z")

</div>

I’m writing code and trying to extract it, but when it comes to choose 2D array, it crashes. And I’m trying to fix this.

# choose 2D array

#The memory is referenced and changed, so call it again.  
imageName, maskName = getTestCase(‘lung2’)  
imageStack = sitk.ReadImage(imageName)  
maskSatck = sitk.ReadImage(maskName)

#Extract pixels as adarray for parametric image calculations, etc.(Example for the 24th slice)  
ndimage = sitk.GetArrayFromImage(imageStack)[24]  
ndmask = sitk.GetArrayFromImage(maskStack)[24]

#Basically, the data that was originally a DICOM image has a dimension of 3, so it is expanded.  
ndimage = np.expand\_dims(ndimage, axis=0)  
ndmask = np.expand\_dims(ndmask, axis=0)

print(ndimage.shape)# (1, 512, 512)Even with force2D, the shape must be 3D.  
print(ndmask.shape)# (1, 512, 512)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/1/c145e939bb5c0e1ed363262962886fcebcc292fe.png)

---

<div class="post-metadata">

**Author:** ![Van\_Tran\_Sang\_Huynh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/van_tran_sang_huynh/32/15043_2.png) [@Van\_Tran\_Sang\_Huynh](https://discourse.slicer.org/u/Van_Tran_Sang_Huynh)\
**Post date:** [April 23, 2022, 4:50am UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/4 "2022-04-23T04:50:35Z")

</div>

Can you help me about writing code in feature extraction using pyrradiomics. I tried to use the code but failed. Hope your help.

[https://pyradiomics.readthedocs.io/en/latest/features.html](https://pyradiomics.readthedocs.io/en/latest/features.html)

Best regards.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [April 23, 2022, 6:39pm UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/5 "2022-04-23T18:39:49Z")

</div>

The error message says that you haven’t defined `maskStack`.

---

<div class="post-metadata">

**Author:** ![Van\_Tran\_Sang\_Huynh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/van_tran_sang_huynh/32/15043_2.png) [@Van\_Tran\_Sang\_Huynh](https://discourse.slicer.org/u/Van_Tran_Sang_Huynh)\
**Post date:** [April 25, 2022, 7:00am UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/6 "2022-04-25T07:00:40Z")

</div>

Can you show me how to extract features using pyradiomics in python? Please!!!

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [April 25, 2022, 12:24pm UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/7 "2022-04-25T12:24:31Z")

</div>

I’m afraid we seem to be going in a loop here. I think the documentation is pretty clear, but maybe there’s a specific step that’s not working for you or there’s some conceptual step that isn’t clear. Maybe looking at [these suggestions](http://sscce.org/) will help you formulate a question someone here can help with.

[https://pyradiomics.readthedocs.io/en/latest/usage.html](https://pyradiomics.readthedocs.io/en/latest/usage.html)

---

<div class="post-metadata">

**Author:** ![Van\_Tran\_Sang\_Huynh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/van_tran_sang_huynh/32/15043_2.png) [@Van\_Tran\_Sang\_Huynh](https://discourse.slicer.org/u/Van_Tran_Sang_Huynh)\
**Post date:** [April 28, 2022, 9:15am UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/8 "2022-04-28T09:15:06Z")

</div>

I am having some problems. Can you give me a solution please?

File “C:/Users/Admin/Desktop/vd2.py”, line 18, in   
extractor = featureextractor.RadiomicsFeaturesExtractor(params)  
AttributeError: module ‘radiomics.featureextractor’ has no attribute ‘RadiomicsFeaturesExtractor’

and if i drop ‘s’ → RadiomicsFeatureExtractor() can’t try pair ‘kwargs’?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/0/4043b8669cfe79d407c6335db35e33b80eb22beb.png)

---

<div class="post-metadata">

**Author:** ![JoostJM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joostjm/32/1091_2.png) [@JoostJM](https://discourse.slicer.org/u/JoostJM)\
**Post date:** [May 3, 2022, 7:30am UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/9 "2022-05-03T07:30:49Z")

</div>

RadiomicsFeaturesExtractor, inputImages etc. are not valid anymore, they are from an older version of PyRadiomics and are renamed etc.

Als to your “kwargs” problem, pleas read the error carefully: It says you are using an outdated syntax. `print` without parenthesis is not allowed since Python 3.

---

<div class="post-metadata">

**Author:** ![Manju\_Manju](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/manju_manju/32/15313_2.png) [@Manju\_Manju](https://discourse.slicer.org/u/Manju_Manju)\
**Post date:** [May 17, 2022, 12:28pm UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/10 "2022-05-17T12:28:37Z")

</div>

Sir Im trying segmentation on 2d images but im not able to get the output table of radiomic feature generator.can you please guide me

---

<div class="post-metadata">

**Author:** ![Van\_Tran\_Sang\_Huynh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/van_tran_sang_huynh/32/15043_2.png) [@Van\_Tran\_Sang\_Huynh](https://discourse.slicer.org/u/Van_Tran_Sang_Huynh)\
**Post date:** [May 26, 2022, 3:51pm UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/13 "2022-05-26T15:51:53Z")

</div>

I have imported the DICOM file but the ‘mask’ as above is correct or not. If I’m wrong, how do I need to correct it? hope the helping  
Best regards.  
Sang.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/e/6ea5eaa25b877c8e740b69ded84558eb77ed9b93.png)

---

<div class="post-metadata">

**Author:** ![Van\_Tran\_Sang\_Huynh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/van_tran_sang_huynh/32/15043_2.png) [@Van\_Tran\_Sang\_Huynh](https://discourse.slicer.org/u/Van_Tran_Sang_Huynh)\
**Post date:** [May 31, 2022, 11:29am UTC](https://discourse.slicer.org/t/how-to-run-pyradiomics/23047/14 "2022-05-31T11:29:23Z")

</div>

I have imported the DICOM file but the ‘mask’ as above is correct or not. If I’m wrong, how do I need to correct it? hope the helping  
Best regards.  
Sang.
