Import Dicom Files with DICOM RT files

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

Image type tag 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.

1 Like