Faster DICOM loading

Hi, I’m loading DICOM series this way:

    from DICOMLib import DICOMUtils
    loadedNodeIDs = []
    
    with DICOMUtils.TemporaryDICOMDatabase() as db:
      DICOMUtils.importDicom(image_dicom_folder, db)
      patientUIDs = db.patients()
      for patientUID in patientUIDs:
        loadedNodeIDs.extend(DICOMUtils.loadPatientByUID(patientUID))
    #print("image loaded:",image_dicom_folder)
    slicer.app.applicationLogic().GetInteractionNode().SetCurrentInteractionMode(slicer.vtkMRMLInteractionNode.AdjustWindowLevel)

for a DICOM series to load it takes around 25 seconds on a intel quad core 4.00GHz cpu and 32 GB of Ram.

I was wondering if this is something that I can improve in some way?

Best

If you know that you only need to load 3D images (no 4D data, no 2D+t data, no DICOM segmentation objects, RT structure sets, etc.) then you can disable all DICOM plugins except the basic scalar volume reader plugin. To do that run these before starting the loading:

# Temporarily remove all DICOM plugins except DICOMScalarVolumePlugin
originalDicomPlugins = slicer.modules.dicomPlugins
slicer.modules.dicomPlugins = {'DICOMScalarVolumePlugin': originalDicomPlugins['DICOMScalarVolumePlugin']}

and in the end restore the original plugin list by running this:

# Restore original DICOM plugin list
slicer.modules.dicomPlugins = originalDicomPlugins
1 Like