# DICOM to NRRD conversion in command line (for PyRadiomics)

**URL:** <https://discourse.slicer.org/t/dicom-to-nrrd-conversion-in-command-line-for-pyradiomics/32306>\
**Category:** Support\
**Tags:** dicom, nrrd, radiomics, batch, pyradiomics\
**Created:** [October 18, 2023, 4:00pm UTC](https://discourse.slicer.org/t/dicom-to-nrrd-conversion-in-command-line-for-pyradiomics/32306 "2023-10-18T16:00:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcin.jakalski](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@marcin.jakalski](https://discourse.slicer.org/u/marcin.jakalski)\
**Post date:** [October 18, 2023, 4:00pm UTC](https://discourse.slicer.org/t/dicom-to-nrrd-conversion-in-command-line-for-pyradiomics/32306/1 "2023-10-18T16:00:31Z")

</div>

Hello! I would like to recreate some of the functionality of 3D Slicer in command line for batch analysis of several hundred of patients’ images. I have a set of DICOM images along with their segmentations. For these I want to calculate radiomics features. It is fairly easy to do using GUI for a single case, but not for the entire set of patients.  
I noticed, that when running Radiomics feature extraction within Slicer, two NRRD files are being created in the temporary directory, as well as an CSV file and a JSON file with run parameters. I assume these two NRRD files correspond to the image and the mask (segment). I would like to be able to create the same kind of files directly on the command line.  
I’ve already tried using different tools/scripts for converting original images and segments to either NII or NRRD (as required by pyradiomics command line tool) but these always seem to be invalid, namely - there is some problem, such as mismatched input’s size:  
`pyradiomics Image.nii Segmentation.nii`  
`sitk::ERROR: Input "labelImage" for "LabelStatisticsImageFilter" has size of [512, 512, 134] which does not match the primary input's size of [512, 512, 536]!`

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 18, 2023, 5:50pm UTC](https://discourse.slicer.org/t/dicom-to-nrrd-conversion-in-command-line-for-pyradiomics/32306/2 "2023-10-18T17:50:25Z")

</div>

Probably the same answer as this post: [radiologist saved segmentations without references -\> annotations come out cropped when loading as numpy arrays - #2 by pieper](https://discourse.slicer.org/t/radiologist-saved-segmentations-without-references-annotations-come-out-cropped-when-loading-as-numpy-arrays/32277/2)
