-
Notifications
You must be signed in to change notification settings - Fork 121
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
Conversation
b89ef2e
to
d3b1e66
Compare
The most important part of the implementation is in |
d3b1e66
to
7dff4de
Compare
TransformixFilter::SetTransform(TransformBase::ConstPointer)
TransformixFilter::SetTransform
7dff4de
to
b285c56
Compare
Core/Main/itkTransformixFilter.hxx
Outdated
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; | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Core/Main/itkTransformixFilter.hxx
Outdated
for (auto & transformParameterMap : transformParameterMapVector) | ||
{ | ||
// Use the same transform for all parameter maps. | ||
transformToMap(*m_Transform, transformParameterMap); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
fd5c293
to
e10290f
Compare
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.
e10290f
to
a1b2d66
Compare
@thewtex FYI: |
Including pull request SuperElastix/elastix#747 commit SuperElastix/elastix@89e8c54 "ENH: Add `TransformixFilter::SetTransform(const TransformBase *)`"
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.