View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008470ITKpublic2009-02-04 16:272010-11-13 13:01
ReporterIvan Macia 
Assigned ToMathieu Malaterre 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionITK-3-10 
Target VersionFixed in VersionITK-3-12 
Summary0008470: Trying to load 2D images in coronal or sagittal orientation always throws exception in ITK-3.10.1
DescriptionPosted here, no answer :(
http://www.itk.org/mailman/private/insight-developers/2009-January/011575.html [^]

Since version 3.10.1 (and probably 3.10) I am unable to load a single slice
from a 3D coronal or sagittal volume (we do this for previewing or loading,
without actually loading the whole volume). ImageBase
::ComputeIndexToPhysicalPointMatrices() complains that the determinant is
zero.

This is quite critical because we cannot make our software work with
ITK-3.10 and above without changing this code. Either our exception handling
or Qt's is always catching this exception and we cannot continue with the
loading.
Additional InformationThis seems to be related to the fact that for a 2D image, m_Direction is 2x2
where it should be 3x3. It seems that previous versions didn't throw an
exception so they were working anyway.

Having a deeper look, I try to load an image where ImageIO (GDCMImageIO)
reads the following for the direction:

0.252 0.968 0.0
0.0 0.0 -1.0
-0.0968 0.252 0.0

However, when converting from the direction stored in ImageIO to
ImageBase::m_Direction (see ImageFileReader::GenerateOutputInformation() )
the resulting matrix is

0.252 0.968
0.0 0.0

For this, the present code in
ImageBase::ComputeIndexToPhysicalPointMatrices() and
Image::ComputeIndexToPhysicalPointMatrices() throws an exception because the
determinant is zero

 if (vnl_determinant(this->m_Direction.GetVnlMatrix()) == 0.0)
    {
    itkExceptionMacro(<< "Bad direction, determinant is 0. Direction is " <<
this->m_Direction);
    }

I have seen a discussion about this in Mantis issue [0005573]:
"Image::DirectionType should be Nx3 rather than NxN", however the discussion
was centered on 4D images. IMHO, leaving the 4D world apart, a single slice
of a volume lies in a 3D world so m_Direction should be 3x3.
TagsNo tags attached.
Resolution Date
Sprint
Sprint Statusbacklog
Attached Files

 Relationships

  Notes
(0015282)
Bradley Lowekamp (developer)
2009-02-21 08:58

I was able to reproduce the bug with the following:


Can anyone please try to reproduce this error? You can find 2 DICOM files, one sagittal, one coronal that fail here
http://www.yousendit.com/download/U0d3K3BKQk5tMEtGa1E9PQ [^]
(0015283)
Bradley Lowekamp (developer)
2009-02-21 09:21

This is the problematic code in ImageFileReader, it also should check the degenerate case when the det is 0:

// TODO: actually figure out what to do about dir cosines in 2d.
  // don't allow degenerate direction cosines
  // This is a pure punt; it will prevent the exception being
  // thrown, but doesn't do the right thing at all -- replacing e.g
  // [0, 0, -1] with [0, 1] doesn't make any real sense.
  // On the other hand, programs that depend on 2D Direction Cosines
  // are pretty much guaranteed to be disappointed if they expect anything
  // meaningful in the direction cosines anyway.
  if(TOutputImage::ImageDimension == 2)
    {
    if(direction[0][0] == 0.0 && direction[1][0] == 0)
      {
      if(direction[0][1] == 0.0)
        {
        direction[0][0] = 1.0;
        }
      if(direction[1][1] == 0.0)
        {
        direction[1][0] = 1.0;
        }
      }
    else if(direction[0][1] == 0.0 && direction[1][1] == 0)
      {
      if(direction[0][0] == 0.0)
        {
        direction[1][0] = 1.0;
        }
      if(direction[1][0] == 0.0)
        {
        direction[1][1] = 1.0;
        }
      }
    }
(0015473)
Luis Ibanez (manager)
2009-03-01 13:44

A fix has been committed (now included in ITK 3.12).

Two new methods were added to ImageIOBase,
and they were overloaded in itkAnalyzeImageIO.

http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkImageIOBase.cxx?root=Insight&r1=1.82&r2=1.83 [^]
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkImageIOBase.h?root=Insight&r1=1.50&r2=1.51 [^]
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkAnalyzeImageIO.cxx?root=Insight&r1=1.93&r2=1.94 [^]
http://www.itk.org/cgi-bin/viewcvs.cgi/Code/IO/itkAnalyzeImageIO.h?root=Insight&r1=1.21&r2=1.22 [^]

These methods implement the preferred way of initializing direction cosines when the image instantiated in memory is of dimension lower than the image stored in the input file.
(0015474)
Luis Ibanez (manager)
2009-03-01 13:45

All tests passed in the Dashboard after this changes.

The fixes are included in ITK 3.12.
(0015797)
Hans Johnson (developer)
2009-03-25 09:05

The original bug fix caused failure for 3D images with direction cosigns of [1 0 0;0 0 -1; 0 1 0] which is a valid orientation for the analyze filter.

This was fixed with code submitted in
/cvsroot/Insight/Insight/Code/IO/itkAnalyzeImageIO.cxx,v <-- itkAnalyzeImageIO.cxx
new revision: 1.95; previous revision: 1.94
(0023114)
Mathieu Malaterre (developer)
2010-11-09 17:56

I believe this bug has been fixed.

 Issue History
Date Modified Username Field Change
2009-02-04 16:27 Ivan Macia New Issue
2009-02-21 08:56 Bradley Lowekamp Assigned To => Bradley Lowekamp
2009-02-21 08:56 Bradley Lowekamp Status new => assigned
2009-02-21 08:58 Bradley Lowekamp Note Added: 0015282
2009-02-21 08:58 Bradley Lowekamp Status assigned => confirmed
2009-02-21 09:21 Bradley Lowekamp Note Added: 0015283
2009-02-23 11:54 Bradley Lowekamp Status confirmed => assigned
2009-02-23 11:54 Bradley Lowekamp Assigned To Bradley Lowekamp => Luis Ibanez
2009-03-01 13:44 Luis Ibanez Note Added: 0015473
2009-03-01 13:45 Luis Ibanez Note Added: 0015474
2009-03-01 13:45 Luis Ibanez Status assigned => closed
2009-03-01 13:45 Luis Ibanez Resolution open => fixed
2009-03-01 13:45 Luis Ibanez Fixed in Version => ITK-3-12
2009-03-25 09:05 Hans Johnson Note Added: 0015797
2009-03-25 09:05 Hans Johnson Status closed => feedback
2009-03-25 09:05 Hans Johnson Resolution fixed => reopened
2010-10-26 05:56 Mathieu Malaterre Status feedback => assigned
2010-10-26 05:56 Mathieu Malaterre Assigned To Luis Ibanez => Mathieu Malaterre
2010-11-09 17:56 Mathieu Malaterre Note Added: 0023114
2010-11-09 17:57 Mathieu Malaterre Sprint Status => backlog
2010-11-09 17:57 Mathieu Malaterre Status assigned => closed
2010-11-09 17:57 Mathieu Malaterre Resolution reopened => fixed
2010-11-13 13:00 Mathieu Malaterre Status closed => feedback
2010-11-13 13:00 Mathieu Malaterre Resolution fixed => reopened
2010-11-13 13:01 Mathieu Malaterre Status feedback => closed
2010-11-13 13:01 Mathieu Malaterre Resolution reopened => fixed


Copyright © 2000 - 2018 MantisBT Team