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

Add TransformixFilter::SetTransform #747

Merged
merged 1 commit into from
Oct 26, 2022
Merged

Conversation

N-Dekker
Copy link
Member

Added support for single and composite transforms (itk::CompositeTransform). Tested with itk::TranslationTransform, itk::AffineTransform, itk::Euler2DTransform, itk::Euler3DTransform, itk::Similarity2DTransform, itk::Similarity3DTransform, and itk::BSplineTransform.

@N-Dekker N-Dekker force-pushed the TransformixFilter-SetTransform branch from b89ef2e to d3b1e66 Compare October 21, 2022 14:11
@N-Dekker
Copy link
Member Author

The most important part of the implementation is in itk::TransformixFilter<TMovingImage>::GenerateData(), in itkTransformixFilter.hxx:
https://github.com/SuperElastix/elastix/pull/747/files?file-filters%5B%5D=.hxx&show-viewed-files=true

@N-Dekker N-Dekker force-pushed the TransformixFilter-SetTransform branch from d3b1e66 to 7dff4de Compare October 24, 2022 10:28
@N-Dekker N-Dekker changed the title ENH: Add TransformixFilter::SetTransform(TransformBase::ConstPointer) Add TransformixFilter::SetTransform Oct 24, 2022
@N-Dekker N-Dekker force-pushed the TransformixFilter-SetTransform branch from 7dff4de to b285c56 Compare October 24, 2022 16:45
Comment on lines 228 to 222
if (numberOfTransforms == 0)
{
itkExceptionMacro(
"The specified composite transform has no subtransforms! At least one subtransform is required!");
}

if (numberOfTransforms != numberOfTransformParameterMaps)
{
if (numberOfTransformParameterMaps == 0)
{
transformParameterMapVector.resize(numberOfTransforms);
}
else
{
// The last TransformParameterMap is special, as it needs to be used for the final transformation.
const auto lastTransformParameterMap = transformParameterMapVector.back();
transformParameterMapVector.resize(numberOfTransforms);
transformParameterMapVector.back() = lastTransformParameterMap;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mstaring @stefanklein Please check if you like this logic:

  • The user-specified compositeTransform mus have at least one subtransform (otherwise throw an exception)
  • If the number of parameter maps is zero, resize the vecor of maps to the number of subtransforms.
  • Otherwise, if the number of subtransforms of the compositeTransform is different from the number of parameter maps, add maps to the end, or remove maps from the end, to make these numbers the same, and then, copy the original "last parameter map" to the last entry of the vector of maps (the "back").

Is that the intended behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with Marius (@mstaring) at the office: If the number of parameter maps is zero, an exception should be thrown. For the other cases, the behavior was described as intended.

Comment on lines 262 to 250
for (auto & transformParameterMap : transformParameterMapVector)
{
// Use the same transform for all parameter maps.
transformToMap(*m_Transform, transformParameterMap);
}
Copy link
Member Author

@N-Dekker N-Dekker Oct 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mstaring @stefanklein Also please check if you like this: When the specified transform is a single transform (not a composite), its Parameters/FixedParameters/etc are copied to each map. Also if there are multiple maps in the vector. Is that OK?

Should there be a check if there is at least one map? (There is one actually in TransformixFilter::GenerateOutputInformation().) Or if there is exactly one, when the transform is also a single one.

Copy link
Member Author

@N-Dekker N-Dekker Oct 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with Marius (@mstaring) at the office: when there is only one single transform, there should be only one parameter map. If there is only one single transform and the specified TransformParameterObject has more than one map, only the last map should be taken into account.

@N-Dekker N-Dekker force-pushed the TransformixFilter-SetTransform branch 2 times, most recently from fd5c293 to e10290f Compare October 25, 2022 15:11
Added support for single and composite transforms (itk::CompositeTransform). Tested with itk::TranslationTransform, itk::AffineTransform, itk::Euler2DTransform, itk::Euler3DTransform, itk::Similarity2DTransform, itk::Similarity3DTransform, and itk::BSplineTransform.
@N-Dekker N-Dekker force-pushed the TransformixFilter-SetTransform branch from e10290f to a1b2d66 Compare October 25, 2022 15:25
@N-Dekker
Copy link
Member Author

@thewtex FYI: TransformixFilter::SetTransform(const itk::TransformBase*) is underway! 🎉

@N-Dekker N-Dekker merged commit 89e8c54 into main Oct 26, 2022
@N-Dekker N-Dekker deleted the TransformixFilter-SetTransform branch October 26, 2022 13:30
N-Dekker added a commit to N-Dekker/ITKElastix that referenced this pull request Oct 27, 2022
Including pull request SuperElastix/elastix#747
commit SuperElastix/elastix@89e8c54
"ENH: Add `TransformixFilter::SetTransform(const TransformBase *)`"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants