[Insight-developers] Proposal for writing ITK transforms as MATLAB Level 4 Binary MAT files

kent williams norman-k-williams at uiowa.edu
Wed Aug 1 16:12:22 EDT 2007


I need some feedback on how I should go about this.  For our lab's purposes,
we need a binary format for writing out transformations, primarily as a way
to ensure that no rounding errors happen due to writing floating point
numbers as text.   It would also be useful to be able to load transforms
saved out of Matlab.

What I propose to do:

1. Create a new class itk::TransformFileWriterBase. Almost all the code from
TransformFileReader/Writer would be pushed up to this class, except for the
Update method, in which the actual File/IO and Formatting would take place.

2. Modify itk::TransformFileReader/Writer such that it derives from
itk::TransformFileReader/WriterBase, and has the code particular to
text-format ITK transforms in its version of Update().

3. Add new classes itk::MatlabTransformFileReader/Writer, derived from
itk::TransformFileReader/WriterBase.  Write new versions of Update, to
read/write Matlab Level 4 files.

Using the Matlab Level 4 Format:

Matlab Level 4 file format is simple and straightforward. Furthermore, VNL
has classes for reading and writing Matlab level 4 files.  Matlab has a
newer format that supports serializing nearly any Matlab variable, and
supports data compression.  Unfortunately Matlab Level 5 files are much more
complex than Level 4, and the libraries I've found that read and write Level
5 files are GPL, which are incompatible with ITK licensing.

For the purposes of writing ITK transforms, the following sequence would be
used, one per transform added to the file before writing.

<Parameters>
<Fixed Parameters>

The parameters are written out using
vnl_matlab_filewrite(vnl_vector<double>,varname);  The 'varname' field of
the parameters gives the class name for the transform to create when
reading. The 'varname' of the FixedParameters is simply 'FIXED'.

I don't use Matlab, so I don't know how difficult this will make writing out
transforms from Matlab -- perhaps some Matlab users would have an opinion?

Since there's no standard for transform file naming, I don't think that that
it makes sense to try and parallel the way that ImageIO works -- a user
would choose either writing out binary Matlab files or ITK text files for
transforms.

An alternative way of handling this would be to add Set/GetBinaryFile
boolean functions to the existing TransformFileReader/Writer classes, and
incorporate the matlab I/O code in those classes.

Opinions?



More information about the Insight-developers mailing list