Skip to content

Conversation

@vboussot
Copy link

@vboussot vboussot commented Jul 1, 2025

This PR adds support for using ITK transform files (*.itk.txt) as initial transforms in Elastix via the -t0 flag.

While Elastix already supports exporting transforms in ITK format, I’ve often needed the reverse, initializing a registration from an existing ITK transform. This addition closes that gap, enabling reuse of transforms from ITK pipelines.

A small contribution, as suggested 😉, but it adds a feature I’ve personally missed many times and I suspect I’m not the only one.

…se\n\nAdded support in TransformBase::ReadInitialTransformFromFile to detect and load ITK-formatted transform files (*.itk.txt) using TransformIO.\n Introduced a new method ReadInitialItkTransformFromConfiguration() for handling such transforms separately from standard elastix .txt parameter files.\n This enables direct reuse of transforms generated by ITK pipelines.
@N-Dekker
Copy link
Member

N-Dekker commented Jul 2, 2025

Interesting proposal, thanks @vboussot However, this is larger than the minimal stylish pull request I had in mind for you, just to let GitHub know that you are no longer a "first-time contributor"! I think your proposal needs some more discussion, and possibly a few more iterations. (In the mean time, GitHub will still think you're a "first-time contributor", so it won't automatically approve the so-called "workflow" of your pull request.)

elastix does already support ITK transform files as input, but in an indirect way. You may find it less convenient, but it should work, for the most commonly used ITK transform types. For an initial transform, this works by the following tags

// Elastix TransformParameterFile.txt 
(Transform "File")
(TransformFileName "ITK-Transform.tfm")

Or with a TOML file:

// Elastix TransformParameterFile.toml 
Transform = "File"
TransformFileName = "ITK-Transform.tfm"

Assuming that "ITK-Transform.tfm" is an ITK transform file.

So then, the transform is specified by an ITK file, but the Elastix TransformParameterFile may still have extra parameters. For example, it may still refer to a prior transform (elastix transform parameter InitialTransformParameterFileName), that should be applied before the current one. It may also specify how to combine multiple transforms (elastix transform HowToCombineTransforms).

What do you think?

@vboussot
Copy link
Author

vboussot commented Jul 3, 2025

Yes, you're right, Elastix already supports ITK transform files via (Transform "File"). My PR simply builds on that existing mechanism, I’ve reused the same logic internally. The goal is to make it more intuitive and convenient to use an ITK transform directly with the -t0 flag.

So this is really just syntactic sugar, no new transform logic, just a simpler and more direct way to do something that’s already supported, but currently a bit more verbose.

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