I am trying to create a python script that can import a DICOM image series from a folder, however I can’t seem to find a way to make this work.
I can load a single DICOM file (in my case an RTSTRUCT) using this code:
contour_fn = 'contours.dcm'
# Add filename to list for DICOM-RT module
contour_vtkFileList = vtk.vtkStringArray()
# Examine files
contour_loadablesCollection = vtk.vtkCollection()
# Set name for when loaded
# Load file
contour_success = slicer.modules.dicomrtimportexport.logic().LoadDicomRT(contour_loadablesCollection.GetItemAsObject(0))
However, if I create a list of filenames to load, it doesn’t seem to work correctly. Specifically, my ‘loadablesCollection’ is empty.
Is there a way to do this? I have seen options for loading patients from the DICOM browser, but I don’t want to have to import all the data through that if possible. Also, I’m not sure what the patient name will be, so don’t know how I would do a load by name/ID.
You can also take a look at this python module that provides a command line tool to essentially take a folder with DICOM data, and organize it into patient/study/series hierarchy of folders accompanied by volumetric reconstructions for each series. It does not handle RT, but it should be easy to add that. You can also find more details here: How can I convert DICOM series to NRRD files in batch mode?.
Hi, i am trying to import a dicom series directory by python scripting, i just found the command 'slicer.util.loadNodeFromFile /loadScene/loadVolume ’ , is there any other function to load the dicom series from directory ?