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

沈庄明 zhuangming.shen at sphic.org.cn
Mon May 2 22:40:02 EDT 2016


Hi Dženan,


Thanks for your prompt response. I used ITK 4.9.1 and your attached code (just changed inDir and outFile) to test both public DICOM data (http://www.osirix-viewer.com/datasets/DATA/BREBIX.zip) and private DICOM data, the results are still incorrect (please see the attached screenshot). What's the problem?


Besides, as far as I know, rescaling the intensity from short type to char type leads to lose precision because the DICOM tags ( (0028,0100) and (0028,0101) ) show the BitsAllocated is 16-bits and the BitsStored is 12-bits. Consequently, this solution doesn't seem to be a good solution. Is it possible to output the DICOM file by other tools (e.g. DCMTK) if the GDCM doesn't support short type?​



Regards,


Zhuangming Shen




________________________________
From: Dženan Zukić <dzenanz at gmail.com>
Sent: Friday, April 29, 2016 9:59 PM
To: 沈庄明
Cc: insight-users at itk.org; Matt McCormick
Subject: Re: [ITK-users] Strange situation when ITK writes DICOM file

Hi Shen,

GDCM version was updated recently. It now complains that short type is unsupported, and works correctly with char type. I attached an example which rescales the intensity and works correctly.

Regards,
Dženan

On Fri, Apr 29, 2016 at 3:17 AM, 沈庄明 <zhuangming.shen at sphic.org.cn<mailto:zhuangming.shen at sphic.org.cn>> wrote:

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<mailto:dzenanz at gmail.com>>
Sent: Saturday, December 26, 2015 1:44 AM
To: 沈庄明
Cc: insight-users at itk.org<mailto: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/20160503/88a004c0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Result.png
Type: image/png
Size: 23765 bytes
Desc: Result.png
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20160503/88a004c0/attachment.png>


More information about the Insight-users mailing list