[Insight-users] Wrong origin after using OrientImageFilter (with mnc2nii and NiftiImageIO)

Tom Vercauteren tom.vercauteren at gmail.com
Thu Mar 8 08:27:31 EST 2007


Hi all,

Sorry for sending so much to the mailing list lately.

I am trying to read and use the images from BrainWeb. I first convert
them from MINC 1 to Nifti using mnc2nii.

For some of my processing, I need the orientation to be RAI. That's
why I am using the OrientImageFilter.

Here is what I first did:
------------
typedef itk::Image< InputPixelType, 3 > ImageType;

typedef typename itk::OrientImageFilter<ImageType,
  ImageType> ImageOrienterType;

[...]

inputImage = imageReader->GetOutput();

orienter->UseImageDirectionOn();
orienter->SetDesiredCoordinateOrientation(
   itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAI);

orienter->SetInput(inputImage);
outputImage = orienter->GetOutput()
----------



Unfortunately the origin of my output image seemed wrong. I also tried
to use itk::OrientedImage instead of itk::Image but this did not
change the output image.

I finally got it right by forcing to use another input origin:
------------
inputImage = imageReader->GetOutput();
inputImage->DisconnectPipeline();

// Change origin for orienter
PointType new_origin(
   ( (inputImage->GetDirection()).GetInverse()
     *(inputImage->GetOrigin()).GetVnlVector() ).data_block() );

inputImage->SetOrigin( new_origin );
----------


I don't know exactly where the problem arises:
- wrong input data from BrainWeb?
- wrong conversion using mnc2nii?
- wrong orientation computation by NiftiImageIO?
- wrong orientation computation by OrientImageFilter?

Here is some information that might help:
- the input Nifti image I read (before modifying the origin) is such that
Origin: [127.75, 145.75, -72.25]
Direction:
-1 0 0
0 -1 0
0 0 1

- the modified input image I make is such that
Origin: [-127.75, -145.75, -72.25]
Direction:
-1 0 0
0 -1 0
0 0 1

- the (wrong) output image with the initial input image is such that
Origin: [-382.75, -400.75, -72.25]
Direction:
1 0 0
0 1 0
0 0 1

- the (correct) output image with the modified input image is such that
Origin: [-127.25, -109.25, -72.25]
Direction:
1 0 0
0 1 0
0 0 1


Let me know if I am doing something silly here or if this is not
related to ITK or if I should file a bug for this.

Best,
Tom Vercauteren


More information about the Insight-users mailing list