Skip to content

Commit

Permalink
ENH: ElastixRegistrationMethod writes initial transform parameter files
Browse files Browse the repository at this point in the history
Let ElastixRegistrationMethod write the transform maps from its InitialTransformParameterObject to the output directory.
  • Loading branch information
N-Dekker committed Jun 14, 2023
1 parent 007dadd commit 9e64269
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Core/Main/itkElastixRegistrationMethod.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,25 @@ ElastixRegistrationMethod<TFixedImage, TMovingImage>::GenerateData()
m_EnableOutput && m_LogToConsole,
static_cast<elastix::log::level>(m_LogLevel));

if (m_InitialTransformParameterObject && !m_OutputDirectory.empty())
{
// Write InitialTransformParameters.0.txt, InitialTransformParameters.1.txt, InitialTransformParameters.2.txt, etc.
std::string initialTransformParameterFileName = "NoInitialTransform";
unsigned i{};

for (auto transformParameterMap : m_InitialTransformParameterObject->GetParameterMaps())
{
transformParameterMap["InitialTransformParameterFileName"] = { initialTransformParameterFileName };

const auto transformParameterFileName = "InitialTransformParameters." + std::to_string(i) + ".txt";
elx::ParameterObject::WriteParameterFile(transformParameterMap, m_OutputDirectory + transformParameterFileName);
initialTransformParameterFileName = transformParameterFileName;
++i;
}

argumentMap["-tp"] = initialTransformParameterFileName;
}

const auto fixedImageDimensionString = std::to_string(FixedImageDimension);
const auto fixedImagePixelTypeString = elx::PixelTypeToString<typename TFixedImage::PixelType>();
const auto movingImageDimensionString = std::to_string(MovingImageDimension);
Expand Down

0 comments on commit 9e64269

Please sign in to comment.