Show transform being updated during registration

hi community
can i set a callback function to brainsfit or elastix when brainsfit or elastix running on each iteration?

Brainsfit is a CLI module. CLI module output is collected during execution and made accessible when execution ends. If the process output contains specially formatted “progress output” text (information about what stage the processing is in and what is the progress within that stage and what is the overall progress) then that information is displayed during execution in the module GUI. However, I don’t think Brainsfit module provides progress output. You would need to modify it to gather progress input during execution and print it on the process output with that special formatting.

Elastix is a Python scripted module. You can change the part of the Python script that displays the process output in the Python console to print it in a GUI widget or interpret it and use it any way you want (display it as a progress bar, show current metric value, etc.).

What is your overall goal? Would you like to display progress information during registration?

1 Like

thank you very much lassoan
your advice is very helpful , i think i know what to do in next step
yes,my boss want to display registration moving image in each iteration step , he says “it’s owesome to show registration progress on renderwindow when the registration button is pressed”

I see. Yes, the videos showing the evolution of the registration in time are very cool. During time when you start experimenting with new registration tools it may be actually useful to see this, because you could abort the registration if you see that it is not converging at all.

However, during normal the disadvantage of slowdown (caused by exporting the transformation parameters, applying them, and update the rendering) could be significant, and there would be not much advantage in seeing the evolving transformation.

Implementation for linear transforms could be relatively easy, but it would require some changes in the registration tool (to display transform parameters), a small changes in Slicer core to continuously make the process output available (not just when the registration is finished), and development of a small script that observes the process output and updates the transform in the scene. For warping transforms, passing the transform parameters and applying the transform could be time-consuming, so it could significantly slow down the registration, therefore probably the feature would be very rarely used.

Still, if you are interested in developing this then we can guide you through the process.

1 Like

thank you very much lassoan
thank you for reply so detail
Our use scenario is to register images of different modal of the same patient, so rigid registration is most often used, which is also the reason why similar manufacturers use video to show the registration process
i am interested in developing this,I hope I can get your guidance !

The first step is to update the CLI module execution class to save process output into the CLI node during execution (not just at the end, when execution is completed). For this you need to build Slicer. Let us know if you have managed to build Slicer or you have run into errors that you cannot solve.

thank you lassoan
i have managed to build Slicer and understand the code of main module in Slicer
i am trying to start to update the CLI module and wait for the second step :smile:


You may want to use the debugger to go through the code in vtkSlicerCLIModuleLogic.cxx in this directory to see how progress is handled. I believe Andras is suggesting that you can extend the progress notification code to include a matrix that would update the transform for a real-time update.

1 Like

thank you pieper!
your suggestion is very detail i think i understand what to do next now

Congratulations @jay1987, successfully building Slicer is already an accomplishment.

I’ve made an improvement in Slicer core (pull request is expected to be integrated tonight), which allows continuously monitoring process output. This allows getting transforms from BRAINS and ANTs registration (Elastix output can be captured here).

Now, the next step is to check if the registration tool that you want to use has an option to print the current rigid transform parameters on its output. If you cannot find such option, then ask on the forum/support site of the tool to confirm that the tool cannot print the transform parameters and ask advice on how to implement it.

Once you have the transform parameters on the output then you can add a simple scripted module that observes the output of BRAIN, ANTs, or Elastix output and updates a transform node accordingly.

1 Like

thank you lassoan !
thank you for made such work for the question .
i think i can find the way to print the rigid transform parameters on the output
I need some time to complete this function with your help, and then I will share this script for everyone to use.

1 Like