Skip to content

Commit

Permalink
DOC: Explain ElastixRegistrationMethod use "-tp" for initial transforms
Browse files Browse the repository at this point in the history
Follow-up to pull request #909 commit 9e64269 "ENH: ElastixRegistrationMethod writes initial transform parameter files"

Requested by Marius Staring.
  • Loading branch information
N-Dekker committed Jun 15, 2023
1 parent 9e64269 commit 47db252
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Core/ComponentBaseClasses/elxTransformBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,9 @@ TransformBase<TElastix>::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"));

Expand Down
9 changes: 7 additions & 2 deletions Core/Main/itkElastixRegistrationMethod.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ ElastixRegistrationMethod<TFixedImage, TMovingImage>::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())
{
Expand All @@ -193,6 +194,10 @@ ElastixRegistrationMethod<TFixedImage, TMovingImage>::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;
}

Expand Down

0 comments on commit 47db252

Please sign in to comment.