[Insight-developers] Proposal for writing ITK transforms as
MATLAB Level 4 Binary MAT files
kent williams
norman-k-williams at uiowa.edu
Fri Aug 3 10:54:13 EDT 2007
This is a good proposal. It is probably preferable to the quick and dirty
thing I did yesterday.
Dpes VTK have a file format for a vtk transform? I'm not seeing any classes
in the VTK documentation for reading and writing transforms.
On 8/3/07 7:42 AM, "Luis Ibanez" <luis.ibanez at kitware.com> wrote:
>
> Hi Kent,
>
> A couple of questions:
>
>
> 1) Why is that the TransformFileWriterBase class is necessary ?
> Is it because the Update() method in the current
> TransformFileWriter is not "virtual" ?
>
> 2) Should we consider setting up a Factory mechanism similar
> to the ImageIO ?
>
> In your proposal, we would be following rather the VTK model
> where the user has to explicitly specify the writer, as opposed
> to the ITK model where the ImageFileWriter (and presumably the
> TransformFileWriter) used the filename as a way of picking up
> the actual class that will do the writing.
>
> We could have a "neutral" TransformFileWriter, and add classes
>
>
> TranformIOBase the basic helper class
>
> with derived classes:
>
> MatlabTransformIO
> VTKTransformIO (a common request from users )
> OpenGLTransformIO
> MetaTransformIO (the current implementation in ITK)
>
>
> The extension of the filename will be used for picking up
> the correct TransformIO class from a factory.
>
>
> 3) We would like to stay away from code covered by the GPL
> license, but if you find code out there the is the perfect
> fit for what you want, we always have the option of supporting
> it the way we support FFTW: CMake will allow developers to
> use the software if it is available in their machine, and it
> they turn ON a CMake variable.
>
> However, in the case of writing a Matlab transform, the tasks
> doesn't seem to be as daunting as to require a helper library.
>
>
>
> 4) You bring up a very important point regarding the precision
> of the numerical values written in the Transform files.
>
> This was discussed a while ago in the list, but looking at the
> code, it seems that we are still writing the transforms in
> ASCII.
>
> It is definitely worth to consider the "binary" option.
> Note that it brings with it all the local machine
> architecture issues of endianness and byte swapping....
>
> We may reuse a lot of the code from ImageIO that already handles
> that...., but we will need to add a couple of fields to the
> Transform file format to indicate "binary", and "endianness".
>
>
>
> We probably should discuss this further at the ITK Tcon...
>
>
>
>
> Luis
>
>
>
> ---------------------
> kent williams wrote:
>> 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?
>>
>> _______________________________________________
>> 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