Transforming image to world coordinates with negative z axis

View: New views
7 Messages — Rating Filter:   Alert me  

Transforming image to world coordinates with negative z axis

by John M. Drescher :: Rate this Message:

| View Threaded | Show Only this Message

I am loading a dicom CT series in image # order

The first slice is:
0020|0032 Image Position (Patient) = -164.300\-169.500\-24.750
0020|0037 Image Orientation (Patient) =
1.000000\0.000000\0.000000\0.000000\1.000000\0.000000

And the last slice is:
0020|0032 Image Position (Patient) = -164.300\-169.500\-359.750
0020|0037 Image Orientation (Patient) =
1.000000\0.000000\0.000000\0.000000\1.000000\0.000000

The problem I am having is that TransformIndexToPhysicalPoint is
returning Z values that are positive which is impossible because the z
range is from -24.750 to -359.750. I thought it was the same problem
as

http://www.nabble.com/itk::Image-vs.-itk::OrientedImage-td19899159.html

but my direction vector (examined while debugging) looks wrong to me:
1 0 0
0 1 0
0 0 1

Any ideas how to fix this so that I get the correct world coordinates?
Or am I misunderstanding something? I am quite new at itk and vtk.

I am using itk version is 3.10.2, and vtk-5.2.1.

Thanks,
John M. Drescher
_____________________________________
Powered by www.kitware.com

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

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

Re: Transforming image to world coordinates with negative z axis

by Luis Ibanez :: Rate this Message:

| View Threaded | Show Only this Message

Hi John,

You are right, this looks strange.


Please do the following:

Just after you load your DICOM image into an ITK image,
call the Print() method in the resulting image, and post
the outcome to the mailing list.

Your code should look something like

   imageSeriesReader->Update();

   imageSeriesReader->GetOutput()->Print( std::cout );


The output of the Print() method will help us to locate
the source of the problem.


----


BTW: Why do you say that the direction cosines

 > 1 0 0
 > 0 1 0
 > 0 0 1

look wrong to you ?

Given that the direction cosines in the DICOM header
are

 > 1.000000\0.000000\0.000000\0.000000\1.000000\0.000000

It seems normal to have the Direction matrix to be an
identity matrix.




     Thanks


        Luis


--------------------
John Drescher wrote:

> I am loading a dicom CT series in image # order
>
> The first slice is:
> 0020|0032 Image Position (Patient) = -164.300\-169.500\-24.750
> 0020|0037 Image Orientation (Patient) =
> 1.000000\0.000000\0.000000\0.000000\1.000000\0.000000
>
> And the last slice is:
> 0020|0032 Image Position (Patient) = -164.300\-169.500\-359.750
> 0020|0037 Image Orientation (Patient) =
> 1.000000\0.000000\0.000000\0.000000\1.000000\0.000000
>
> The problem I am having is that TransformIndexToPhysicalPoint is
> returning Z values that are positive which is impossible because the z
> range is from -24.750 to -359.750. I thought it was the same problem
> as
>
> http://www.nabble.com/itk::Image-vs.-itk::OrientedImage-td19899159.html
>
> but my direction vector (examined while debugging) looks wrong to me:
> 1 0 0
> 0 1 0
> 0 0 1
>
> Any ideas how to fix this so that I get the correct world coordinates?
> Or am I misunderstanding something? I am quite new at itk and vtk.
>
> I am using itk version is 3.10.2, and vtk-5.2.1.
>
> Thanks,
> John M. Drescher
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> 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
>
_____________________________________
Powered by www.kitware.com

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

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

Re: Transforming image to world coordinates with negative z axis

by John M. Drescher :: Rate this Message:

| View Threaded | Show Only this Message

> You are right, this looks strange.
>
>
> Please do the following:
>
> Just after you load your DICOM image into an ITK image,
> call the Print() method in the resulting image, and post
> the outcome to the mailing list.
>
> Your code should look something like
>
>  imageSeriesReader->Update();
>
>  imageSeriesReader->GetOutput()->Print( std::cout );
>
>
> The output of the Print() method will help us to locate
> the source of the problem.
>
>

OrientedImage (01D5C650)
  RTTI typeinfo:   class itk::OrientedImage<short,3>
  Reference Count: 1
  Modified Time: 2757
  Debug: Off
  Observers:
    none
  Source: (01D5C508)
  Source output index: 0
  Release Data: Off
  Data Released: False
  Global Release Data: Off
  PipelineMTime: 30
  UpdateMTime: 2758
  LargestPossibleRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [512, 512, 107]
  BufferedRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [512, 512, 107]
  RequestedRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [512, 512, 107]
  Spacing: [0.626953, 0.626953, 2.5]
  Origin: [-174.6, -160.5, -35.685]
  Direction:
1 0 0
0 1 0
0 0 1

  IndexToPointMatrix:
  0.626953 0 0
0 0.626953 0
0 0 2.5

  PointToIndexMatrix:
  1.59502 0 0
0 1.59502 0
0 0 0.4

  PixelContainer:
    ImportImageContainer (01D5C8A0)
      RTTI typeinfo:   class itk::ImportImageContainer<unsigned long,short>
      Reference Count: 1
      Modified Time: 81
      Debug: Off
      Observers:
        none
      Pointer: 03410040
      Container manages memory: true
      Size: 28049408
      Capacity: 28049408

> ----
>
>
> BTW: Why do you say that the direction cosines
>
>> 1 0 0
>> 0 1 0
>> 0 0 1
>
> look wrong to you ?
>
I thought it should be

1 0 0
0 1 0
0 0 -1

so that the z axis coordinate conversion would be handled correctly.

> Given that the direction cosines in the DICOM header
> are
>
>> 1.000000\0.000000\0.000000\0.000000\1.000000\0.000000
>
> It seems normal to have the Direction matrix to be an
> identity matrix.
>
Looks like I have to do some reading.

Thanks for your help,
John
_____________________________________
Powered by www.kitware.com

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

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

Re: Transforming image to world coordinates with negative z axis

by Luis Ibanez :: Rate this Message:

| View Threaded | Show Only this Message

Hi John,

Thanks a lot for posting the output of the Print() method.

It seems that the image is not being read as the last slice
begin located at:

                 Z = -359.750

Instead it is located at:


       Z = -35.685 + 2.5 * 107 =  +231.81

and... even if the spacing was negative,
it could have only got to:

       Z = -35.685 - 2.5 * 107 =  -303.18



This raises suspicion about what you call the


            "last DICOM slice..."


Are you sure that it belongs to the same Series
as the first slice ?


Also,
If you visualize the image that you can read with ITK,
does it look ok ?


BTW: As DICOM readers/viewers you may want to try:


     A) Slicer
        http://www.slicer.org

     B) VV
        http://www.midasjournal.org/browse/publication/288



Please let us know what you find.


     Thanks


        Luis


-------------------
John Drescher wrote:

>>You are right, this looks strange.
>>
>>
>>Please do the following:
>>
>>Just after you load your DICOM image into an ITK image,
>>call the Print() method in the resulting image, and post
>>the outcome to the mailing list.
>>
>>Your code should look something like
>>
>> imageSeriesReader->Update();
>>
>> imageSeriesReader->GetOutput()->Print( std::cout );
>>
>>
>>The output of the Print() method will help us to locate
>>the source of the problem.
>>
>>
>
>
> OrientedImage (01D5C650)
>   RTTI typeinfo:   class itk::OrientedImage<short,3>
>   Reference Count: 1
>   Modified Time: 2757
>   Debug: Off
>   Observers:
>     none
>   Source: (01D5C508)
>   Source output index: 0
>   Release Data: Off
>   Data Released: False
>   Global Release Data: Off
>   PipelineMTime: 30
>   UpdateMTime: 2758
>   LargestPossibleRegion:
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [512, 512, 107]
>   BufferedRegion:
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [512, 512, 107]
>   RequestedRegion:
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [512, 512, 107]
>   Spacing: [0.626953, 0.626953, 2.5]
>   Origin: [-174.6, -160.5, -35.685]
>   Direction:
> 1 0 0
> 0 1 0
> 0 0 1
>
>   IndexToPointMatrix:
>   0.626953 0 0
> 0 0.626953 0
> 0 0 2.5
>
>   PointToIndexMatrix:
>   1.59502 0 0
> 0 1.59502 0
> 0 0 0.4
>
>   PixelContainer:
>     ImportImageContainer (01D5C8A0)
>       RTTI typeinfo:   class itk::ImportImageContainer<unsigned long,short>
>       Reference Count: 1
>       Modified Time: 81
>       Debug: Off
>       Observers:
>         none
>       Pointer: 03410040
>       Container manages memory: true
>       Size: 28049408
>       Capacity: 28049408
>
>
>>----
>>
>>
>>BTW: Why do you say that the direction cosines
>>
>>
>>>1 0 0
>>>0 1 0
>>>0 0 1
>>
>>look wrong to you ?
>>
>
> I thought it should be
>
> 1 0 0
> 0 1 0
> 0 0 -1
>
> so that the z axis coordinate conversion would be handled correctly.
>
>
>>Given that the direction cosines in the DICOM header
>>are
>>
>>
>>>1.000000\0.000000\0.000000\0.000000\1.000000\0.000000
>>
>>It seems normal to have the Direction matrix to be an
>>identity matrix.
>>
>
> Looks like I have to do some reading.
>
> Thanks for your help,
> John
>
_____________________________________
Powered by www.kitware.com

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

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

Re: Transforming image to world coordinates with negative z axis

by John M. Drescher :: Rate this Message:

| View Threaded | Show Only this Message

Luis,
I am Sorry. I will have to get you new output. The debug output I
posted for GetOutput()->Print( std::cout ) was not the same as the
original post.

John

On Thu, Mar 12, 2009 at 4:35 PM, Luis Ibanez <luis.ibanez@...> wrote:

> Hi John,
>
> Thanks a lot for posting the output of the Print() method.
>
> It seems that the image is not being read as the last slice
> begin located at:
>
>                Z = -359.750
>
> Instead it is located at:
>
>
>      Z = -35.685 + 2.5 * 107 =  +231.81
>
> and... even if the spacing was negative,
> it could have only got to:
>
>      Z = -35.685 - 2.5 * 107 =  -303.18
>
>
>
> This raises suspicion about what you call the
>
>
>           "last DICOM slice..."
>
>
> Are you sure that it belongs to the same Series
> as the first slice ?
>
>
> Also,
> If you visualize the image that you can read with ITK,
> does it look ok ?
>
>
> BTW: As DICOM readers/viewers you may want to try:
>
>
>    A) Slicer
>       http://www.slicer.org
>
>    B) VV
>       http://www.midasjournal.org/browse/publication/288
>
>
>
> Please let us know what you find.
>
>
>    Thanks
>
>
>       Luis
>
>
> -------------------
> John Drescher wrote:
>>>
>>> You are right, this looks strange.
>>>
>>>
>>> Please do the following:
>>>
>>> Just after you load your DICOM image into an ITK image,
>>> call the Print() method in the resulting image, and post
>>> the outcome to the mailing list.
>>>
>>> Your code should look something like
>>>
>>> imageSeriesReader->Update();
>>>
>>> imageSeriesReader->GetOutput()->Print( std::cout );
>>>
>>>
>>> The output of the Print() method will help us to locate
>>> the source of the problem.
>>>
>>>
>>
>>
>> OrientedImage (01D5C650)
>>  RTTI typeinfo:   class itk::OrientedImage<short,3>
>>  Reference Count: 1
>>  Modified Time: 2757
>>  Debug: Off
>>  Observers:
>>    none
>>  Source: (01D5C508)
>>  Source output index: 0
>>  Release Data: Off
>>  Data Released: False
>>  Global Release Data: Off
>>  PipelineMTime: 30
>>  UpdateMTime: 2758
>>  LargestPossibleRegion:
>>    Dimension: 3
>>    Index: [0, 0, 0]
>>    Size: [512, 512, 107]
>>  BufferedRegion:
>>    Dimension: 3
>>    Index: [0, 0, 0]
>>    Size: [512, 512, 107]
>>  RequestedRegion:
>>    Dimension: 3
>>    Index: [0, 0, 0]
>>    Size: [512, 512, 107]
>>  Spacing: [0.626953, 0.626953, 2.5]
>>  Origin: [-174.6, -160.5, -35.685]
>>  Direction:
>> 1 0 0
>> 0 1 0
>> 0 0 1
>>
>>  IndexToPointMatrix:
>>  0.626953 0 0
>> 0 0.626953 0
>> 0 0 2.5
>>
>>  PointToIndexMatrix:
>>  1.59502 0 0
>> 0 1.59502 0
>> 0 0 0.4
>>
>>  PixelContainer:
>>    ImportImageContainer (01D5C8A0)
>>      RTTI typeinfo:   class itk::ImportImageContainer<unsigned long,short>
>>      Reference Count: 1
>>      Modified Time: 81
>>      Debug: Off
>>      Observers:
>>        none
>>      Pointer: 03410040
>>      Container manages memory: true
>>      Size: 28049408
>>      Capacity: 28049408
>>
>>
>>> ----
>>>
>>>
>>> BTW: Why do you say that the direction cosines
>>>
>>>
>>>> 1 0 0
>>>> 0 1 0
>>>> 0 0 1
>>>
>>> look wrong to you ?
>>>
>>
>> I thought it should be
>>
>> 1 0 0
>> 0 1 0
>> 0 0 -1
>>
>> so that the z axis coordinate conversion would be handled correctly.
>>
>>
>>> Given that the direction cosines in the DICOM header
>>> are
>>>
>>>
>>>> 1.000000\0.000000\0.000000\0.000000\1.000000\0.000000
>>>
>>> It seems normal to have the Direction matrix to be an
>>> identity matrix.
>>>
>>
>> Looks like I have to do some reading.
>>
>> Thanks for your help,
>> John
>>
>



--
John M. Drescher
_____________________________________
Powered by www.kitware.com

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

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

Re: Transforming image to world coordinates with negative z axis

by John M. Drescher :: Rate this Message:

| View Threaded | Show Only this Message

Here is output from 1 series:

0020|0013 Instance Number = 1
0020|0032 Image Position (Patient) = -174.600006\-160.500000\-35.685001
0020|0037 Image Orientation (Patient) =
1.000000\0.000000\0.000000\0.000000\1.000000\0.000000

0020|0013 Instance Number = 107
0020|0032 Image Position (Patient) = -174.600006\-160.500000\-300.684998
0020|0037 Image Orientation (Patient) =
1.000000\0.000000\0.000000\0.000000\1.000000\0.000000

OrientedImage (02606C90)
  RTTI typeinfo:   class itk::OrientedImage<short,3>
  Reference Count: 1
  Modified Time: 2757
  Debug: Off
  Observers:
    none
  Source: (02606B88)
  Source output index: 0
  Release Data: Off
  Data Released: False
  Global Release Data: Off
  PipelineMTime: 30
  UpdateMTime: 2758
  LargestPossibleRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [512, 512, 107]
  BufferedRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [512, 512, 107]
  RequestedRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [512, 512, 107]
  Spacing: [0.626953, 0.626953, 2.5]
  Origin: [-174.6, -160.5, -35.685]
  Direction:
1 0 0
0 1 0
0 0 1

  IndexToPointMatrix:
  0.626953 0 0
0 0.626953 0
0 0 2.5

  PointToIndexMatrix:
  1.59502 0 0
0 1.59502 0
0 0 0.4

  PixelContainer:
    ImportImageContainer (02606F30)
      RTTI typeinfo:   class itk::ImportImageContainer<unsigned long,short>
      Reference Count: 1
      Modified Time: 81
      Debug: Off
      Observers:
        none
      Pointer: 05660040
      Container manages memory: true
      Size: 28049408
      Capacity: 28049408

John
_____________________________________
Powered by www.kitware.com

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

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

Re: Transforming image to world coordinates with negative z axis, from DICOM image

by Luis Ibanez :: Rate this Message:

| View Threaded | Show Only this Message


Hi John,

This looks strange.

Is there a chance that you could send us the DICOM images ?

You will have to de-identify the image by first removing
all patient information.


    Thanks


        Luis


----------------------
John Drescher wrote:

> Here is output from 1 series:
>
> 0020|0013 Instance Number = 1
> 0020|0032 Image Position (Patient) = -174.600006\-160.500000\-35.685001
> 0020|0037 Image Orientation (Patient) =
> 1.000000\0.000000\0.000000\0.000000\1.000000\0.000000
>
> 0020|0013 Instance Number = 107
> 0020|0032 Image Position (Patient) = -174.600006\-160.500000\-300.684998
> 0020|0037 Image Orientation (Patient) =
> 1.000000\0.000000\0.000000\0.000000\1.000000\0.000000
>
> OrientedImage (02606C90)
>   RTTI typeinfo:   class itk::OrientedImage<short,3>
>   Reference Count: 1
>   Modified Time: 2757
>   Debug: Off
>   Observers:
>     none
>   Source: (02606B88)
>   Source output index: 0
>   Release Data: Off
>   Data Released: False
>   Global Release Data: Off
>   PipelineMTime: 30
>   UpdateMTime: 2758
>   LargestPossibleRegion:
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [512, 512, 107]
>   BufferedRegion:
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [512, 512, 107]
>   RequestedRegion:
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [512, 512, 107]
>   Spacing: [0.626953, 0.626953, 2.5]
>   Origin: [-174.6, -160.5, -35.685]
>   Direction:
> 1 0 0
> 0 1 0
> 0 0 1
>
>   IndexToPointMatrix:
>   0.626953 0 0
> 0 0.626953 0
> 0 0 2.5
>
>   PointToIndexMatrix:
>   1.59502 0 0
> 0 1.59502 0
> 0 0 0.4
>
>   PixelContainer:
>     ImportImageContainer (02606F30)
>       RTTI typeinfo:   class itk::ImportImageContainer<unsigned long,short>
>       Reference Count: 1
>       Modified Time: 81
>       Debug: Off
>       Observers:
>         none
>       Pointer: 05660040
>       Container manages memory: true
>       Size: 28049408
>       Capacity: 28049408
>
> John
>
_____________________________________
Powered by www.kitware.com

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

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