SimpleITK Euler3D Transform, Adjust Image Origin and Direction

Hi board,

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?

See PR2249 and comments therein.

If you are up for it, you could add itkResampleInPlaceImageFilter.h into ITK, probably into Transform module. PR2249 could then be closed in favor of that.

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.

Hello,
Did you find a solution for this? I struggle with the same problem but with the comments of dzenanz I won’t come much further. Thank you!

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.

Hello @dzenanz,

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.

1 Like

I originally wanted to call it harden transform :smiley:

@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.

1 Like

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”…

What do you mean? Could that be the reason for issue 2703 submitted by @hjmjohnson?

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.

1 Like

Thanks for the explanation. That might very well be the root cause of #2703.

I can do a refactor of the filter. Once a name is decided on. I think “HardenTransformImageFilter” is the best suggestion so far.

1 Like

There was some discussion about the name already. I hope that @jhlegarreta and @hjmjohnson will pitch in on the name.

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 :pensive:.
  • “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 :pensive:).
  • Following my comment https://github.com/InsightSoftwareConsortium/ITK/pull/2249#issuecomment-759865588, and as opposed to @zivy’s proposal, I still do not think that using the term “Harden” is the best choice; could be interesting to know how the process of applying a transform is named in other places/methods in ITK for the sake of consistency.

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.

1 Like

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.

Hans

2 Likes

Lets come to a quick consensus, please vote:

  • HardenTransformImageFilter
  • PhysicalSpaceTransformComposeImageFilter
  • TransformEnforcementImageFilter

0 voters

1 Like

Hello all,

If you haven’t voted, bringing this to your attention via tagging (please excuse if you have already voted, can’t see who voted): @dzenanz, @jhlegarreta, @hjmjohnson, @blowekamp, @lassoan

Please voice your opinion, so we can close this survey today evening (5pm EST).

thanks
Ziv

As there are 5 votes, it might be exactly the 5 of us who voted :smiley:

Very likely.

Because I can’t see who voted didn’t want to say that we arrived at a decision, just yet. Will wait till 5pm EST today to make that claim.

1 Like