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

Matt McCormick matt.mccormick at kitware.com
Thu May 19 13:22:50 EDT 2016


Hi Zhuangming,

That is great to hear.

As far as the data types supported by GDCM that are exposed by ITK,
this code snippet is informative:

  https://github.com/InsightSoftwareConsortium/ITK/blob/417d6a36d01aa3b835855349cc481a9b3dca8506/Modules/IO/GDCM/src/itkGDCMImageIO.cxx#L334-L370

Hope this helps,
Matt

On Mon, May 9, 2016 at 8:45 PM, 沈庄明 <zhuangming.shen at sphic.org.cn> wrote:
> Hi Matt,
>
> Thank you for your reply.  I have tried to use ITK Git master and the code provided by Dženan, it can work correctly. Thanks again.
>
> By the way, could you list what data types (e.g. char type) do the updated GDCM support now?
>
>
> Regards,
>
> Zhuangming Shen
> ________________________________________
> From: Matt McCormick <matt.mccormick at kitware.com>
> Sent: Thursday, May 5, 2016 10:21 PM
> To: 沈庄明
> Cc: Dženan Zukić; insight-users at itk.org
> Subject: Re: [ITK-users] Strange situation when ITK writes DICOM file
>
> Hi Zhuangming Shen,
>
> GDCM was updated in ITK Git master, to be released in ITK 4.10.
> Instructions on how to obtain this version can be found here:
>
>   https://itk.org/Wiki/ITK/Git/Download
>
> Thanks,
> Matt
>
> On Mon, May 2, 2016 at 10:40 PM, 沈庄明 <zhuangming.shen at sphic.org.cn> wrote:
>> 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> wrote:
>>>
>>> Hi Dženan,
>>>
>>>
>>> I'd like to know if the bug 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 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> 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
>>>>
>>>> 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
>>>>
>>>
>>
_____________________________________
Powered by 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


More information about the Community mailing list