Script transform application

Operating system: Linux Mint
Slicer version: 5.0.3

I have a transforms file (from ANTs registration) .mat and I would like to script the application of this transform via slicer on another image. When I was using CLI modules I could get the bash code and adapt it but with the transforms module, I can’t script the application of the transform on the image I want. How to do it please?
Thanks already,


There are CLI modules for applying transforms on an image. For example, you can use “Resample Scalar/Vector/DWI volume” - it is the .../Slicer 5.0.3/bin/../lib/Slicer-5.0/cli-modules/ResampleScalarVectorDWIVolume.exe.

You can use loadable modules via the module logic class. For example, you can use the Crop volume module for applying a transform to a volume, along with cropping and resampling as shown in this code snippet in the script repository.

Thanks !
Sort of works :slight_smile:
I don’t really understand how for example the ResampleScalarVectorDWIVolume.exe module interprets
the ROI to create a transform that crops but it works !

Hi Andras,
How to get the invert transform and then apply it onto a volume using python scripting.


You can invert a transform node by calling the Inverse() method. You can apply a transform as shown here.