# Fixes label for dicom image

**URL:** <https://discourse.slicer.org/t/fixes-label-for-dicom-image/24116>\
**Category:** Support\
**Created:** [June 30, 2022, 12:09pm UTC](https://discourse.slicer.org/t/fixes-label-for-dicom-image/24116 "2022-06-30T12:09:18Z")\
**Posts on this page:** 1\
**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:** [June 30, 2022, 12:09pm UTC](https://discourse.slicer.org/t/fixes-label-for-dicom-image/24116/1 "2022-06-30T12:09:18Z")

</div>

I use dicom dataset for feature extraction. But I got an error about ‘label’. Hoping for help

from **future** import print\_function  
import six  
import os # needed navigate the system to get the input data

import matplotlib.pyplot as plt  
import SimpleITK as sitk  
import pydicom as dicom

import radiomics  
from radiomics import featureextractor # This module is used for interaction with pyradiomics

# Get the testCase

maskPath =(‘D:/NSCLC data CT paitent/manifest-1603198545583/NSCLC-Radiomics/LUNG1-001/09-18-2008-StudyID-NA-69331/300.000000-Segmentation-9.554/1-1.dcm’)  
imagePath = (‘D:/NSCLC data CT paitent/manifest-1603198545583/NSCLC-Radiomics/LUNG1-001/09-18-2008-StudyID-NA-69331/0.000000-NA-82046/1-068.dcm’)  
#radiomics.getTestCase  
image = sitk.ReadImage(imagePath)  
mask = sitk.ReadImage(maskPath)  
ndImg = sitk.GetArrayFromImage(image)  
ndLbl = sitk.GetArrayFromImage(mask)  
plt.imshow(ndImg[0])  
plt.show()  
plt.imshow(ndLbl[0])  
plt.show()

if imagePath is None or maskPath is None: # Something went wrong, in this case PyRadiomics will also log an error  
raise Exception(‘Error getting testcase!’) # Raise exception to prevent cells below from running in case of “run all”

# Additonally, store the location of the example parameter file, stored in \pyradiomics\examples/exampleSettings

paramPath = os.path.join(‘..’, ‘examples’, ‘exampleSettings’, ‘Params.yaml’)  
print(‘Parameter file, absolute path:’, os.path.abspath(paramPath))

# Instantiate the extractor

extractor = featureextractor.RadiomicsFeatureExtractor()

print(‘Extraction parameters:\n\t’, extractor.settings)  
print(‘Enabled filters:\n\t’, extractor.enabledImagetypes)  
print(‘Enabled features:\n\t’, extractor.enabledFeatures)

settings = {‘label’: 255}

extractor = radiomics.featureextractor.RadiomicsFeatureExtractor(additionalInfo=True, \*\*settings)

result = extractor.execute(imagePath, maskPath)

print(‘Result type:’, type(result)) # result is returned in a Python ordered dictionary)  
print(‘’)  
print(‘Calculated features’)  
for key, value in six.iteritems(result):  
print(‘\t’, key, ‘:’, value)

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