From e96012523f1b7025213873ea8aef79f65bef8dbe Mon Sep 17 00:00:00 2001 From: Niels Dekker Date: Wed, 23 Mar 2022 17:21:09 +0100 Subject: [PATCH] STYLE: Encapsulate NiftiImage qto_xyz mat44 data as `Matrix` Using `itk::Matrix` (instead of `std::vector`) to store the "qto_xyz" data from m_NiftiImage, as this `Matrix` template instantiation more closely resembles the original niftilib `mat44` data structure. --- Modules/Core/Common/include/itkMetaDataObject.h | 1 + Modules/Core/Common/src/itkMetaDataObject.cxx | 1 + Modules/IO/NIFTI/src/itkNiftiImageIO.cxx | 12 +++--------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Modules/Core/Common/include/itkMetaDataObject.h b/Modules/Core/Common/include/itkMetaDataObject.h index 8fab875c797..91023fc5e77 100644 --- a/Modules/Core/Common/include/itkMetaDataObject.h +++ b/Modules/Core/Common/include/itkMetaDataObject.h @@ -364,6 +364,7 @@ extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject>; extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject>; extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject>; extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject>; +extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject>; extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject>; ITK_GCC_PRAGMA_DIAG_POP() diff --git a/Modules/Core/Common/src/itkMetaDataObject.cxx b/Modules/Core/Common/src/itkMetaDataObject.cxx index ab5b909f9e5..36c38a33cc7 100644 --- a/Modules/Core/Common/src/itkMetaDataObject.cxx +++ b/Modules/Core/Common/src/itkMetaDataObject.cxx @@ -43,6 +43,7 @@ template class ITKCommon_EXPORT MetaDataObject>; template class ITKCommon_EXPORT MetaDataObject>; template class ITKCommon_EXPORT MetaDataObject>; template class ITKCommon_EXPORT MetaDataObject>; +template class ITKCommon_EXPORT MetaDataObject>; template class ITKCommon_EXPORT MetaDataObject>; template class ITKCommon_EXPORT MetaDataObject>; template class ITKCommon_EXPORT MetaDataObject>; diff --git a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx index ac96e85de2f..c8d58a7e567 100644 --- a/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx +++ b/Modules/IO/NIFTI/src/itkNiftiImageIO.cxx @@ -999,15 +999,9 @@ NiftiImageIO::SetImageIOMetadataFromNIfTI() EncapsulateMetaData(thisDic, "qfac", nim->qfac); - std::vector qto_xyz; - for (int row = 0; row < 4; ++row) - { - for (int column = 0; column < 4; ++column) - { - qto_xyz.push_back(nim->qto_xyz.m[row][column]); - } - } - EncapsulateMetaData>(thisDic, "qto_xyz", qto_xyz); + // Use the ITK Matrix template instantiation that matches the `mat44` typedef from niftilib. + using Matrix44Type = Matrix; + EncapsulateMetaData(thisDic, "qto_xyz", Matrix44Type(nim->qto_xyz.m)); } void