Programmatically load transform apply to image and then save

I am trying to automate parts of my workflow in Slicer, ( my mental model wants something like VMTK or the CLI where I can break the operations into smaller steps and add and rearrange as needed)

I have figured out how to read in a .h5 transform and and image volume with python commands but it is not clear how to apply the transform to the image volume and save or “harden” transformed image to be subsequently processed with Brainsfit.

i have been reading through
[] (Transforms docs)

but it is more confusing than helpful

This worked for me:

[success, dsa] = slicer.util.loadVolume(r’./image_vols/DSA.nrrd’, returnNode=True)
#relative paths seem to not work with transforms, filed on a bug on that.
[success, dss2post_trans] = slicer.util.loadTransform(r’/home/sansomk/caseFiles/mri/VWI_proj/case4/registration/dsa2post_man_LT.h5’, returnNode=True)
slicer.util.saveNode(dsa, “./registration/dsa2post_man_trans.nrrd”)

I haven’t tried this outside of the python interactor, but ideally I would be able to execute this without the slicer gui, I assume this is possible but I am don’t know how.

This post should help: Slicer batch processing question (--no-main-window --python-script)

If you still have questions then let us know.