[Insight-developers] Speak now or forever hold your peace
w.r.t. itk::TransformFileReader/Writer
kent williams
norman-k-williams at uiowa.edu
Fri Aug 3 10:26:07 EDT 2007
On 8/3/07 7:51 AM, "Luis Ibanez" <luis.ibanez at kitware.com> wrote:
>
> Does this involve any API change ?
>
It doesn't change the existing API. The Matlab file it writes is
functionally equivalent to the text file -- it writes out and reads in a
list of transforms.
Right now I've exposed as public 'WriteTextTransform' 'WriteMatlabTransform'
and 'ReadTextTransform' and 'WriteMatlabTransform' with the thought that
would explicitly want one or ther other in some cases. But I don't
necessarily think this is a good idea; it would allow you to write a text
transform file named something.mat, which wouldn't read in so well.
I've thought about adding some sniffing code to the reader to make sure that
the right reader is getting called. The vnl matlab header will always have
a non-printing character in the first 4 bytes, and if we've settled on a One
True Text Transform file format, will always start with '#Insight'
> We could expect that users will also need to write
> VTK transforms, IDL transforms, OpenGL transforms...
>
Well, I haven't looked at any of those other libraries and how they
represent transforms, and given the specificity of
itk::TransformFileRead/Write to ITK transform classes, I don't know how it
could accommodate those other libraries. Matlab Level 4 files can certainly
handle any 2D matrix, 1D Vectors, and scalars, and complex versions of those
constructs.
Looking at the vnl_matlab classes, I'm not sure it handles foreign byte
order at all correctly -- there's no endian test or byte swapping
incorporated. That would need addressing before this goes into production
code.
> Note that only Affine-like transforms can be written
> in Matlab format. (AFAIK).
Only affine transforms have a straightforward matrix representation, but
that's not what I'm writing. What I've done is to parallel the text
transform format -- I write out the Parameter and FixedParameter vectors
from the transform object, and on reading in, I use the same factory pattern
to recreate the Transform object and assign the parameters and fixed
parameters.
> How are you dealing with the case where the input transform
> happens to be a BSplineDeformable, or a ThinPlateKernelTransform ?
>
>
> Throw an exception ?
>
It's the same as the existing Text Transform code -- it will read and write
anything that the TransformFactoryBase can create, which doesn't include
either of those classes. And yes it throws an exception.
More information about the Insight-developers
mailing list