[Insight-developers] ImageSeriesWriter + GDCMImageIO
Mathieu Malaterre
mathieu.malaterre at gmail.com
Thu Dec 3 06:37:03 EST 2009
On Wed, Sep 30, 2009 at 3:44 PM, Daniele E. Domenichelli
<daniele.domenichelli at gmail.com> wrote:
> 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
I applied your proposed patch : ITK_Direction.diff (and not
ITK_Direction2.diff). Thanks !
$ cvs ci -m"BUG: 0009622 Thanks to Daniele E. Domenichelli for
providing the patch"
~/Kitware/Insight
Committer: Mathieu Malaterre <mathieu.malaterre at gmail.com>
Running style check
Running style check
Processing itkGDCMImageIO.cxx
Running style check
Processing itkIOCommon.cxx
Running style check
Processing itkIOCommon.h
Running style check
Processing itkImageSeriesWriter.txx
/cvsroot/Insight/Insight/Code/IO/itkGDCMImageIO.cxx,v <--
Code/IO/itkGDCMImageIO.cxx
new revision: 1.168; previous revision: 1.167
/cvsroot/Insight/Insight/Code/IO/itkIOCommon.cxx,v <-- Code/IO/itkIOCommon.cxx
new revision: 1.30; previous revision: 1.29
/cvsroot/Insight/Insight/Code/IO/itkIOCommon.h,v <-- Code/IO/itkIOCommon.h
new revision: 1.28; previous revision: 1.27
/cvsroot/Insight/Insight/Code/IO/itkImageSeriesWriter.txx,v <--
Code/IO/itkImageSeriesWriter.txx
new revision: 1.34; previous revision: 1.33
--
Mathieu
More information about the Insight-developers
mailing list