[ITK-users] Strange situation when ITK writes DICOM file

沈庄明 zhuangming.shen at sphic.org.cn
Fri Apr 29 03:17:15 EDT 2016


Hi Dženan,

​

I'd like to know if the bug<https://issues.itk.org/jira/browse/ITK-3407><https://issues.itk.org/jira/browse/ITK-3407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel> regarding 3D DICOM writer has been fixed. When I tried to run the same code but using ITK 4.9.1, I still got the same results, i.e. the output DICOM file does not properly record original image's origin and spacing.



Regards,


Zhuangming Shen

________________________________
From: Dženan Zukić <dzenanz at gmail.com>
Sent: Saturday, December 26, 2015 1:44 AM
To: 沈庄明
Cc: insight-users at itk.org
Subject: Re: [ITK-users] Strange situation when ITK writes DICOM file

​I have confirmed this bug and entered it into tracker<https://issues.itk.org/jira/browse/ITK-3407> along with a DICOM series which reproduces it.​

Thanks Shen

On Tue, Dec 22, 2015 at 8:41 PM, 沈庄明 <zhuangming.shen at sphic.org.cn<mailto:zhuangming.shen at sphic.org.cn>> wrote:

Hi all,


I met a very strange situation when I used ITK 4.8.1. I'd like to read a DICOM series, write it to a DICOM file (i.e. save the volume created by the DICOM series to a .dcm file), and read the DICOM file. Theoretically, the DICOM series and the DCM file should have the same information, e.g origin, spacing, size. However, My results show me that the information has been changed. When I use other ITK-support file format (e.g. nii, nrrd), the information has not been changed. It seems a bug. My code and results are listed as below. Has anyone met the same situation?


Regards,


Zhuangming Shen



​

================   My code  =================


import itk

input_dir = "/home/zshen/workspace/Data/testDCM/bbb"
output_filename = "/home/zshen/workspace/Data/bbb2.dcm"

# read DICOM series
dicom_io = itk.GDCMImageIO.New()

reader = itk.ImageSeriesReader[itk.Image.SS3].New()
reader.SetImageIO(dicom_io)

name_generator = itk.GDCMSeriesFileNames.New()
name_generator.SetUseSeriesDetails(True)
name_generator.SetDirectory(input_dir)

series_uid = name_generator.GetSeriesUIDs()

series_identifier = series_uid[0]

file_names = name_generator.GetFileNames(series_identifier)

reader.SetFileNames(file_names)
reader.Update()

print("****  series DICOM information: *****")
print("size: "+str(reader.GetOutput().GetLargestPossibleRegion().GetSize()))
print("origin: "+str(reader.GetOutput().GetOrigin()))
print("spacing: "+str(reader.GetOutput().GetSpacing()))

writer = itk.ImageFileWriter[itk.Image.SS3].New()
writer.SetInput(reader.GetOutput())
writer.SetFileName(output_filename)
writer.Update()

# read again
reader2 = itk.ImageFileReader[itk.Image.SS3].New()
reader2.SetFileName(output_filename)
reader2.Update()

print("****  DICOM information: *****")
print("size: "+str(reader2.GetOutput().GetLargestPossibleRegion().GetSize()))
print("origin: "+str(reader2.GetOutput().GetOrigin()))
print("spacing: "+str(reader2.GetOutput().GetSpacing()))


=================  My results ====================

****  series DICOM information: *****
size: itkSize3 ([512, 512, 118])
origin: itkPointD3 ([-229.5, -96.5, -553])
spacing: itkVectorD3 ([0.896484, 0.896484, 3])
****  DICOM information: *****
size: itkSize3 ([512, 512, 118])
origin: itkPointD3 ([0, 0, 0])
spacing: itkVectorD3 ([0.896484, 0.896484, 1])




_____________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160429/3666da0d/attachment.html>


More information about the Insight-users mailing list