[Insight-users] itkAnalyzeImageIO bugs/problems

Hans J. Johnson hans-johnson at uiowa . edu
29 Jul 2003 09:51:30 -0500


Keon,

Upon further invesitigation into the 3rd problem, I would have to
disagree with your diagnosis.  The suggestion you made would not be an
acceptable thing to do because it would make using the field for it's
intended purpose (i.e. holding a character string) potentially
unsafe.    We may have to change this to make it work, but that would
require some more testing.  If you have a small file in the SPM-Analyze
file format, and a description of how you would like that field
presented to you, I may be able to work through a solution for you.  

The m_hdr.hst.originator field is a 10byte field designated to hold a 10
consecutive characters.  The extra copying into the temp variable is to
explicitly add a null terminating character so that it may safely be put
into a string.  (PS:  Your solution of string(varname,10) is more
elegant, but I am not sure that it works under all compilers, and I
don't want to add any more instability to code until after august 1st.)

Is there a sentinal flag in the analyze header somewhere to specify that
this is an SPM image?  If so, we could put something like the following
in:


if(this->m_hdr.hist.funused==SPM_SENTINAL_FLAG)
	{
	itk::EncapsulateMetaData<typename SPM_TYPE>(thisDic,ITK_SPM_ORIGINFEILD_TAG,SPM_TYPE(this->m_hdr.hist.originator));
	}
else
	{
	strncpy(temp,this->m_hdr.hist.originator,10);  
	temp[10]='\0';
	itk::EncapsulateMetaData<std::string>(thisDic,ITK_FileOriginator,std::string(temp));
	}

Regards,
Hans J. Johnson
hans-johnson at uiowa . edu


PS: The other changes have already been made, and I will start testing
them right now.  Hopefully they will make it into the cvs code yet
today.  Since the bleeding edge version of ITK is undergoing many
changes before august 1st, I would suggest that you only checkout the
new Analyze files when they become available.



> 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
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users