[Insight-developers] *.nii Endianness Patch?

Kevin H. Hobbs hobbsk at ohio.edu
Tue Jul 2 16:54:53 EDT 2013


On 07/02/2013 04:10 PM, Matt McCormick wrote:
> Hi Kevin,
> 
> Thanks for the report.  I have created an issue [1] in the issue
> tracker to keep track of the issue.
> 
> Thanks,
> Matt
> 
> [1] https://issues.itk.org/jira/browse/ITK-3165
> 

I have the start of a patch :

diff --git a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
index 3836a29..498eb3e 100644
--- a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
+++ b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
@@ -1257,6 +1257,16 @@ NiftiImageIO
   EncapsulateMetaData< std::string >(this->GetMetaDataDictionary(),
                                      ITK_FileNotes, description);

+  // Set byte order
+  if( this->m_NiftiImage->byteorder == 1 ) // LSB_FIRST
+    {
+    this->m_ByteOrder = LittleEndian;
+    }
+  if( this->m_NiftiImage->byteorder == 2 ) // MSB_FIRST
+    {
+    this->m_ByteOrder = BigEndian;
+    }
+
   // We don't need the image anymore
   nifti_image_free(this->m_NiftiImage);
   this->m_NiftiImage = 0;

"It works for me" but I've only looked at one image on one machine and I
don't really know the implications of setting this member variable.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 255 bytes
Desc: OpenPGP digital signature
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20130702/97afc0da/attachment.pgp>


More information about the Insight-developers mailing list