[Insight-developers] experiences with writing Analyze and MetaIO images and orientation with ITK 3.2.0

kent williams norman-k-williams at uiowa.edu
Wed Sep 5 10:20:22 EDT 2007


We generally use an OrientImageFilter when we read images, to make sure
they're in a consistent frame of reference before we do anything with them.
So much so that we have a template function we generally use:

template <typename  TReadImageType>
typename TReadImageType::Pointer
ReadImageCoronal(const std::string &fileName,
                 const bool zeroOrigin = true);

When writing images out, a similar Template function is easy enough to
write...

We have a header file full of functions that encapsulate some of the
'boilerplate' code for common operations like this.  I've thought of writing
it up for the Insight Journal but have not yet gotten around to it.

Of course, this sort of functional pattern for reading files means you
actually read it in before you pass it along to a pipeline, which isn't the
ITK way. On the other hand usually you'd rather know when reading a file
fails before you build a pipeline and call Update on it.



On 9/5/07 9:13 AM, "Kris Thielemans" <kris.thielemans at csc.mrc.ac.uk> wrote:

> Thanks Hans,
> that's helpful.
> 
> This doesn't seem to be documented anywhere. It would be good to put
> this info in the doxygen (or at least the file). What's the name of the
> #define variable? (I can't really see it in the code) and how would I
> enable it with cmake?
> 
> I had to use analyze 7.5 file format because of the application reading
> the data, but I agree that it should be avoided if possible as the
> header really doesn't contain enough info.
> 
> I've solved my particular problems by forcing an orientation (using
> OrientImageFilter) before writing the image.
> 
> thanks again
> 
> Kris
> 
> 
> 
> On Wed, 2007-09-05 at 07:25 -0500, Hans J. Johnson wrote:
>> Kris,
>> 
>> I wanted to add a bit of clarification to your statements about the
>> Analyze7.5 reader.  The Analyze 7.5 reader implementation in ITK was one of
>> the first image file readers that was committed even before ITK had the
>> concept of orientation.  As such the original developers of the Analyze75 IO
>> (my colleagues and I at Iowa) were lax in the original implementation, and
>> now we are stuck with maintaining backwards compatibility with a sub-optimal
>> solution.  
>> 
>> Analyze 7.5 in ITK only records 3 of the 48 possible orthogonal orientations
>> of a 3D image properly.  The other 45 orientations are all lumped into the
>> CORONAL orientation.
>> 
>> It is very easy to get right left swapping in medical images, so be very
>> careful when using Analyze75 because it will often write improperly oriented
>> images.  There is a compile-time #define to force Analyze75 to throw an
>> error when orientation is not going to be written properly, I would suggest
>> using that if you are working on medical image processing.
>> 
>> In our lab, we could not afford R/L swapping errors, and have moved
>> completely over to the NIFTI file format.   It supports orientation much
>> more consistently.
>> 
>> I hope these comments help.
>> 
>> Hans
>> 
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers



More information about the Insight-developers mailing list