[Insight-users] itkAnalyzeImageIO bugs/problems

Koen Van Leemput koen . vanleemput at hus . fi
Tue, 29 Jul 2003 13:52:57 +0300


Hi,

When I was trying to read images written with ITK's Analyze writer (CVS 
version) into SPM and vice versa, I came across the following problems:

--

Problem 1: Images of pixel type "unsigned short" cannot be exchanged between 
ITK and SPM. 

I quickly checked the Analyze format, and it would appear that Analyze simply 
doesn't support images of this pixel type. In ITK, the pixel type field for 
unsigned short is set to "6", whereas this is "132" in SPM. Is there a 
specific reason why ITK has chosen 6? And if not, would it be possible to use 
SPM's definition? 

Aside from "unsigned short", also "unsigned int" seems different between ITK 
(defined as 12) and SPM (defined as 136).
 
In case it is decided to change ITK's Analyze image IO, the following lines 
should be changed:

itkAnalyzeDbh.h, line 51-52: 

ANALYZE_DT_UNSIGNED_SHORT =6 
ANALYZE_DT_UNSIGNED_INT   =12

into:

ANALYZE_DT_UNSIGNED_SHORT =132
ANALYZE_DT_UNSIGNED_INT   =136


--

Problem 2: Analyze images of pixel type "unsigned char" get read as "char" in 
ITK. This is simply a bug:

itkAnalyzeImageIO.cxx, line 888-891

case ANALYZE_DT_UNSIGNED_CHAR:
  m_ComponentType = CHAR;
  m_PixelType = CHAR;
 
should be

case ANALYZE_DT_UNSIGNED_CHAR:
  m_ComponentType = UCHAR;
  m_PixelType = UCHAR;

 
--

Problem 3: the FileOriginator field, (ab)used in SPM to store the origin,  
doesn't get read properly on my machine (gcc 3.2 on Linux Mandrake 9.1) 

itkAnalyzeImageIO.cxx, line 977-979

strncpy(temp,this->m_hdr.hist.originator,10);  
temp[10]='\0';
itk::EncapsulateMetaData<std::string>(thisDic,ITK_FileOriginator,std::string(temp));

should be

itk::EncapsulateMetaData<std::string>(thisDic,ITK_FileOriginator,std::string(this->m_hdr.hist.originator,10));

This also applies to the many other fields in the MetaDataDictionary for 
itkAnalyzeImageIO.

--

That's all ;-)

- Koen