[Insight-developers] Re: itkMetaDataDictionary

Hans J. Johnson hans-johnson@uiowa.edu
19 Mar 2003 12:01:13 -0600


Mathieu,

Background:
===========
I have added a few convenience functions last night that should make
using the itkMetaDataDictionary a lot easier.  I have also reworked the
itkAnalyzeIO filter to use these new convenience functions. 

The two functions are EncapsulateMetaData and ExposeMetaData, and they
take care of a lot of the dynamic casting and MetaDataObject
generation.  (As a bonus, this also takes care of some memory leaks that
were occuring in earlier versions.)

It is important to note that the MetaDataDictionary is a very flexible
mechanism for storing any type of data.  Keeping the information in the
dictionary useful across different applications is outside the scope of
the MetaDataDictionary design (but not outside the scope of the ITK
design).

Your Questions:
===============
> 	I had a look at itkMetaDataDictionary but I am not sure about some 
> issues. As I don't get insight-dev mails I hope this has not already 
> been discussed.
> 
> Anyway.
> 	What is the typo define for an entry in itkMetaDataDictionary

At it's core it is just a std::map with keys of type std::string, and
values of type itk::SmartPointer<itk::MetaDataObjectBase>.  The hope was
that anybody could put any type of data into the dictionary.

> 
> For example in itkAnalyzeIO: Hans you defined ITK_OnDiskStorageTypeName 
> and "
> 
> - One is begining with "ITK" the other "ANALYZE" ...
> - Should I use capital letter, "_" , AaaBbbbCcc

The identifiers "ITK_OnDiskStorageTypeName" and "ANALYZE_GLMIN" are
completely arbitrary, and have not implicit meaning at this point.  In
this particular example, I have encapsulated an integer value into the
dictionary that can be referenced with the "ANALYZE_GLMIN" key, and an
std::string value that can be referenced with the
"ITK_OnDiskStorageTypeName" key.  The keys have no implicit meaning as
to what they hold.  As far as the MetaDataDictionary is concerned, the
itkAnalyzeIO could encapsulate an std::string with key
"ITK_OnDiskStorageTypeName", and the itkStimulateImage could encapsulate
an integer with key "ITK_OnDiskStorageTypeName".

Obviously we need to impose some standards external to the dictionary so
that the same information is shared between all developers.  These
standards are probably domain dependant, i.e. one set of standards for
IO routines that work with the dictionary, and another set of standards
for filter routines that work with the dictionary, and yet another set
of standards for each application that works with the dictionary.

As a first pass at this, I have prefixed items that I think are general
to many IO routines with "ITK", and prefixed items only relevant to the
analyze IO with "ANALYZE_".  I am working on a set of shared definitions
that will be placed in IOCommon.h for use by all the IO
filters(hopefully done this afternoon).

===itkIOCommon.h===
//                  
extern const std::sring ITK_OnDiskStorageTypeName_Key;//Dictionary
object intended for holding a std::string with a plain text description
of the on disk storarge type.  i.e. "float" or "unsigned int"
  . . . 
extern const std::string ITK_Orientation_Key;//Dictionary object
intended for holding an itk::ITK_Orientation with an identifier
describing the anatomical orientation of the subject data in image
space.
===itkIOCommon.cpp==
const std::string
ITK_OnDiskStorageTypeName_Key("ITK_OnDiskStorageTypeName");
  . . . 
const std::string ITK_Orientation_Key("ITK_Orientation");

========itkAnalyzeIO.cpp==================================
{
  itk::IOCommon::ValidOrientationFlags temporient;
itk::ExposeMetaData<itk::IOCommon::ValidOrientationFlags>
           (
              thisDic,
              itk::IOCommon::ITK_Orientation_Key,
              temporient
            );
          
this->m_hdr.hist.orient=static_cast<itk::IOCommon::ValidOrientationFlags>(temporient);
}


> 
> Furthermore you use then:
> 
> std::string does it mean I should use the std when possible. For 
> instance in my itkStimulateIO I have a vector of 3 float that I would 
> add to the Dictionary. Should I use:
> 
> - std::vector
> - itk::Vector
> - vnl_vector
> 
>From a technical standpoint, any of these storage types will work.  I
don't know what the data represents, or how what it's intended use is. 
I would suggest that you store it in whatever type makes it most useful
in latter processing, and then add good documentation.


I hope this helps,

Hans J. Johnson
hans-johnson@uiowa.edu

> Thanks for your precisions,
> 
> regards,
> mathieu
> 
> -- 
> Mathieu Malaterre
> CREATIS
> 28 Avenue du Doyen LEPINE
> B.P. Lyon-Montchat
> 69394 Lyon Cedex 03
> http://www.creatis.insa-lyon.fr/~malaterre/