Open-source python package for the extraction of Radiomics features from 2D and 3D images and binary masks. Support: https://discourse.slicer.org/c/community/radiomics
Hi, I have a (very simple) question, but I can't figure it out. Hope you can help!
Describe the bug
I'm trying to compute features from a masked numpy array (which I converted to a Simple ITK image and mask), but all my first order features are 0 except for uniformity (=1) and entropy (=-3.20e-16). I really don't understand what is causing this.
I've followed this pyradiomics example, which loads Simple ITK images and computes the first order features. Running the example works for me, but all values are zero when I plug in my values. As example, I've a raster which I've called test_r which is a masked numpy array. I have replaced the nan values of the data by zeros, and multiplied my values (which are in the range of 20 to 28) by 1000 converted them to np.int16, since this is the same data type I got when I converted the example to an array. The mask had data type np.int32, so I also convert that one.
I saw a similar issue here, but for me changing the bin width did not change the output.
PyRadiomics configuration
So my code looks like this:
image_arr = np.nan_to_num(test_r.data) * 1000
image_arr = image_arr.astype(np.int16)
image = sitk.GetImageFromArray(image_arr)
mask_arr = test_r.mask.astype(np.int32)
mask = sitk.GetImageFromArray(mask_arr)
# Setting for the feature calculation.
settings = {'binWidth': 10}
# Show the first order feature calculations
firstOrderFeatures = firstorder.RadiomicsFirstOrder(image, mask, **settings)
firstOrderFeatures.enableAllFeatures()
print('Calculating first order features...')
results = firstOrderFeatures.execute()
print('done')
print('Calculated first order features: ')
for (key, val) in six.iteritems(results):
print(' ', key, ':', val)
Version (please complete the following information):
OS: Ubuntu
Python version: 3.9
PyRadiomics version 3.0.1
Additional context
Below I added the image and mask plots from the example and my own.
Hi, I have a (very simple) question, but I can't figure it out. Hope you can help!
Describe the bug I'm trying to compute features from a masked numpy array (which I converted to a Simple ITK image and mask), but all my first order features are 0 except for uniformity (=1) and entropy (=-3.20e-16). I really don't understand what is causing this. I've followed this pyradiomics example, which loads Simple ITK images and computes the first order features. Running the example works for me, but all values are zero when I plug in my values. As example, I've a raster which I've called test_r which is a masked numpy array. I have replaced the nan values of the data by zeros, and multiplied my values (which are in the range of 20 to 28) by 1000 converted them to np.int16, since this is the same data type I got when I converted the example to an array. The mask had data type np.int32, so I also convert that one. I saw a similar issue here, but for me changing the bin width did not change the output.
PyRadiomics configuration So my code looks like this:
Version (please complete the following information):
Additional context Below I added the image and mask plots from the example and my own.
Example image & mask:
My image & mask:
I hope you can help, thank you in advance!