AIM-Harvard / pyradiomics

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
http://pyradiomics.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.17k stars 497 forks source link

[FEAT EXTRACTION] Same GLRLM Features for different images #813

Closed prakanshuls22 closed 1 year ago

prakanshuls22 commented 1 year ago

I am trying to extract the GLRLM features for a set of images, and then storing them to be used as input for further SVM classification. However, I am faced with the issue that, the features calculated for all the images are same. Below I have provided a set of images and the procedure of GLRLM feature extraction, which I am following. Can anyone tell why these features are same, or point out an error in my procedure so that I can correct it.

Thanks in advance!!!

Sample Images to try this code on- https://drive.google.com/drive/folders/1jr1Rm78IZqbknFH-vxc6wn_H8__aqJE-?usp=share_link

import SimpleITK as sitk
import radiomics
import six
import matplotlib.pyplot as plt
import numpy as np
import mclahe as mc
from radiomics import glrlm
from radiomics import glcm

img = plt.imread("Image path")
img_enhanced = mc.mclahe(img[:,:,1]) #just a contrast enhancement library, applied on the green channel of the image
img_mask = np.ones(img_enhanced.shape) #I want to calculate the features over the whole image, thus forming an input image mask of all ones. 
img_mask_sitk = sitk.GetImageFromArray(img_mask) #conversion to sitk objects 
image = sitk.GetImageFromArray(img_enhanced) #conversion to sitk objects 

glrlmFeatures = glrlm.RadiomicsGLRLM(image, img_mask_sitk)
glrlmFeatures.enableAllFeatures()
results = glrlmFeatures.execute()

print('Calculated GLRLM features: ')
for i, (key, val) in enumerate(six.iteritems(results)):
  print('  ', key, ':', val)

The output obtained is -

Calculated GLRLM features: GrayLevelNonUniformity : 5351.5 GrayLevelNonUniformityNormalized : 1.0 GrayLevelVariance : 0.0 HighGrayLevelRunEmphasis : 1.0 LongRunEmphasis : 8522218.622564822 LongRunHighGrayLevelEmphasis : 8522218.622564822 LongRunLowGrayLevelEmphasis : 8522218.622564822 LowGrayLevelRunEmphasis : 1.0 RunEntropy : 4.941750153069838 RunLengthNonUniformity : 1930.311772950245 RunLengthNonUniformityNormalized : 0.5205062050385768 RunPercentage : 0.0004382084704636928 RunVariance : 432929.4178383168 ShortRunEmphasis : 0.0002305520163691588 ShortRunHighGrayLevelEmphasis : 0.0002305520163691588 ShortRunLowGrayLevelEmphasis : 0.0002305520163691588

I receive the above features for all the images that I use for GLRLM Feature calculation.

Versions Python 3.8.5 Pyradiomics 3.0.1 SimpleITK 2.2.1 six 1.1.6.0

JoostJM commented 1 year ago

These values tell me it's a 'flat region' (binWidth parameter too large). e.g. no variance in the gray level. You can check this in by comparing the range (firstorder feature) to your setting of binWidth.