# Import Dicom Files with DICOM RT files

**URL:** <https://discourse.slicer.org/t/import-dicom-files-with-dicom-rt-files/11964>\
**Category:** Development\
**Created:** [June 9, 2020, 5:13pm UTC](https://discourse.slicer.org/t/import-dicom-files-with-dicom-rt-files/11964 "2020-06-09T17:13:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![loubna](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@loubna](https://discourse.slicer.org/u/loubna)\
**Post date:** [June 9, 2020, 5:13pm UTC](https://discourse.slicer.org/t/import-dicom-files-with-dicom-rt-files/11964/1 "2020-06-09T17:13:32Z")

</div>

Hi;  
I am trying to develop a python script in order to import spectroscopy and metabolite data. However when I import the dicom file with SlicerRT structures, I have got an error “DICOM Plugin failed: Dataset does not have attribute ‘ImageType’.”  
here is the code :

filePath = file[0]  
ds = dicom.read\_file(filePath,stop\_before\_pixels=True)  
if ds.ImageType[2] == ‘SPECTROSCOPY’:  
#Only a single file when we talk about spectrosopy files  
result = []  
loadable = DICOMLoadable()  
loadable.files = [filePath]  
loadable.name = ‘Donnes Spectrophotometriques’  
loadable.tooltip = ‘Siemens’  
loadable.confidence = 0.95  
loadable.selected = True  
result.append(loadable)  
return result

when I import spectroscopy data in slicer with dicom diles (not DICOM RT), the spectroscopy data displayed without any error.

Can you tell me why the script does not work when import it with DicomRt files

thank’s in advance

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 9, 2020, 5:33pm UTC](https://discourse.slicer.org/t/import-dicom-files-with-dicom-rt-files/11964/2 "2020-06-09T17:33:56Z")

</div>

[Image type tag](https://dicom.innolitics.com/ciods/cr-image/general-image/00080008) is in “General Image” module and so it is probably not permitted in non-image data objects, such as RT structure set. You can put `ds.ImageType` between try/except or check if the attribute exists before you try to access it.
