# Can I read and modify a transform matrix with python

**URL:** <https://discourse.slicer.org/t/can-i-read-and-modify-a-transform-matrix-with-python/6964>\
**Category:** Development\
**Created:** [May 29, 2019, 11:13pm UTC](https://discourse.slicer.org/t/can-i-read-and-modify-a-transform-matrix-with-python/6964 "2019-05-29T23:13:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![timeanddoctor](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/timeanddoctor/32/5839_2.png) [@timeanddoctor](https://discourse.slicer.org/u/timeanddoctor)\
**Post date:** [May 29, 2019, 11:13pm UTC](https://discourse.slicer.org/t/can-i-read-and-modify-a-transform-matrix-with-python/6964/1 "2019-05-29T23:13:17Z")

</div>

can I read and modify a transform matrix with python directly(not the GUI of transform) in slicer.  
for example:  
Read  
display (transformMatrix)  
I will get a 4\*4matrix:  
[[ 1 0 0 52.64097]  
[0 1 0 -46.12696]  
[0 0 1 -0.48185]  
[0. 0. 0. 1.]]

Modify  
transformMatrix=np.array[  
[0.92979 -0.26946 -0.25075 52.64097]  
[0.03835 0.74845 -0.66209 -46.12696]  
[0.36608 0.60599 0.70623 -0.48185]  
[0. 0. 0. 1.]]

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 30, 2019, 3:45am UTC](https://discourse.slicer.org/t/can-i-read-and-modify-a-transform-matrix-with-python/6964/2 "2019-05-30T03:45:05Z")

</div>

See example of setting a transform from a numpy array here: [https://www.slicer.org/wiki/Documentation/Nightly/Modules/Transforms#Examples](https://www.slicer.org/wiki/Documentation/Nightly/Modules/Transforms#Examples)
