from DICOMScalarVolumePlugin import DICOMScalarVolumePluginClass
result = utils.importDicom(self.path)
DSVPC = DICOMScalarVolumePluginClass()
db = slicer.dicomDatabase
if(db.patients()):
for patient in db.patients():
for study in db.studiesForPatient(patient):
for series in db.seriesForStudy(study):
print('looking at series ' + str(series) + ' for patient ' + str(patient))
files = db.filesForSeries(series)
if len(files) >= 1:
self.importedVolume = DSVPC.load(DSVPC.examineForImport([files])[0])
# TODO use bodypart information to determine what segments are expected to be present, or some other way to determine what segments types should be created
import dicom
data = dicom.read_file(files[0])
# for info in data: print('file ' + str(files[0]) + ' has data: ' + str(info))
self.bodyPartExamined = data.get('BodyPartExamined')
print('dicom header has info bodyPartExamined: ' + str(self.bodyPartExamined))
this the area where i’m getting error , basically while importing DICOM files , one more thing i get this issue when i use --no–window mode.
Thank you for the code, it helped a lot. The problem is that you force the DICOMScalarVolumePlugin to load all kinds of data you have in your database. You need to use the appropriate plugin for each data type.
If you are only interested in scalar volumes, you can keep using only DICOMScalarVolumePlugin but catch exceptions thrown by DSVPC.load(...).
Yes, you will still get errors for information objects that cannot be loaded as scalar volumes, but if you catch the correct exception for them you can still load everything else.