[Insight-users] Analyze Image Orientation (Again)

Geoff Topping g_topping at hotmail.com
Wed Mar 28 00:50:56 EST 2007


Hi all,

I've successfully gotten Analyze format images saved out of ITK, using the 
suggestions by Jernej and others.  Thanks.

However, whenever I write out an Analyze format image that is generated from 
a resampler (such as in registration examples), various problems arise:


If I read the image(s) in, resample one of them, orient the result, cast the 
result to a new pixel time and then write out the result, I get no error 
messages when writing, but the result is anterior-posterior flipped.


If I read, cast the original unaltered images, then write, the results are 
just the original unaltered image, in the correct orientation.


If I read, resample, don't orient, cast and write, then I get an error 
message:

WARNING: In 
/home/gtopping/InsightToolkit-3.2.0/Code/IO/itkAnalyzeImageIO.cxx, line 1182
AnalyzeImageIO (0xb8f460): ERROR: Analyze 7.5 File Format Only Allows RPI, 
PIR, and RIP Orientation

The output still finishes, and the output image looks correct, or at least 
plausible, in that it's not the original image, and it's not flipped as in 
the first case.


If I read, orient the initial unaltered image, cast that, and write, I get 
the original image back, without any flipping.

So, I either get an error message and some concern that something's going 
wrong that I'm not yet aware of, or I get a flipped image as output.


How can I set the orientation of the results of resampling correctly, 
getting rid of warnings and error messages, without screwing up the 
resulting images?  Is there something else obvious I'm missing?  Should I / 
can I safely just ignore the error messages?  Should I be using a different 
set orientation (I tried this a bit, but got different wrong orientation 
results when viewing images)


Thanks,
Geoff


Somewhat edited, and omitting typedefs and instantiation, the changing 
section my code is below.  This essentially follows the registration example 
for 3D rigid transform, except that the writer is told to use AnalyzeIO...


resampler->SetTransform(finalTransform);
resampler->SetInput(movingImageReader->GetOutput());
resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize());
resampler->SetOutputOrigin(fixedImage->GetOrigin());
resampler->SetOutputSpacing(fixedImage->GetSpacing());
resampler->SetDefaultPixelValue(0);

outputImageOrienter->SetUseImageDirection(true);
outputImageOrienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RPI);

// next two lines: can change comments of inputs to test / skip steps:
outputImageOrienter->SetInput(resampler->GetOutput()/*movingImageReader->GetOutput()*/);
caster->SetInput(/*resampler->GetOutput()*/outputImageOrienter->GetOutput()/*movingImageReader->GetOutput()*/);

// writing
writer->SetImageIO(analyzeIO);
writer->SetFileName(argv[3]);
writer->SetInput(caster->GetOutput());
writer->Update();

**************************************************
Previous Message:
Date: Mon, 26 Mar 2007 10:22:13 +0200
From: "Perhavc" <J.Perhavc at student.tudelft.nl>
Subject: RE: Re: [Insight-users] Analyze Image Orientation (Again)
To: <insight-users at itk.org>
Message-ID:
	<944EF7346A898740AEBA05CC866E278F020C79 at SRV602.tudelft.net>
Content-Type: text/plain; charset="iso-8859-1"

Hey Geoff!

You should use your image orienter in the pipeline, meaning that you need to 
insert it into the whole process. For now you only set
the parameters, but you do not end up using the results. To be more 
specific, you set the input to the orienter correctly, but then
you should use the output of it as the input to your writer. As an example 
look at the code below. You might need to modify it a
bit, but the idea is there:

caster->SetInput(resampler->GetOutput());

outputImageOrienter->SetInput(caster->GetOutput(););
outputImageOrienter->SetUseImageDirection(true);
outputImageOrienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RPI);

writer->SetInput( outputImageOrienter->GetOutput() );

I hope this will work.... Oh, another thing. I believe you dont need to set 
the orientation at the beginning when you read the file.
Setting the orientation for the output image should be enough I guess.

Jernej

_________________________________________________________________
http://local.live.com/?mkt=en-ca/?v=2&cid=A6D6BDB4586E357F!420



More information about the Insight-users mailing list