Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/upstream/release-5.4' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanz committed Aug 21, 2024
2 parents f026b76 + 9b7d005 commit 3e66ec2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,17 @@ NiftiImageIO::WriteImageInformation()
strcpy(this->m_NiftiImage->aux_file, temp.c_str());
}
}
if (itk::ExposeMetaData<std::string>(thisDic, "ITK_FileNotes", temp))
{
if (temp.length() > 79)
{
itkExceptionMacro("ITK_FileNotes (Nifti descrip field) too long, Nifti limit is 79 characters");
}
else
{
strcpy(this->m_NiftiImage->descrip, temp.c_str());
}
}

// Enable RAS conversion based on metadata and flags
this->m_ConvertRAS = (m_ConvertRASVectors && this->m_NiftiImage->intent_code == NIFTI_INTENT_VECTOR) ||
Expand Down
16 changes: 16 additions & 0 deletions Modules/IO/NIFTI/test/itkNiftiImageIOTest3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ TestImageOfVectors(const std::string & fname, const std::string & intentCode = "
itk::MetaDataDictionary & dictionary = vi->GetMetaDataDictionary();
itk::EncapsulateMetaData<std::string>(dictionary, "intent_code", intentCode);
}
std::string description("text description of file content");
itk::EncapsulateMetaData<std::string>(vi->GetMetaDataDictionary(), "ITK_FileNotes", description);
try
{
itk::IOTestHelper::WriteImage<VectorImageType, itk::NiftiImageIO>(vi, fname);
Expand Down Expand Up @@ -190,6 +192,7 @@ TestImageOfVectors(const std::string & fname, const std::string & intentCode = "
{
const itk::MetaDataDictionary & dictionary = readback->GetMetaDataDictionary();
std::string readIntentCode;
std::string readDescription;
if (itk::ExposeMetaData<std::string>(dictionary, "intent_code", readIntentCode))
{
if (readIntentCode != intentCode)
Expand All @@ -203,6 +206,19 @@ TestImageOfVectors(const std::string & fname, const std::string & intentCode = "
std::cout << "The read image should have an intent_code in its dictionary" << std::endl;
same = false;
}
if (itk::ExposeMetaData<std::string>(dictionary, "ITK_FileNotes", readDescription))
{
if (readDescription != description)
{
std::cout << "ITK_FileNotes is different: " << readDescription << " != " << description << std::endl;
same = false;
}
}
else
{
std::cout << "The read image should have a ITK_FileNotes (nifti descrip field) in its dictionary" << std::endl;
same = false;
}
}
if (readback->GetOrigin() != vi->GetOrigin())
{
Expand Down

0 comments on commit 3e66ec2

Please sign in to comment.