DICOM import failed

i saw this error in log file ,when my script for model import is failed . these are the last few lines.

self.importedVolume = DSVPC.load(DSVPC.examineForImport([files])[0])
  File "C:/Program Files/Slicer 4.10.1/bin/../lib/Slicer-4.10/qt-scripted-modules/DICOMScalarVolumePlugin.py", line 429, in load
  File "C:/Program Files/Slicer 4.10.1/bin/../lib/Slicer-4.10/qt-scripted-modules/DICOMScalarVolumePlugin.py", line 693, in createAcquisitionTransform
    self.gridTransformFromCorners(volumeNode, self.originalCorners, self.targetCorners)
  File "C:/Program Files/Slicer 4.10.1/bin/../lib/Slicer-4.10/qt-scripted-modules/DICOMScalarVolumePlugin.py", line 599, in gridTransformFromCorners
    displacements = slicer.util.arrayFromGridTransform(gridTransform)
  File "C:\Program Files\Slicer 4.10.1\bin\Python\slicer\util.py", line 870, in arrayFromGridTransform
    nshape = tuple(reversed(displacementGrid.GetDimensions()))
AttributeError: 'NoneType' object has no attribute 'GetDimensions'

i notice that this is happening after i have enabled ‘apply regularization transform’ in the application setting

Can you load the volume successfully by using the DICOM browser user interface? (with “apply regularization transform” enabled)

yes, its working in user interface.

Then the issue is in your script. Could you copy the script or a URL to its source code repository?

    from DICOMScalarVolumePlugin import DICOMScalarVolumePluginClass
    result = utils.importDicom(self.path)
    DSVPC = DICOMScalarVolumePluginClass()
    db = slicer.dicomDatabase

        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(...).

1 Like

i’m handling the exception now, but still getting same error messages

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.