[Insight-developers] *.nii Endianness Patch?

Matt McCormick matt.mccormick at kitware.com
Tue Jul 2 17:05:03 EDT 2013


On Tue, Jul 2, 2013 at 8:54 PM, Kevin H. Hobbs <hobbsk at ohio.edu> wrote:
> 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.
>

Very cool.  Do you have a small test big endian Nifti image that can
be used in additional test cases?

Thanks,
Matt


More information about the Insight-developers mailing list