I have a 3D volume that I registered to another volume with ITK’s registration methods. My moving->fixed transformation is an Euler3DTransform.
I’d like to adjust the Origin and Direction of my moving image with the Euler3DTransform while maintaining the size and spacing of the moving image. I don’t need to resample the moving image, just adjust the information about its spatial position.
To adjust the Origin I’ve used:
tmpOrigin = myOriginalImage.GetOrigin()
newOrigin = tform.TransformPoint(tmpOrigin))
Is there an easy way in SimpleITK to apply my Euler3DTransform and adjust the Direction of the image?
I might take a crack at it, but I’ve never built SimpleITK from scratch. I can handle building and wrapping ITK but for SimpleITK I currently use the version in Ubuntu’s Apt repository.
This is the filter that I would like to use though.
There is now ResampleInPlaceImageFilter. It hasn’t made it into a release yet, so if you want it you will need to build ITK from source yourself. ITK 5.3 release cycle is scheduled for next month, so you could wait for that too.
Before this makes it into a release, consider a name change for the filter?
It isn’t really doing any resampling/computation so “ResampleInPlace” is a bit misleading. Taking a page out of the Slicer book, possibly rename to “HardenTransformImageFilter”? I’m sure there are other useful names, all of which make sense as long as we don’t use “Resample” in the name because that’s not what the filter is doing.
@hjmjohnson’s team named it when they added it to BRAINSTools. I kept that name when migrating it into ITK proper.
Notice that there is another way to do it in place, namely transform->ApplyToImageMetadata(image), which is more appropriately named and does indeed work in place.
I also find the term “InPlace” in the filter’s name misleading, as it is not derived from the InPlaceImageFilter, it doesn’t not have the “InPlace” parameter, and the filter always makes a copy of the input image’s bulk data to the output.
Also the filter does not correctly update the metadata of the image in the update output information step of the pipeline.
This filter needs some work, that I can help with.
Unfortunately, I can’t think of a name I really like “TransformImageFilter”, “RigidTransformImageFilter”…
The GenerateOutputInformation method is not overloaded. This method updates the size, spacing, origin, direction cosines. Downstream filters when pipelines expect this information to be updated, and correct at this phase of pipeline execution.
The ResampleInPlaceImageFilter, modifies the meta data in the GenerateData method. This is in violation of the contract of a filter to be able to run multiple filters in a pipeline.
If the refactoring changes the filter to inherit from InPlaceImageFilter, maybe we could also keep the old, unchanged filter which duplicates the image (with just the GenerateOutputInformation fixed)?
So it looks like there are three terms/parts in the class/method naming that do not convince us:
“InPlace”: I haven’t considered the “InPlace” nature of the name. Sorry .
“Resample”: I had commented on the “Resample” term throughout in-line comments in the PR, as I found it a little bit misleading across the documentation. Once the documentation and naming were made consistent, I did not really look at whether the “Resample” part was really honoring the purpose of the class (sorry ).
If I had to suggest something, I think those are better if we are to leave out the “InPlace”, “Resample” and “Harden” parts, or else e.g. “TransformExecutorImageFilter”, “TransformEnforcementImageFilter”, “TransformEnforcerImageFilter” if we are to give a “doer” nature to the class naming, and if they make sense.
That said, I do not want to be a show-stopper: if people think it including “Harden” in the class name is intuitive, and as long as what the method does is well documented, then I’d be fine.
I don’t really have a strong preference on name. I agree with @blowekamp that the name we choose a lifetime ago for private use does conflict with other naming paradigms in use in ITK.
I don’t have strong feelings, but the term “Harden” is what slicer uses. “PhysicalSpaceTransformComposeImageFilter” ? This filter is VERY important to get into the code base. Anything I can do to facilitate getting it fixed and improved would be greatly appreciated.