Import DICOM files from python interactor add extra volumes and nodes

Operating system: win10
Slicer version: stable version 4.11.20210226
Expected behavior: Manually loading works fine
Actual behavior: python interactor add extra volumes and nodes

Hi all,

I am new to Slicer. I got 5 folders of DICOM files with one folder contains CT and other four folders contains MRI and DWI. All files ending with .dcm

If I load these folders using DCM module, everything works fine. But I need to develop a script to do this in the python Interactor. Here is what I found online:

dicomDataDir = r"C:\MyDicomFoldercontainsFivefolders"
from DICOMLib import DICOMUtils
patientUIDs = slicer.dicomDatabase.patients()
for patientUID in patientUIDs:

This code will import all the data and some extra volumes named “Sequence” (just one slice of image) and some extra nodes with “browser” in the name. Checked the source code of DICOMUtils, really can’t figure out where went wrong.


Any advice? Thanks.


Just an update. Not sure this is possible, I am thinking to call “Load” function (Load button) in DCM module using code. Now I can import the DICOM files into DICOMdatabase using the following code:

dicomFilesDirectory = r"C:\MyDicomFoldercontainsFivefolders"
dicomBrowser = slicer.modules.DICOMWidget.browserWidget.dicomBrowser
# use dicomBrowser.ImportDirectoryCopy to make a copy of the files (useful for importing data from removable storage)
dicomBrowser.importDirectory(dicomFilesDirectory, dicomBrowser.ImportDirectoryAddLink)
# wait for import to finish before proceeding (optional, if removed then import runs in the background)

After checking the source code of, I found that “Load” button is calling “loadCheckedLoadables” function, but I cannot call this function using “dicomBrowser.loadCheckedLoadables()”. Any suggestion on how to do that?

Thank you!

Thanks for reporting this. When using loadSeriesByUID from Python, the function loaded all possible interpretations of the series. It makes more sense to use only the highest-confidence loadable by default (as it is done when using the DICOM browser in the non-advanced mode). I’ve changed the function accordingly - the update will be available in Slicer Preview Releases from tomorrow.

Thank you, Andras. The Preview Release solved the problem!

A post was split to a new topic: Radiomics error - No module named ‘pywt’