How to convert dicom files to nrrd

Operating system:Windows
Slicer version:4.6.2
Expected behavior:
Actual behavior:

Use the DICOM module to import the files, and then export as NRRD:

https://www.slicer.org/wiki/Documentation/Nightly/Modules/DICOM

When I do that, only one of the three files saves as an nrrd. I need the
segmentation to also be in nrrd form in order for it to be used by
pyradiomics. How can I convert that segment then also to nrrd, as it is not
a choice to save it as that.

Export it to labelmap node using Segmentations module (Import/Export section).

If you are on Mac or Windows, you can also use SlicerRadiomics extension to calculate pyradiomics features. SlicerRadiomics works with either label maps, or segmentations.

Do you know of anywhere I can go to learn how to use SlicerRadiomics? I now
have it installed, but I cannot find how to use the extension.

We have very basic usage instructions here: https://github.com/Radiomics/SlicerRadiomics/blob/master/USAGE.md#usage

Are there specific issues where you are confused? It would be helpful to get some feedback what are exactly the challenges using the module.

Hello, I’m new to Slicer
Could you send updated instructions for how to convert a DICOM folder to NRRD?
Thanks
James

Please refer to the comment of @ihnorton

You can save the loaded DICOM volume as NRRD in the Save data dialog.

hello,i am on the same boat,i am looking at mass conversion of thousands of dicom files to nrrd.
hence thought to use it in python script to automate it. is there any way that i can use command line slicer to mass convert dicom to nrrd ?

You can load DICOM from python like this

from DICOMLib import DICOMUtils
DICOMUtils.openDatabase('path/to/tempDatabase') # For batch processing it's better to use a  temporary database
DICOMUtils.loadPatientByUID(patientUID)

You can load patients by name, UID, and patient ID (an incremental integer Slicer assigns to imported patients), see https://github.com/Slicer/Slicer/blob/master/Modules/Scripted/DICOMLib/DICOMUtils.py#L105-L110

Then you can save NRRD like this

slicer.util.saveNode(node, 'fileName.nrrd')

For this you’ll need the MRML node which you can get in several ways, depending how you want your batch script to operate (for example dynamically with onNodeAdded, by getting the last volume node from the scene, or simply by closing scene after each save and get the only volume node)

2 Likes

You can also consider one of the many tools out there that are much easier to use than Slicer for batch volume reconstruction (faster, easier to use, possibly more robust).

You can find a list of some of the most popular ones (incomplete, I am sure) here: https://na-mic.github.io/ProjectWeek/PW27_2018_Boston/Projects/DICOMVolumeReconstruction/.

A number of them (including Slicer converters) are set up in this dockerfile: https://github.com/QIICR/dcmheat/blob/master/docker/Dockerfile (just noticed the corresponding container on Docker Hub is broken, I need to fix that).

How they compare to each other and which specific one to recommend remains the open question (for me at least). As we make progress with the project referenced above, hopefully we will be able to recommend one specific tool, or say that all/subset of them are equivalent for practical purposes.

And just to make sure this is clear: converting DICOM to nrrd is not a simple well defined operation in general. DICOM is a very expressive and flexible standard and there are several possibilities for any one collection of DICOM files:

  • it may correspond to many nrrd files (e.g. different series in a study)
  • there may be more than one valid conversion and only the user knows which is preferred
  • it may not be possible for nrrd to represent the DICOM data (such as a DICOM structured report or something)

That said, if you are dealing with a fairly standard case like converting one CT series to a nrrd scalar volume there are many good options as @fedorov points out. It all depends on the data and what you hope to use it for. Luckily there are lots of examples to learn from and by writing a script you can control the process to get what you need.

2 Likes