[Insight-developers] question regarding direction cosines

Kent Williams norman-k-williams at uiowa.edu
Thu Nov 10 13:18:55 EST 2005


Thanks for the catch on IOP... I'll try and straighten it out.

The ITK Origin = IOP^-1 * IPP thing is in itkGDCMImageIO.cxx, I was 
simply passing what is done in there; right now I'm not sure the GDCM 
reader is 100% correct right now, because it does this transformation 
when it reads a DICOM file, but the code to convert the ITK origin to 
DICOM is commented out, and I think all DICOM files are written out with 
an origin of 0,0,0.

Here's an excerpt of the code, where I got my information.

  // DICOM specifies its origin in LPS coordinate, regardless of how
  // the data is acquired. itk's origin must be in the same
  // coordinate system as the data. This code transforms the DICOM
  // origin into the itk origin. The itk origin is computed by
  // multiplying the inverse(transpose) of the direction cosine times
  // the dicom origin.
  vnl_vector<double> itkOrigin(3), dicomOrigin(3);
  vnl_matrix<double> dicomDirection(3,3);
  dicomOrigin[0] = header.GetXOrigin();
  dicomOrigin[1] = header.GetYOrigin();
  dicomOrigin[2] = header.GetZOrigin();
  for (unsigned int ii = 0; ii < 3; ii++)
    {
    dicomDirection[0][ii] = rowDirection[ii];
    dicomDirection[1][ii] = columnDirection[ii];
    dicomDirection[2][ii] = sliceDirection[ii];
    }
  itkOrigin = dicomDirection * dicomOrigin;
  m_Origin[0] = itkOrigin[0];
  m_Origin[1] = itkOrigin[1];
  m_Origin[2] = itkOrigin[2];



Blezek, Daniel J (Research) wrote:

>Kent,
>
>  Just below the picture of Sinead O'Connor, you talk about "Image Position (Patient)" being a directional cosine, I think that should be "Image Orientation Patient".
>
>  I have to admit I'm a bit confused as to why you suggest setting the ITK origin to be 
>
>IOP^-1 * IPP
>
>IOP = Image Orientation Patient, IPP = Image Position Patient.
>
>Isn't IPP already the origin of the coordinate system?  Does this imply an ITK image is to have the first pixel in the lower left?  I'm confused by this issue, but need to resolve it to register coronal and axial MR data.
>
>-dan
>
>P.S.  Being from Minnesota, I enjoyed your site. 8)  Corn, corn, corn.
>
>
>
>
>-----Original Message-----
>From: insight-developers-bounces+blezek=crd.ge.com at itk.org
>[mailto:insight-developers-bounces+blezek=crd.ge.com at itk.org]On Behalf
>Of Kent Williams
>Sent: Thursday, November 10, 2005 9:54 AM
>To: Leila baghdadi
>Cc: insight-developers at itk.org
>Subject: Re: [Insight-developers] question regarding direction cosines
>
>
>Well, the definition of the direction cosines is that they define 3 
>vectors, which define a coordinate system. The first vector corresponds 
>to the fastest moving dimension in the image, the second to the next 
>fastest, and the third to the slowest.
>
>In other words, the direction cosines define a relationship between 
>patient space and the indices into the image data array.
>
>I suppose it would be possible to have a file with more than 3 
>dimensions, with an organization such that the dimensions are ordered 
>T,U,X,V,Z,Y (fastest moving index to slowest) or something like that. 
>But I would worry about getting the most common case right, and work up 
>from there.
>
>I've written an article that will be in the Insight Journal, and here is 
>a preliminary copy:
>
>http://cornwarning.com/xfer/OrientationArticle.pdf
>
>I hope that helps somewhat. Any more questions, feel free to ask.
>
>Leila baghdadi wrote:
>
>  
>
>>Hi Kent
>>
>>that sounds like a good solution, the only problem with this is what if
>>the spatial dimensions with meaningful directions are *not* the first 3
>>dimensions,
>>
>>The way I envisioned this, the image could have dimensions of any order
>>
>>i.e, the three spatial dimensions can show up in any order, so that
>>would make the upper left 3x3 of an NxN not meaningful
>>
>>will work on your solution plus correct ordering, I am sure once I
>>commit the code I hear complaints about it
>>
>>
>>Thanks again
>>
>>Leila
>>On Tue, 2005-11-08 at 17:11 -0600, Kent Williams wrote:
>> 
>>
>>    
>>
>>>Direction Matrix is NxN where N is the number of dimensions in the 
>>>image.  In general, only the first 3 directions have any spatial 
>>>meaning, and 3D images are the most common by far.
>>>
>>>I'd suggest setting the direction matrix to identity, and then filling 
>>>in the X,Y,Z (0,1,2) columns with the direction cosines representing the 
>>>3D orientation -- basically the upper left 3x3 of the matrix.  Anyone 
>>>else have a suggestion?
>>>
>>>Leila baghdadi wrote:
>>>
>>>   
>>>
>>>      
>>>
>>>>Hi guys
>>>>
>>>>I am writing ImageIO classes for our specific file format (minc2) which
>>>>is like itk N-dimensional,
>>>>
>>>>I am a bit confused about how to create a correct matrix for direction
>>>>cosines,
>>>>
>>>>suppose I have an image with the following
>>>>
>>>>u,x,r,y,w,z
>>>>
>>>>so direction cosines are only for x,y,z
>>>>
>>>>the question is what is the correct way to create m_Direction of
>>>>itkImageIOBase.*
>>>>
>>>>do I create a matrix (6x3) where I have (0,0,0) (1,0,0) (0,0,0) 
>>>>
>>>>or basically how do you carry the correct index for the spatial
>>>>dimensions,
>>>>
>>>>Hopefully my question is clear if not please let me know
>>>>
>>>>Thanks
>>>>
>>>>Leila
>>>>
>>>>
>>>>_______________________________________________
>>>>Insight-developers mailing list
>>>>Insight-developers at itk.org
>>>>http://www.itk.org/mailman/listinfo/insight-developers
>>>>
>>>>
>>>>
>>>>     
>>>>
>>>>        
>>>>
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers at itk.org
>http://www.itk.org/mailman/listinfo/insight-developers
>
>  
>



More information about the Insight-developers mailing list