[Insight-users] DICOM vs ITK orientation

Dan Mueller dan.muel at gmail.com
Sat Jun 22 02:29:29 EDT 2013


Hi Tim,

What ImageIO are you using? If you have not specified, I believe ITK
uses DCMTK by default. (DCMTK is the recommended ImageIO plugin for
DCM file format).

You can find the source code for the relevant DCMTK ImageIO files here:
    https://github.com/Kitware/ITK/blob/master/Modules/IO/DCMTK/src/itkDCMTKImageIO.cxx
    https://github.com/Kitware/ITK/blob/master/Modules/IO/DCMTK/src/itkDCMTKFileReader.cxx

(Being able to directly inspect the source code is only one of the
many reasons for using open source software!)

As can be seen in itkDCMTKImageIO.cxx @ L273, the ITK image will
contain the direction cosines computed by the function GetDirCosArray
in itkDCMTKFileReader.cxx @ L1078. In the first instance this function
uses the Image Orientation (0x0020,0x0037) tag to obtain the direction
matrix.

You are correct that reading a 2D image will only use the first two
rows of this matrix (i.e. 2x2 matrix), see:
    https://github.com/Kitware/ITK/blob/master/Modules/IO/DCMTK/src/itkDCMTKImageIO.cxx#L281

Also, as can be seen in itkImageBase.h, the DirectionType is a matrix
of VImageDimension x VImageDimension (i.e. 2x2 matrix for 2D image):
    https://github.com/Kitware/ITK/blob/master/Modules/Core/Common/include/itkImageBase.h#L162

If you want to read a 2D image oriented in 3D space, then you can read
it as a 3D image with one slice (i.e. simply use ImageDimension = 3).
If your image is 3D, but you want to operate on a single slide only,
then you can use ExtractImageFilter to extract a single-slice 3D
image. In terms of computational overhead, using a 2D image or a
single-slice 3D image is virtual synonymous. Using a single-slice 3D
image will allow you to retain the full 3D orientation information.

HTH

Cheers, Dan

On 22 June 2013 03:04, Tim Allman <dr.tim.allman at gmail.com> wrote:
> Actually, as far as I can tell, ITK does not use DICOM orientation.
>
> Encoded in the DICOM tag "Image Orientation (Patient)" are two 3D vectors.
> The first gives the orientation in 3D space if the first row of the image
> and the second gives the orientation of the first column. (If the image is
> 3D, the third axis, which is normal to the plane of the other two, is
> calculated as the cross product of the first two vectors). Because a 2D
> image is embedded in 3D space, it needs the 3D vectors for correct
> orientation.
>
> The orientation (direction in ITK) in ITK is given as a 3x3x3 matrix in a 3D
> image which is correct. However, a 2D image contains only a 2x2 direction
> matrix instead of the 2x3 matrix implied by the DICOM tag. The orientation
> is lost when extracting a slice from a 3D image using the
> itk::ExtractImageFilter regardless of the direction collapse strategy.
>
> Please let me know if my analysis is incorrect.
>
> Thanks,
> Tim
>
>
>
>
> On 13-06-19 06:37 PM, Bill Lorensen wrote:
>
> ITK uses the DICOM orientation information.
>
>
> On Wed, Jun 19, 2013 at 2:13 PM, Tim Allman <dr.tim.allman at gmail.com> wrote:
>>
>> I have been trying to make sense of both systems of describing orientation
>> but without success. Is there a function or some documentation somewhere
>> that describes how to convert one to the other?
>>
>> Thanks,
>> Tim
>>
>> --
>> Tim Allman, Ph.D.
>> 35 Margaret Street,
>> Guelph Ontario N1E 5R6
>> Canada
>>
>>
>> _____________________________________
>> 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://www.itk.org/mailman/listinfo/insight-users
>>
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
>
> --
> Tim Allman, Ph.D.
> 35 Margaret Street,
> Guelph Ontario N1E 5R6
> Canada
>
>
> _____________________________________
> 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://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list