diff --git a/Core/ComponentBaseClasses/elxTransformBase.hxx b/Core/ComponentBaseClasses/elxTransformBase.hxx index b9bc67e08..41d9d57e6 100644 --- a/Core/ComponentBaseClasses/elxTransformBase.hxx +++ b/Core/ComponentBaseClasses/elxTransformBase.hxx @@ -437,8 +437,9 @@ TransformBase::ReadFromFile() this->GetAsITKBaseType()->SetUseComposition(howToCombineTransforms == "Compose"); /** Task 4 - Remember the name of the TransformParametersFileName. - * This will be needed when another transform will use this transform - * as an initial transform (see the WriteToFile method) + * This will be needed when another transform will use this transform as an initial transform (see the WriteToFile + * method), which is relevant for transformix, as well as for elastix (specifically + * ElastixRegistrationMethod::GenerateData(), when InitialTransformParameterObject is specified). */ this->SetTransformParametersFileName(configuration.GetCommandLineArgument("-tp")); diff --git a/Core/Main/itkElastixRegistrationMethod.hxx b/Core/Main/itkElastixRegistrationMethod.hxx index 8c96f8482..6b6290517 100644 --- a/Core/Main/itkElastixRegistrationMethod.hxx +++ b/Core/Main/itkElastixRegistrationMethod.hxx @@ -179,9 +179,10 @@ ElastixRegistrationMethod::GenerateData() if (m_InitialTransformParameterObject && !m_OutputDirectory.empty()) { - // Write InitialTransformParameters.0.txt, InitialTransformParameters.1.txt, InitialTransformParameters.2.txt, etc. std::string initialTransformParameterFileName = "NoInitialTransform"; - unsigned i{}; + + // Write InitialTransformParameters.0.txt, InitialTransformParameters.1.txt, InitialTransformParameters.2.txt, etc. + unsigned i{}; for (auto transformParameterMap : m_InitialTransformParameterObject->GetParameterMaps()) { @@ -193,6 +194,10 @@ ElastixRegistrationMethod::GenerateData() ++i; } + // Pass the last initial transform parameter file name to the argument map, in order to have it stored by + // elx::TransformBase::ReadFromFile(), so that it can be retrieved later by + // elx::TransformBase::GetInitialTransformParametersFileName(). Use "-tp", instead of "-t0", to avoid actual file + // reading of the initial transforms, as they are already in memory. argumentMap["-tp"] = initialTransformParameterFileName; }