[Insight-developers] ImageSeriesWriter + GDCMImageIO

Daniele E. Domenichelli daniele.domenichelli at gmail.com
Wed Sep 30 10:44:25 EDT 2009


Mathieu Malaterre wrote:
>> 2) When I read a DICOM set as a volume that has direction cosines
>> written as:
>>
>>  Ax\Ay\Az\Bx\By\Bz
>>
>> these values are stored in a 3x3 matrix as:
>>
>>  Ax  Bx  Cx
>>  Ay  By  Cy   (where C=AxB)
>>  Az  Bz  Cz
>>
>> When I write back this volume as 2D DICOM, direction cosines are:
>>
>>  Ax\Bx\Cx\Ay\By\Cy
>>
>>
>> The second attached file (GDCMDirectionCosines.diff) should correct this
>> behaviour. (I tested this only for GDCM 2)
> 
> This is exactly the opposite of bug 0007748 which was recently applied
> to CVS HEAD
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/IO/itkGDCMImageIO.cxx?root=Insight&r1=1.161&r2=1.162


Ok now I understand what happened:

With the first patch (ITK_Direction.diff) I wrote m_Direction in this way:


---

       ExposeMetaData< DoubleMatrixType >( dict, key, directionMatrix );
        for(int i = 0; i<3; i++)
            for(int j = 0; j<3; j++)
                m_Direction[i][j]=directionMatrix[i][j];

---

but reading in the discussion of bug #7748 I understand that

> The short hand explanation should be that the member m_Direction of
> itk::GDCMImageIO (inherited from itk::ImageIOBase) is a vector that
> points to vectors, where the first vector contains the direction
> cosines of the image rows, the second the direction cosines of the
> image columns and the third contains the direction cosines of the
> image slices. So, m_Direction[0][0], m_Direction[0][1],
> m_Direction[0][2] are the direction cosines of the image rows.
> itk::GDCMImageIO::m_Direction stores the direction cosines as rows.

Then m_Direction is transposed and should be written in this way:

---

       ExposeMetaData< DoubleMatrixType >( dict, key, directionMatrix );
        for(int i = 0; i<3; i++)
            for(int j = 0; j<3; j++)
                m_Direction[j][i]=directionMatrix[i][j];

---

I attached a new file to bug #9622


Regards,
 Daniele


More information about the Insight-developers mailing list