From KitwarePublic
Jump to navigationJump to search

MetaIO Documentation

  • MetaIO began in 1996 to address the growing complexity and inflexibility of medical image formats that were available at that time.
  • MetaIO has maintained backward compatibility since its initial public release in 2000 as part of the Insight Toolkit (ITK)
  • MetaIO is used for the majority of tests and examples in the ITK framework


  • Simple text descriptor using tagged field format
  • Descriptor can appear as a text header preceding binary data
  • Descriptor can be in a separate file that describes a binary data file
  • Via separate header and binary data files, multiple binary data formats are supported
    • Bmp, .im, dicom
    • UChar, Char, UShort, Short, UInt, Int, Float, Double voxels
  • Supports storage of parameters necessary for real-world medical image processing
    • Element (e.g., voxel or pixel) size
    • Image position and orientation
    • Patient position and orientation
  • Supports MSB and LSB byte ordering
  • ND Data in a single file
  • ND Data as a sequence of (N-1)D files
  • Optional compression
  • Easily extended to handle user-defined fields on a per application basis


Get the software

  • Most recent version available as part of the Insight Toolkit in the directory Insight/Utilities/MetaIO
  • MetaIO is also available as part of the Visualization Toolkit in the directory VTK/Utilities/vtkmetaio

VTK MetaIO -vs- ITK MetaIO

The ITK and VTK distributions differ by having local include files that cause each distribution to be wrapped in a different namespace. In this manner, programs can link with the VTK and ITK libraries without receiving errors related to the same function having been previously defined.

A summary of the differences are as follows:

  • Each distribution has a file called "localMetaConfiguration.h." This file defines METAIO_USE_NAMESPACE, META_IO_NAMESPACE, include paths for vtk/itk's kwsys libraries, and namespaces for STL, STREAM, and KWSYS libraries. Important differences are as follows
    • ITK distribution:
      • Does not use a namespace - in order to preserve backward compatibility
      • Includes itk_zlib.h
      • Includes itksys/SystemTools.hxx for kwsys
    • VTK distribution:
      • Uses the namespace vtkmetaio
      • Includes vtkConfigure.h to learn about std dependencies
      • Includes vtksys/SystemTools.hxx for kwsys
      • Defines METAIO_EXTERN and METAIO_EXPORT for shared libraries
  • Each .h and .cxx file in MetaIO includes the localMetaConfiguration.h file using quotes to cause the local version of that file to be found first. Thus, a single application should be able to compile with VTK and ITK without problems/conflict


  • When using MetaIO from within VTK, prefix with the namespace vtkmetaio::
  • When using MetaIO from within ITK, call the function without a namespace
  • Developers should never issue "using namespace vtkmetaio" in a program if VTK and ITK are to be used in that program.


  1. I am trying to use MetaIO to point to and read my set of png (or tiff or jpeg) files, but it isn't working. What is wrong with MetaIO?
    • More than likely your files are using compressed versions of those image formats. MetaIO only supports its own type of image compression - it cannot read data that is compressed in other formats. Sorry.
  2. Should I use Origin, Position, or Offset (and similarly Orientation, Rotation, or TransformMatrix) to represent the recorded location of my data?
    • Due to backward compatibility constraints, any of these variations is supported and produces identical results.
  3. What is the difference between BinaryDataByteOrderMSB and ElementDataByteOrderMSB?
    • Again backward compatibility is the driving force. Over the past decade some inconsistencies crept into the implementation of derived classes, and when we go back and standardize, we must maintain backward compatibility. Therefore, equivalent terms are often defined in the tag dictionary.
  4. I think MetaIO is encoding my image's orientation incorrectly...
    • We greatly appreciate your feedback -- particularly if you can provide the data and/or data conversion program that is exhibiting this behavior. We've tried to get it "right" but data orientation is both critical and tricky. Please send your data and details to
  5. What orientation convention is MetaIO using?

Related Links

  • ITK
  • VTK
  • MRIConvert - excellent tool for DICOM to MetaImage conversion
  • FusionViewer - U of Washington tool for pet/ct visualization
  • I3DLib - Microscopy software - Masaryk University
  • BatchMake - Simple scripting for GRID processing

MetaCommand and MetaOutput

The MetaCommand and MetaOutput classes are provided with the MetaIO library. They simplify the parsing of command-line parameters, integration of executables with BatchMake, and distributed processing.

Documentation on MetaCommand and MetaOutput is available as a wiki page.