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


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.


Hello @Hasna,

As you haven’t specified if you are using SimpleITK or ITK, I’ll assume SimpleITK and point you to this example of writing a DICOM series from array. Hopefully this is what you are looking for. If not, please provide additional details.

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

Hi @Hasna,

I don’t think so. In any case all of the ITK examples can be found here, so possibly there is one there.

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

Hi @zivy,

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

How about this example? 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?

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.