Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Support ITK transform files with corrected group names #65

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Modules/IO/TransformHDF5/include/itkHDF5TransformIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ struct ITKIOTransformHDF5_EXPORT HDF5CommonPathNames
static const std::string transformTypeName;
static const std::string transformFixedName;
static const std::string transformParamsName;
static const std::string transformFixedNameCorrected;
static const std::string transformParamsNameCorrected;
static const std::string ItkVersion;
static const std::string HDFVersion;
static const std::string OSName;
Expand Down
23 changes: 19 additions & 4 deletions Modules/IO/TransformHDF5/include/itkHDF5TransformIO.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,28 @@ HDF5TransformIOTemplate<TParametersValueType>
// Composite transform doesn't store its own parameters
if(transformType.find("CompositeTransform") == std::string::npos)
{
std::string fixedParamsName(transformName);
fixedParamsName += transformFixedName;
std::string fixedParamsName(transformName + transformFixedName);

// check if group exists
htri_t exists = H5Lexists( this->m_H5File->getId(),
fixedParamsName.c_str(),
H5P_DEFAULT);
if ( exists == 0 )
{
fixedParamsName = transformName + transformFixedNameCorrected;
}
FixedParametersType fixedparams(this->ReadFixedParameters(fixedParamsName));
transform->SetFixedParameters(fixedparams);

std::string paramsName(transformName);
paramsName += transformParamsName;
std::string paramsName(transformName + transformParamsName);

exists = H5Lexists( this->m_H5File->getId(),
paramsName.c_str(),
H5P_DEFAULT);
if ( exists == 0 )
{
paramsName = transformName + transformParamsNameCorrected;
}
ParametersType params = this->ReadParameters(paramsName);
transform->SetParametersByValue(params);
}
Expand Down
3 changes: 3 additions & 0 deletions Modules/IO/TransformHDF5/src/itkHDF5TransformIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const std::string HDF5CommonPathNames::transformGroupName(std::string("/Transfor
const std::string HDF5CommonPathNames::transformTypeName("/TransformType");
const std::string HDF5CommonPathNames::transformFixedName("/TranformFixedParameters");
const std::string HDF5CommonPathNames::transformParamsName("/TranformParameters");

const std::string HDF5CommonPathNames::transformFixedNameCorrected("/TransformFixedParameters");
const std::string HDF5CommonPathNames::transformParamsNameCorrected("/TransformParameters");
const std::string HDF5CommonPathNames::ItkVersion("/ITKVersion");
const std::string HDF5CommonPathNames::HDFVersion("/HDFVersion");
const std::string HDF5CommonPathNames::OSName("/OSName");
Expand Down