I use python pyradiomics for feature extraction. I have imported the DICOM image but about the masking part i still don’t know if i did it right or not. If my masking part is wrong, please tell me how to correct and mask the dicom image!!! Please
import SimpleITK as sitk
import matplotlib.pyplot as plt
imageName = ‘C:/Users/Admin/Desktop/CERR/Gui SV/CT3.DCM’
maskName = ‘C:/Users/Admin/Desktop/CERR/Gui SV/CT3.DCM’
image = sitk.ReadImage(imageName)
mask = sitk.ReadImage(maskName)
ndImg = sitk.GetArrayFromImage(image)
ndLbl = sitk.GetArrayFromImage(mask)
plt.imshow(ndImg[0])
plt.show()
plt.imshow(ndLbl[0])
plt.show()
settings = {}
settings[‘binWidth’] = 25
If enabled, resample image (resampled image is automatically cropped.
settings[‘resampledPixelSpacing’] = None # [3,3,3] is an example for defining resampling (voxels with size 3x3x3mm)
settings[‘interpolator’] = sitk.sitkBSpline
settings[‘label’] = 1 #Since the mask area has a pixel value of 1 (otherwise it is 0).
#Check the integrity of the mask and create a bbox# 2020/1/23 Addendum
bb, correctedMask = imageoperations.checkMask(image, mask)
if correctedMask is not None:
mask = correctedMask
image, mask = imageoperations.cropToTumorMask(image, mask, bb)
firstOrderFeatures = radiomics.firstorder.RadiomicsFirstOrder(image, mask, **settings)
firstOrderFeatures.enableFeatureByName(‘Mean’, True)
firstOrderFeatures.enableAllFeatures()
print('Will calculate the following first order features: ‘)
for f in firstOrderFeatures.enabledFeatures.keys():
print(’ ', f)
print(getattr(firstOrderFeatures, ‘get%sFeatureValue’ % f).doc)
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)