[Insight-developers] nifti direction cosines; bug?

Stefan Klein s.klein at erasmusmc.nl
Fri Feb 10 13:44:54 EST 2012


Hi developers,

In case of an Analyze75 file, loaded by NiftiImageIO, the Direction 
Cosines are not stored in the m_Direction variable. Consequently, all 
Analyze files get an identity direction matrix.

The error occurs in the SetImageIOOrientationFromNifTI function. The 
code first reads the orientation correctly and stores it in a local 
variable called 'dir', but this variable is never stored in the member 
variable m_Direction.

Here is the relevant code (ITK v4.1rc01):

void
NiftiImageIO::SetImageIOOrientationFromNIfTI(unsigned short int dims)
{
  typedef SpatialOrientationAdapter OrientAdapterType;

   //
   // in the case of an Analyze75 file, use old analyze orient method.
   if ( this->m_NiftiImage->qform_code == 0
&& this->m_NiftiImage->sform_code == 0 )
     {
     SpatialOrientationAdapter::DirectionType   dir;
     SpatialOrientationAdapter::OrientationType orient;
     switch ( this->m_NiftiImage->analyze75_orient )
       {
       case a75_transverse_unflipped:
         orient = SpatialOrientation::ITK_COORDINATE_ORIENTATION_RPI;
         break;
       case a75_sagittal_unflipped:
         orient = SpatialOrientation::ITK_COORDINATE_ORIENTATION_PIR;
         break;
       // according to analyze documents, you don't see flipped
       // orientation in the wild
       case a75_transverse_flipped:
       case a75_coronal_flipped:
       case a75_sagittal_flipped:
       case a75_orient_unknown:
       case a75_coronal_unflipped:
         orient = SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP;
         break;
       }
     dir =  OrientAdapterType().ToDirectionCosines(orient);
     m_Origin[0] = 0;
     if ( dims > 1 )
       {
       m_Origin[1] = 0;
       }
     if ( dims > 2 )
       {
       m_Origin[2] = 0;
       }
     return;
     }


  ...  // implementation for non-Analyze files.

}


I'm aware that Analyze75 is deprecated, and that I could use the 
Deprecated/itkAnalyzeImageIO.h class, but this looks to me like a bug.

Kind regards,
Stefan

-- 
Stefan Klein
+31 10 7043049
http://www.bigr.nl/people/StefanKlein



More information about the Insight-developers mailing list