# Invert transformation Python Command?

**URL:** <https://discourse.slicer.org/t/invert-transformation-python-command/28246>\
**Category:** Support\
**Tags:** transforms, python\
**Created:** [March 9, 2023, 2:33am UTC](https://discourse.slicer.org/t/invert-transformation-python-command/28246 "2023-03-09T02:33:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nalindgr](https://avatars.discourse-cdn.com/v4/letter/n/ecae2f/32.png) [@nalindgr](https://discourse.slicer.org/u/nalindgr)\
**Post date:** [March 9, 2023, 2:33am UTC](https://discourse.slicer.org/t/invert-transformation-python-command/28246/1 "2023-03-09T02:33:19Z")

</div>

Hi!

I have a loaded displacement field and a loaded volume that I want to transform by the inverse.  
In Slicer GUI, when applying the transform, one can easily check the “Invert” box.  
How do I specify that I want to do an invert transform in my Python script?

> inputDisplacementfield = mainFolder+‘displacementfield.mhd’  
> inputTemplateVolume = mainFolder+‘volume.nrrd’  
> loadedDisplacementfield = slicer.util.loadTransform(inputDisplacementfield)  
> loadedTemplateVolume = slicer.util.loadVolume(inputTemplateVolume)
> 
> displacementfield\_node = slicer.util.getNode(“displacementfield”)  
> /# Here I want to invert the transform  
> templateVolume\_node = slicer.util.getNode(“volume”)

Any advice?

Thanks in advance.

---

<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:** [March 9, 2023, 2:52pm UTC](https://discourse.slicer.org/t/invert-transformation-python-command/28246/2 "2023-03-09T14:52:18Z")

</div>

If you don’t get a specific answer here, there are general instructions: [https://slicer.readthedocs.io/en/latest/developer\_guide/python\_faq.html#how-to-find-a-python-function-for-any-slicer-features](https://slicer.readthedocs.io/en/latest/developer_guide/python_faq.html#how-to-find-a-python-function-for-any-slicer-features)
