I am trying to patch some problematic dicom files to make sure the patcher will be able to handle any issues when loading dicom files in. running the process through the GUI has no issues, and the patch works as intended. running the code through python generates some issues though. an error is thrown when the patcher is attempting to create an output path for the patched file by using the patient name and patient id attributes from the dicom file. this dicom file has no patient name attribute, so an error is thrown and the process is stopped.
why is this different from the GUI, where no error is thrown for the same file, and how do i fix it?
i’m calling it with the code below. i would also like to know how the logic instance could be accessed without the widget representation, I have only found the abstract class for logic accessible outside of the widget:
logic = slicer.modules.dicompatcher.widgetRepresentation().self().logic
logic.clearRules()
logic.addRule('NormalizeFileNames')
logic.addRule('GenerateMissingIDs')
outputPath = path + '_DicomPatcherOutput'
logic.patchDicomDir(path, outputPath)
here is the stack trace:
logic.patchDicomDir(path, outputPath)
File "C:/Program Files/Slicer 4.9.0-2018-04-04/lib/Slicer-4.9/qt-scripted-modules/DICOMPatcher.py", line 571, in patchDicomDir
patchedFilePath = rule.generateOutputFilePath(patchedFilePath, ds)
File "C:/Program Files/Slicer 4.9.0-2018-04-04/lib/Slicer-4.9/qt-scripted-modules/DICOMPatcher.py", line 458, in generateOutputFilePath
patientNameID = ds.PatientName+"*"+ds.PatientID
AttributeError: 'str' object has no attribute 'PatientName'