Skip to content

Commit

Permalink
STYLE: Encapsulate NiftiImage qto_xyz mat44 data as Matrix<float,4,4>
Browse files Browse the repository at this point in the history
Using `itk::Matrix<float, 4, 4>` (instead of `std::vector<float>`) to
store the "qto_xyz" data from m_NiftiImage, as this `Matrix` template
instantiation more closely resembles the original niftilib `mat44` data
structure.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Mar 25, 2022
1 parent 9325b2a commit e00bad0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions Modules/Core/Common/include/itkMetaDataObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject<Array<char>>;
extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject<Array<int>>;
extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject<Array<float>>;
extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject<Array<double>>;
extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject<Matrix<float, 4, 4>>;
extern template class ITKCommon_EXPORT_EXPLICIT MetaDataObject<Matrix<double>>;

ITK_GCC_PRAGMA_DIAG_POP()
Expand Down
1 change: 1 addition & 0 deletions Modules/Core/Common/src/itkMetaDataObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ template class ITKCommon_EXPORT MetaDataObject<Array<char>>;
template class ITKCommon_EXPORT MetaDataObject<Array<int>>;
template class ITKCommon_EXPORT MetaDataObject<Array<float>>;
template class ITKCommon_EXPORT MetaDataObject<Array<double>>;
template class ITKCommon_EXPORT MetaDataObject<Matrix<float, 4, 4>>;
template class ITKCommon_EXPORT MetaDataObject<Matrix<double>>;
template class ITKCommon_EXPORT MetaDataObject<std::vector<float>>;
template class ITKCommon_EXPORT MetaDataObject<std::vector<double>>;
Expand Down
12 changes: 3 additions & 9 deletions Modules/IO/NIFTI/src/itkNiftiImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -999,15 +999,9 @@ NiftiImageIO::SetImageIOMetadataFromNIfTI()

EncapsulateMetaData<float>(thisDic, "qfac", nim->qfac);

std::vector<float> 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<std::vector<float>>(thisDic, "qto_xyz", qto_xyz);
// Use the ITK Matrix template instantiation that matches the `mat44` typedef from niftilib.
using Matrix44Type = Matrix<float, 4, 4>;
EncapsulateMetaData<Matrix44Type>(thisDic, "qto_xyz", Matrix44Type(nim->qto_xyz.m));
}

void
Expand Down

0 comments on commit e00bad0

Please sign in to comment.