# Convert MRI from DICOM (exported by syngo.via) to NRRD

**URL:** https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555
**Category:** Support
**Created:** [April 10, 2018, 9:06am UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555 "2018-04-10T09:06:03Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Tommaso\_Di\_Noto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tommaso_di_noto/32/6802_2.png) [@Tommaso\_Di\_Noto](https://discourse.slicer.org/u/Tommaso_Di_Noto)
#### Post date: [April 10, 2018, 9:06am UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/1 "2018-04-10T09:06:03Z")

</div>

Hello everyone!  
I have a series of MRI cardiac images (more specifically I have the most significant slice for each patient; i.e. one image for each patient). I have extracted all these images with the software Siemens Syngo Via in a DICOM format.

Since I want to mine these data with a machine learning approach, I wanted to use the open-source platform [pyradiomics](https://github.com/Radiomics/pyradiomics). In order to use this package I need the images in the .nrrd format, so I followed this [guide](https://na-mic.org/w/images/6/6c/2012-SPIE-1-DICOMToNRRDConversionTutorial.pdf) and it worked well.

The only problem is that the new .nrrd images have a different pixel spacing from the original dicom ones. More specifically they now have a pixel spacing in microns and not in mm like before. Moreover, the spacing has been automatically re-set to (1,1) while before it was something like (0.89,0.89). Does 3D slicer automatically rescale images?

How could I solve this issue?

Thanks a lot in advance,  
Tommaso

---

<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: [April 10, 2018, 11:59am UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/2 "2018-04-10T11:59:30Z")

</div>

> [@Tommaso\_Di\_Noto](#):
>
> Does 3D slicer automatically rescale images?

Slicer will use the data from the header (in mm) but you can change this in the Volumes → Volume Information fields and resave if you want.

---

<div class="post-metadata">

### Author: ![Tommaso\_Di\_Noto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tommaso_di_noto/32/6802_2.png) [@Tommaso\_Di\_Noto](https://discourse.slicer.org/u/Tommaso_Di_Noto)
#### Post date: [April 10, 2018, 12:17pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/3 "2018-04-10T12:17:14Z")

</div>

Hi Pieper and thanks for answering my question!

Maybe I have expressed myself wrong. I know that it is possible to modify the spacing in Volumes\>Volume information…the fact is that if I open my DICOM image for instance in ImageJ I have a 512x512 matrix with a FOV of 460x460 mm^2 and hence a pixel spacing of about 0,89 (469/512), while both when I open the same DICOM image with 3D slicer and I save it to .nrrd I get (1,1,1) mm as pixel spacing and not for instance (0.89, 0.89, 0) as I would expect.

Is this normal?  
Thanks a lot again

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [April 10, 2018, 1:43pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/4 "2018-04-10T13:43:17Z")

</div>

If you have access to the original DICOM I suggest loading that to Slicer and saving it as nrrd, without using Syngo Via’s export option. Slicer should interpret the original DICOM correctly and the nrrd file sohuld come out as expected.

---

<div class="post-metadata">

### Author: ![Tommaso\_Di\_Noto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tommaso_di_noto/32/6802_2.png) [@Tommaso\_Di\_Noto](https://discourse.slicer.org/u/Tommaso_Di_Noto)
#### Post date: [April 10, 2018, 2:10pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/5 "2018-04-10T14:10:08Z")

</div>

Hi Csaba!  
I had to go necessarily through SyngoVia because the software they are using here at the hospital for the PACS is Agfa IMPAX and, unfortunately, doesn’t allow the DICOM extraction

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [April 10, 2018, 3:17pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/6 "2018-04-10T15:17:16Z")

</div>

I see, thanks for the clarification. I’m not familiar with SyngoVia, but maybe it has some export options to keep as much of the original DICOM metadata as possible.

@fedorov If I remember correctly you have worked with SyngoVia. Did you have an established protocol for DICOM export that worked well with Slicer?

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [April 10, 2018, 3:51pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/7 "2018-04-10T15:51:32Z")

</div>

On our installation, there is a standard DICOM export to file system feature. I cannot explain the discrepancy between Slicer and ImageJ that is happening in the case of @Tommaso_Di_Noto. Not sure how to debug it without access to a sample dataset.

---

<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: [April 10, 2018, 10:37pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/8 "2018-04-10T22:37:08Z")

</div>

If Imagej is writing out the spacing as .89, .89, 0 then ITK may think it cannot read valid spacing and default to 1,1,1.

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [April 11, 2018, 12:59am UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/9 "2018-04-11T00:59:37Z")

</div>

@pieper the way I understood it, the issue is that image is read from DICOM both in Slicer and ImageJ, but the spacing interpreted from DICOM is different.

---

<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: [April 11, 2018, 11:43am UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/10 "2018-04-11T11:43:26Z")

</div>

> [@fedorov](#):
>
> @pieper the way I understood it, the issue is that image is read from DICOM both in Slicer and ImageJ, but the spacing interpreted from DICOM is different.

Yes, could be - @Tommaso_Di_Noto can you clarify?

---

<div class="post-metadata">

### Author: ![JoostJM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joostjm/32/1091_2.png) [@JoostJM](https://discourse.slicer.org/u/JoostJM)
#### Post date: [April 11, 2018, 12:00pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/11 "2018-04-11T12:00:04Z")

</div>

I’ve been helping @Tommaso_Di_Noto on this error as well, see also [this](https://github.com/Radiomics/pyradiomics/issues/360) issue in PyRadiomics.

As far as I can see, ITK (ITKsnap also misinterpreted the DICOM spacing) is having troubles parsing the spacing as it is encoded in the DICOM. In an example @Tommaso_Di_Noto sent, spacing was encoded as `[5.0781200E-001\5.0781200E-001]`, maybe there is an issue with dealing with the `E-001`?

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [April 11, 2018, 1:44pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/12 "2018-04-11T13:44:44Z")

</div>

@JoostJM no, this is a valid content for PixelSpacing (see [http://dicom.nema.org/dicom/2013/output/chtml/part05/sect\_6.2.html](http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_6.2.html)). I also made a fake dataset with exact same PixelSpacing, and confirmed it is read correctly into Slicer. Must be something else.

@Tommaso_Di_Noto can you run this DICOM validator on your dataset and let us know what it says: [http://www.dclunie.com/dicom3tools/dciodvfy.html](http://www.dclunie.com/dicom3tools/dciodvfy.html)

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [April 11, 2018, 1:54pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/13 "2018-04-11T13:54:47Z")

</div>

I also checked that SimpleITK can read the dataset I created for testing, and it does not reset spacing to 1.

```auto
$ dcmdump image/IMG0001.dcm|grep Spacing 2.3.6
(0028,0030) DS [5.0781200E-001\5.0781200E-001] # 30, 2 PixelSpacing
...
In [3]: i=sitk.ReadImage("image/IMG0001.dcm")
In [5]: i.GetSpacing()
Out[5]: (0.507812, 0.507812, 1.0)

```

---

<div class="post-metadata">

### Author: ![JoostJM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joostjm/32/1091_2.png) [@JoostJM](https://discourse.slicer.org/u/JoostJM)
#### Post date: [April 11, 2018, 2:00pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/14 "2018-04-11T14:00:45Z")

</div>

Hmm, I rechecked the testset @Tommaso_Di_Noto sent, and I’m seeing that the ImageOrientationPatient (0020,0037) and ImagePositionPatient (0020,0032) are missing, could this cause the error perhaps?

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [April 11, 2018, 2:02pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/15 "2018-04-11T14:02:17Z")

</div>

Yes, that very likely could be a problem. I don’t know how it is handled by the libraries, but I am pretty sure this will render the dataset non-compliant with the standard.

---

<div class="post-metadata">

### Author: ![Tommaso\_Di\_Noto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tommaso_di_noto/32/6802_2.png) [@Tommaso\_Di\_Noto](https://discourse.slicer.org/u/Tommaso_Di_Noto)
#### Post date: [April 11, 2018, 2:45pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/16 "2018-04-11T14:45:34Z")

</div>

Exactly, Slicer\>Volume shows (1,1,1), while the ImageJ\>Image Info says: Pixel Size: 0.8984x0.8984 mm^2

---

<div class="post-metadata">

### Author: ![Tommaso\_Di\_Noto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tommaso_di_noto/32/6802_2.png) [@Tommaso\_Di\_Noto](https://discourse.slicer.org/u/Tommaso_Di_Noto)
#### Post date: [April 11, 2018, 3:13pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/17 "2018-04-11T15:13:30Z")

</div>

@pieper @fedorov Sorry if I’m only answering now, but my Slicer/gmail notification was turned off, so I only saw your replies now. I turned it on now! Anyway:

@JoostJM: Yes, I’ve also checked the cardiac images and the ImageOrientationPatient (0020,0037) and ImagePositionPatient (0020,0032) are missing there too.

As far as the feature extraction is concerned, do you think it’s a problem if I go forward with this .dcm to .nrrd conversion done in Slicer? I though that since it rescales ALL images to (1,1,1) and the .nrrd image created is read without errors in PyRadiomics, features shouldn’t suffer from different pixel spacing issues. I tried to explain more or less the same thing [here](https://github.com/Radiomics/pyradiomics/issues/360#issuecomment-380354094).

Let me know if this makes sense 😉

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [April 11, 2018, 3:14pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/18 "2018-04-11T15:14:47Z")

</div>

@JoostJM shared the pointer to the dataset. It is a secondary capture, and it doesn’t have to have the position/orientation. Probably ITK resets to spacing of 1 when those are missing, since it is not possible to know the 3d geometry of the image. Since ImageJ operates purely in 2d, it does not need to worry about geometry, and so this does not trigger an issue there.

@Tommaso_Di_Noto I think your options are:

1. explore if you can export the dataset as MR, not secondary capture - have you tried export to file system option in syngo.via?
2. modify the spacing manually or in a script to use the one from the secondary capture `PixelSpacing`

In-plane spacing matters for some of the radiomics features, so it can be important.

---

<div class="post-metadata">

### Author: ![Tommaso\_Di\_Noto](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/tommaso_di_noto/32/6802_2.png) [@Tommaso\_Di\_Noto](https://discourse.slicer.org/u/Tommaso_Di_Noto)
#### Post date: [April 11, 2018, 3:39pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/19 "2018-04-11T15:39:39Z")

</div>

@fedorov

 ![syngo_via](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/3/a32599dfeb938193dfc8549be5f5652e128aa740.png)

In yellow I have highlighted the options I chose when I extracted the images;

(The white circles are just to shade the patient’s name)

What could I change?

Eventually, if I wanted to manually change the spacing, how could I do it? I mean…with which program? And should I do it on the original .dcm extracted from SyngoVia or on the .nrrd extracted from Slicer?

Thanks a lot!!

---

<div class="post-metadata">

### Author: ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)
#### Post date: [April 11, 2018, 6:29pm UTC](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555/20 "2018-04-11T18:29:42Z")

</div>

> [@Tommaso\_Di\_Noto](#):
>
> What could I change?

Indeed, that’s what I would do too. Not sure, perhaps secondary capture is what is on PACS.

> [@Tommaso\_Di\_Noto](#):
>
> Eventually, if I wanted to manually change the spacing, how could I do it? I mean…with which program? And should I do it on the original .dcm extracted from SyngoVia or on the .nrrd extracted from Slicer?

```bash
$ pip install SimpleITK
$ pip install pydicom

```

Then you can use something like this script:

```python
import SimpleITK as sitk
import pydicom, sys

i = sitk.ReadImage(sys.argv[1])
d = pydicom.read_file(sys.argv[1])
s = d.PixelSpacing[0]
i.SetSpacing([s,s,1])
sitk.WriteImage(i,sys.argv[2])

```

[Next page](https://discourse.slicer.org/t/convert-mri-from-dicom-exported-by-syngo-via-to-nrrd/2555.md?page=2)
