# Adding Patient position tag in each slice while writing a dicom series

**URL:** https://discourse.itk.org/t/adding-patient-position-tag-in-each-slice-while-writing-a-dicom-series/3467
**Category:** Beginner Questions
**Created:** [September 18, 2020, 6:30am UTC](https://discourse.itk.org/t/adding-patient-position-tag-in-each-slice-while-writing-a-dicom-series/3467 "2020-09-18T06:30:48Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Hasna](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/f07891/32.png) [@Hasna](https://discourse.itk.org/u/Hasna)
#### Post date: [September 18, 2020, 6:30am UTC](https://discourse.itk.org/t/adding-patient-position-tag-in-each-slice-while-writing-a-dicom-series/3467/1 "2020-09-18T06:30:48Z")

</div>

Hi,

I am trying generate a dicom series from volume data.  
How can should i give the patient position tag ,orientation tag and pixel spacing tag for each slice? Should I add them in a loop?

I could not find any examples for this. If any reference is there, it will be helpful.

Thanks  
Hasna

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [September 18, 2020, 12:43pm UTC](https://discourse.itk.org/t/adding-patient-position-tag-in-each-slice-while-writing-a-dicom-series/3467/2 "2020-09-18T12:43:46Z")

</div>

Hello @Hasna,

As you haven’t specified if you are using SimpleITK or ITK, I’ll assume SimpleITK and point you to [this example](https://simpleitk.readthedocs.io/en/master/link_DicomSeriesFromArray_docs.html) of writing a DICOM series from array. Hopefully this is what you are looking for. If not, please provide additional details.

---

<div class="post-metadata">

### Author: ![Hasna](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/f07891/32.png) [@Hasna](https://discourse.itk.org/u/Hasna)
#### Post date: [September 18, 2020, 12:48pm UTC](https://discourse.itk.org/t/adding-patient-position-tag-in-each-slice-while-writing-a-dicom-series/3467/3 "2020-09-18T12:48:04Z")

</div>

Hi @zivy I am using ITK. This is what i wanted. Is there any example code implemented in ITK?

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [September 18, 2020, 12:53pm UTC](https://discourse.itk.org/t/adding-patient-position-tag-in-each-slice-while-writing-a-dicom-series/3467/4 "2020-09-18T12:53:02Z")

</div>

Hi @Hasna,

I don’t think so. In any case all of the ITK examples can be [found here](https://itk.org/ITKExamples/src/index.html), so possibly there is one there.

@dzenanz knows this better than me, so possibly he points you in the right direction.

---

<div class="post-metadata">

### Author: ![Hasna](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/f07891/32.png) [@Hasna](https://discourse.itk.org/u/Hasna)
#### Post date: [September 18, 2020, 12:55pm UTC](https://discourse.itk.org/t/adding-patient-position-tag-in-each-slice-while-writing-a-dicom-series/3467/5 "2020-09-18T12:55:35Z")

</div>

Hi @zivy,

I will go through this reference. Thanks a lot !!

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 18, 2020, 2:45pm UTC](https://discourse.itk.org/t/adding-patient-position-tag-in-each-slice-while-writing-a-dicom-series/3467/6 "2020-09-18T14:45:18Z")

</div>

How about [this example](https://itk.org/ITKExamples/src/IO/GDCM/ResampleDICOMSeries/Documentation.html)? If you are not starting from a DICOM input, I think you need to “invent” a patient and a study in order to write a DICOM series.

If you don’t need a series, can you try using a regular ITK writer and asking for a file name which ends with `.dcm`? Or explicitly setting `GDCMImageIO` on the writer?

---

<div class="post-metadata">

### Author: ![Hasna](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/f07891/32.png) [@Hasna](https://discourse.itk.org/u/Hasna)
#### Post date: [September 18, 2020, 3:21pm UTC](https://discourse.itk.org/t/adding-patient-position-tag-in-each-slice-while-writing-a-dicom-series/3467/7 "2020-09-18T15:21:14Z")

</div>

Hi @dzenanz,

Thank you for the reference.

I am not starting from a dicom series.  
If I use regular image series writer with filename ending with .dcm, the patient position and orientation tags are not updating. Anyways I am working using the reference you gave.
