# Create transform programmatically

**URL:** <https://discourse.slicer.org/t/create-transform-programmatically/33927>\
**Category:** Support\
**Tags:** transforms, python\
**Created:** [January 23, 2024, 1:18pm UTC](https://discourse.slicer.org/t/create-transform-programmatically/33927 "2024-01-23T13:18:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anuta](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anuta/32/68992_2.png) [@Anuta](https://discourse.slicer.org/u/Anuta)\
**Post date:** [January 23, 2024, 1:18pm UTC](https://discourse.slicer.org/t/create-transform-programmatically/33927/1 "2024-01-23T13:18:29Z")

</div>

Hello!  
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?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 23, 2024, 1:30pm UTC](https://discourse.slicer.org/t/create-transform-programmatically/33927/2 "2024-01-23T13:30:33Z")

</div>

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

[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#transforms](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#transforms)
