[Insight-users] VectorImage Orientation from NRRD

Daniel Betz dbetz at stud.hs-bremen.de
Tue Oct 14 19:13:05 EDT 2008


Hello,
I have a problem regarding VectorImage orientation. This is the file I
want to load:

<file namic01-dwi_compressed.nhdr>
NRRD0005
# Complete NRRD file format specification at:
# http://teem.sourceforge.net/nrrd/format.html
content: NAMIC01
type: short
dimension: 4
space: right-anterior-superior
sizes: 256 256 36 14
thicknesses: NaN NaN 3 NaN
space directions: (-0.9375,0,0) (0,-0.9375,0) (0,0,-3) none
centerings: cell cell cell ???
kinds: space space space list
endian: little
encoding: gzip
space units: "mm" "mm" "mm"
space origin: (125,124.1,79.3)
measurement frame: (0,-1,0) (1,0,0) (0,0,-1)
data file: namic01-dwi_compressed.raw.gz
modality:=DWMRI
DWMRI_b-value:=800
DWMRI_gradient_0000:= 0 0 0
DWMRI_gradient_0001:= 0 0 0
DWMRI_gradient_0002:= -0.8238094 -0.4178235 -0.3830949 
DWMRI_gradient_0003:= -0.5681645 0.5019867 -0.6520725 
DWMRI_gradient_0004:= 0.4296590 0.1437401 0.8914774 
DWMRI_gradient_0005:= -0.0482123 0.6979894 0.7144833 
DWMRI_gradient_0006:= 0.8286872 -0.0896669 -0.5524829 
DWMRI_gradient_0007:= 0.9642489 -0.2240180 0.1415627 
DWMRI_gradient_0008:= -0.1944068 0.9526976 -0.2336092 
DWMRI_gradient_0009:= 0.1662157 0.6172332 -0.7690224 
DWMRI_gradient_0010:= -0.3535898 -0.9178798 -0.1801968 
DWMRI_gradient_0011:= -0.7404186 -0.5774342 0.3440203 
DWMRI_gradient_0012:= -0.2763061 0.0476582 0.9598873 
DWMRI_gradient_0013:= 0.6168819 -0.7348858 -0.2817793
</file>

The file contains DWI data and the orientation in the file is LPI which
after applying the "space directions" becomes RAS orientation.

I condensed my problem to this little program:

<code>
#include <itkImage.h>
#include <itkVectorImage.h>
#include <itkImageFileReader.h>
#include <itkNrrdImageIO.h>

int main( int argc, char ** argv )
{
  typedef itk::VectorImage< unsigned short int, 3 > DWIVectorImageType;
  typedef itk::ImageFileReader< DWIVectorImageType > DWIVectorImageReaderType;
  typedef itk::MetaDataDictionary DictionaryType;

  DWIVectorImageReaderType::Pointer dwireaderPtr =
    DWIVectorImageReaderType::New();
  dwireaderPtr->SetFileName("namic01-dwi_compressed.nhdr");
  dwireaderPtr->Update();

  DWIVectorImageType::Pointer dwiVectorImage = dwireaderPtr->GetOutput();
  std::cout << dwiVectorImage << std::endl;
  DWIVectorImageType::IndexType index = {{ 134, 112, 11 }};
  DWIVectorImageType::PointType point;
  dwiVectorImage->TransformIndexToPhysicalPoint(index, point);
  std::cout << index << " => " << point << std::endl;
  std::cout << index << ": " << dwiVectorImage->GetPixel(index) << std::endl;
}
</code>

The output of this program is:

<screen>
VectorImage (0x80fd920)
  RTTI typeinfo:   itk::VectorImage<unsigned short, 3u>
  Reference Count: 3
  Modified Time: 130
  Debug: Off
  Observers: 
    none
  Source: (0x80fb228) 
  Source output index: 0
  Release Data: Off
  Data Released: False
  Global Release Data: Off
  PipelineMTime: 10
  UpdateMTime: 131
  LargestPossibleRegion: 
    Dimension: 3
    Index: [0, 0, 0]
    Size: [256, 256, 36]
  BufferedRegion: 
    Dimension: 3
    Index: [0, 0, 0]
    Size: [256, 256, 36]
  RequestedRegion: 
    Dimension: 3
    Index: [0, 0, 0]
    Size: [256, 256, 36]
  Spacing: [0.9375, 0.9375, 3]
  Origin: [-125, -124.1, 79.3]
  Direction: 
1 0 0
0 1 0
0 0 -1

  VectorLength: 14
  PixelContainer: 
    ImportImageContainer (0x80fda50)
      RTTI typeinfo:   itk::ImportImageContainer<unsigned long, unsigned 
short>
      Reference Count: 1
      Modified Time: 128
      Debug: Off
      Observers: 
        none
      Pointer: 0xb2dc7008
      Container manages memory: true
      Size: 33030144
      Capacity: 33030144

[134, 112, 11] => [0.625, -19.1, 112.3]
[134, 112, 11]: [333, 315, 159, 224, 204, 259, 135, 93, 252, 269, 194, 145, 
247, 162]
</screen>

Let's forget the "TransformIndexToPhysicalPoint does not use direction"
problem. But origin and spacing are both wrong, so I can't even calculate
the world coodinates by myself. My object is translated to the wrong place
and besides that in the wrong space. After applying direction it would be
in LPS space, but it should be RAS space.

Is this a bug ? How can I load the NRRD file correctly into an
itk::VectorImage ?

Thanks in advance,
Daniel Betz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081015/d0c7837c/attachment-0001.pgp>


More information about the Insight-users mailing list