0

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 with

imageName, maskName = getTestCase('brain1') # load test case
image = sitk.ReadImage(imageName)           # read image
mask = sitk.ReadImage(maskName)

settings = {'binWidth': 25,
            'interpolator': sitk.sitkBSpline,
            'resampledPixelSpacing': None}

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)

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. 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,
            'interpolator': sitk.sitkBSpline,
            'resampledPixelSpacing': None}

# 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)

I've already tried varying the bin width, but this didn't change the output. For completeness, I've added the example image and mask and my own below.

Example image Example mask

My image My mask

I would be very happy if you can help!! Thank you in advance!

Anne0102
  • 1
  • 1

0 Answers0