Create transform programmatically

I am trying to perform multiplanar reformation in slicer (reslice the volume in a different orientation). For this task I use “Transforms” module to alter orientation of the volume and “Resample Scalar Volume” module to reslice the volume.
The issue is, I would like to do this all programmatically (without opening the slicer and using sliders).
I would like to create a transformation matrix myself, create a linear transform with this matrix and apply it to the given volume.
The questions are:

  • How to create a new transformation matrix programmatically? Is it even possible (I’ve seen that all of the classes related to transforms are Widget-based)?
  • How to set parameters in “Resample Scalar Volume” module programmatically?

Yes, all that is possible. Read through the script repository, especially this section: