Skip to content

Commit

Permalink
BUG: Missing modality tag when reading meta-image format.
Browse files Browse the repository at this point in the history
The modality of a meta image is not stored as part of the metadata
dictionary and was not copied into the ITK metadata dictionary. This
change addresses the issue.
  • Loading branch information
zivy committed Mar 28, 2024
1 parent fad5849 commit ac3870e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Modules/IO/Meta/src/itkMetaImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "itkMath.h"
#include "itkSingleton.h"
#include "itkMakeUniqueForOverwrite.h"
#include "metaImageUtils.h"

namespace itk
{
Expand Down Expand Up @@ -404,6 +405,12 @@ MetaImageIO::ReadImageInformation()

std::string classname(this->GetNameOfClass());
EncapsulateMetaData<std::string>(thisMetaDict, ITK_InputFilterName, classname);

// metaImage has a Modality tag which is not stored as part of its
// metadata dictionary
std::string modality;
MET_ImageModalityToString(m_MetaImage.Modality(), modality);
EncapsulateMetaData<std::string>(thisMetaDict, "Modality", modality);
//
// save the metadatadictionary in the MetaImage header.
// NOTE: The MetaIO library only supports typeless strings as metadata
Expand Down
3 changes: 3 additions & 0 deletions Modules/IO/Meta/test/itkMetaImageIOTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ itkMetaImageIOTest(int argc, char * argv[])
myImage::Pointer image = reader->GetOutput();
image->Print(std::cout);

// MetaImage is expected to have a modality tag
image->GetMetaDataDictionary().Get("Modality");

myImage::RegionType region = image->GetLargestPossibleRegion();
std::cout << "region " << region;

Expand Down

0 comments on commit ac3870e

Please sign in to comment.