Apply Demons transformation onto an image.

This is my first time using SimpleITK, I’m interested in using the Demons registration algorithm, I’m using the python version of this: DemonsRegistration1 — SimpleITK 2.0rc2 documentation
after applying the algorithm to the images, I’m only getting a transformation file (.txt),
how do I apply this transformation to my image and save it?

Hello @eyalol,

Welcome to SimpleITK!

The immediate, yet not so useful answer, is:

sitk.WriteImage(out, 'resampled_moving_image.nrrd')

The useful answer, learn SimpleITK in a principled way:

  1. Read about the toolkit’s fundamental concepts.
  2. Take the online tutorial.
  3. Skim the toolkit’s Jupyter notebooks repository, specifically the 6* series that illustrate various aspects of registration.

Thank you.

I’m planning on taking that tutorial, however, for now i’m looking for a “quick and dirty” way.

Your code snippet is about writing an image to disk if i’m not wrong, though i’m looking to apply the ‘outTx’ transform in the code example that i sent, onto the ‘moving’ image.

What i’m looking for, is for a continuation to the code example i sent, in order to apply the transform and save the registered image.

Good day!

Hello @eyalol,

The code snippet was referring to the example you were pointing to. There is the section under if ("SITK_NOSHOW" not in os.environ) which resamples the moving image, the only thing missing there was writing it to disk which is the one liner I provided.

In your code you can just resample and write to disk as you don’t care about opening the image in an external application for visualization.

1 Like