# Faster DICOM loading

**URL:** <https://discourse.slicer.org/t/faster-dicom-loading/19723>\
**Category:** Development\
**Tags:** dicom\
**Created:** [September 17, 2021, 9:36am UTC](https://discourse.slicer.org/t/faster-dicom-loading/19723 "2021-09-17T09:36:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![S\_Arbabi](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@S\_Arbabi](https://discourse.slicer.org/u/S_Arbabi)\
**Post date:** [September 17, 2021, 9:36am UTC](https://discourse.slicer.org/t/faster-dicom-loading/19723/1 "2021-09-17T09:36:34Z")

</div>

Hi, I’m loading DICOM series this way:

```auto
    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

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 17, 2021, 9:37pm UTC](https://discourse.slicer.org/t/faster-dicom-loading/19723/2 "2021-09-17T21:37:13Z")

</div>

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:

```python
# 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:

```python
# Restore original DICOM plugin list
slicer.modules.dicomPlugins = originalDicomPlugins

```
