VTK/MNI File Formats
The Montreal Neurological Institute (MNI) has a variety of medical image processing tools that might be useful to VTK consumers and developers. The purpose of this project is to to support the MNI file formats in VTK, so that people who use VTK can interoperate with MNI software and use the MNI datasets. Of particular interest is Brainweb, their database of MR head images.
The vtkMINCImageReader and vtkMINCImageWriter support version 1 of the MINC (Medical Image NetCDF) file format. The main features of MINC are:
- Multi-dimensional volumes can be stored in a single file
- The header is both highly standardized and extensible
- It supports image orientation (direction cosines)
- It stores real-valued data with physical units
The header information for MINC is stored in a class called vtkMINCImageAttributes, which makes it easy to read, write, extend, and verify the header information. Like the NetCDF format that it is based on, the header can contain arrays of arbitrary type that may be sized to the image dimensions.
MINC v2 uses the HDF5 file format, and is therefore not supported because VTK only includes the NetCDF libraries and not the HDF5 libraries. However, since NetCDF v4 can read HDF5 files, and since VTK 5.8 includes NetCDF v4, there is a possibility that MINC v2 could be supported in the future. But for now, only MINC v1 files can be read with the vtkMINCImageReader.
The MNI .obj format is used for geometrical data. It is a simple text-based format without the same flexibility as MINC.
- Polygons and polylines are supported
- Polygon normals are supported (in fact, mandatory)
- Colors and surface properties are supported
- Colors may be per-point, per-cell, or per-object
- Binary files are supported (but are native endian, i.e. not portable)
The vtkMNIObjectWriter has methods called SetProperty() and SetMapper() so that it save an actor's colors and surface properties in the file. In other words, vtkMNIObjectWriter can be used as an exporter for a vtkActor.
VTK does not support all extensions that exist for the .obj format. It is not possible to use these datatypes:
The MNI .xfm format is for transform storage. It supports a useful subset of VTK's transforms:
- linear transforms (up to 12 degrees of freedom)
- grid transforms (cubic interpolation of deformation vectors)
- thin-plate spline transforms
For grid transforms, the grid itself is stored in a MINC file, and the .xfm file contains a relative or absolute path to that MINC file. One very useful feature of the MNI .xfm files is that they can contain multiple transforms per file, where the full transform is the concatenation of all the stored transforms. These concatenated transforms are handled in VTK by the vtkGeneralTransform class.
The MNI .tag format is used for annotations. It contains a list of one or two point sets, as well as text for each point. Due to the age of this format (circa 1992) the label text must be ASCII in order to ensure compatibility with all software.
The vtkMNITagPointReader will output a vtkPointSet and store the text in an array called LabelText. The output can be fed into vtkPointSetToLabelHierarchy and used with VTK's label mappers. Alternatively, the user can grab the label text directly from the reader and use their own code to display the labels.
Please see the following examples, which are part of VTK's nightly regression tests: