# Trouble getting the real spacing of a DICOM serie using vtkImageData

**URL:** <https://discourse.slicer.org/t/trouble-getting-the-real-spacing-of-a-dicom-serie-using-vtkimagedata/361>\
**Category:** Development\
**Created:** [May 23, 2017, 9:07am UTC](https://discourse.slicer.org/t/trouble-getting-the-real-spacing-of-a-dicom-serie-using-vtkimagedata/361 "2017-05-23T09:07:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandra](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@sandra](https://discourse.slicer.org/u/sandra)\
**Post date:** [May 23, 2017, 9:07am UTC](https://discourse.slicer.org/t/trouble-getting-the-real-spacing-of-a-dicom-serie-using-vtkimagedata/361/1 "2017-05-23T09:07:55Z")

</div>

Operating system: Mac  
Slicer version: 4.6.2

Hi everyone !

I’m currently working on my loadable module and I would need to get the real spacing of a DICOM serie using vtkImageData. I explain:

the user loads a DICOM serie (using DICOM module) and selects the corresponding node in my module,  
then I do:

```cpp
vtkMRMLScalarVolumeNode* volumeNode = vtkMRMLScalarVolumeNode::SafeDownCast(d->volumeSelector->currentNode());
vtkImageData* image = volumeNode->GetImageData();
double spacing[3];
image->GetSpacing(spacing);

```

And I get `spacing=[1,1,1]`  
But, when the DICOM serie is loaded, I can see in the “Volumes” module that the spacing is different (something like `[1.5 1.5 4]`).

How can I get the real spacing of the DICOM serie in my code (and not `[1 1 1]` ) ?

Thank you for your help,

Regards,  
Sandra.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 23, 2017, 11:05am UTC](https://discourse.slicer.org/t/trouble-getting-the-real-spacing-of-a-dicom-serie-using-vtkimagedata/361/2 "2017-05-23T11:05:26Z")

</div>

```cpp
volumeNode->GetSpacing(spacing);

```

Unfortunately, VTK cannot store axis directions, therefore IJK to RAS transformation (origin, spacing, axis directions) has to be stored outside `vtkImageData`, in the volume node. In `vtkImageData`, origin must be kept at `(0,0,0)`, spacing must be kept at `(1,1,1)`.

---

<div class="post-metadata">

**Author:** ![sandra](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@sandra](https://discourse.slicer.org/u/sandra)\
**Post date:** [May 23, 2017, 11:33am UTC](https://discourse.slicer.org/t/trouble-getting-the-real-spacing-of-a-dicom-serie-using-vtkimagedata/361/3 "2017-05-23T11:33:21Z")

</div>

“volumeNode-\>GetSpacing(spacing);” : that will do for what I need, thank you for these information and for your help 🙂
