# Fastest way to load DICOM

**URL:** <https://discourse.slicer.org/t/fastest-way-to-load-dicom/9317>\
**Category:** Development\
**Created:** [November 27, 2019, 8:12pm UTC](https://discourse.slicer.org/t/fastest-way-to-load-dicom/9317 "2019-11-27T20:12:49Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [November 27, 2019, 9:13pm UTC](https://discourse.slicer.org/t/fastest-way-to-load-dicom/9317/2 "2019-11-27T21:13:31Z")

</div>

> [@fbordignon](#):
>
> What is the fastest way to load them inside slicer.

Use the latest Slicer Preview Release, as DICOM import speed is greatly improved.

If you get scans one by one then you can import them one by one (by drag-and-dropping to the application window), loading them using DICOM browser, then save them as .nrrd.

If you have hundreds of files already then you can write a short Python script that iterates through all your data. You can use tools or scripts described in the topic that you referred above, or you can use a use/customize a simple script like this:

```python
dicomDataDir = 'c:/tmp/inputDicomFiles'
outputDir = 'c:/tmp/outputNrrdFiles'

import DICOMLib
import re
DICOMLib.importDicom(dicomDataDir)
dicomFiles = slicer.util.getFilesInDirectory(dicomDataDir)
loadablesByPlugin, loadEnabled = DICOMLib.getLoadablesFromFileLists([dicomFiles])
loadedNodeIDs = DICOMLib.loadLoadables(loadablesByPlugin)
for loadedNodeID in loadedNodeIDs:
    node = slicer.mrmlScene.GetNodeByID(loadedNodeID)
    safeFileName = re.sub(r'(?u)[^-\w.]', '', node.GetName().strip().replace(' ', '_'))
    slicer.util.saveNode(node, '{0}/{1}.nrrd'.format(outputDir, safeFileName))

```

---

_[View the full topic](https://discourse.slicer.org/t/fastest-way-to-load-dicom/9317)._
