# How to export position parameters like slice center and the normal vector for the slice plane?

**URL:** <https://discourse.slicer.org/t/how-to-export-position-parameters-like-slice-center-and-the-normal-vector-for-the-slice-plane/35266>\
**Category:** Development\
**Tags:** python\
**Created:** [April 3, 2024, 10:26pm UTC](https://discourse.slicer.org/t/how-to-export-position-parameters-like-slice-center-and-the-normal-vector-for-the-slice-plane/35266 "2024-04-03T22:26:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arjun](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/arjun/32/69892_2.png) [@Arjun](https://discourse.slicer.org/u/Arjun)\
**Post date:** [April 3, 2024, 10:26pm UTC](https://discourse.slicer.org/t/how-to-export-position-parameters-like-slice-center-and-the-normal-vector-for-the-slice-plane/35266/1 "2024-04-03T22:26:25Z")

</div>

Hi!

I wanted to know how can we export position parameters like slice center and the normal vector for the slice plane we are viewing such that I can visualize that slice of the 3D data in lets say python? Thanks for the help

---

<div class="post-metadata">

**Author:** ![rfenioux](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rfenioux/32/70007_2.png) [@rfenioux](https://discourse.slicer.org/u/rfenioux)\
**Post date:** [April 4, 2024, 7:52am UTC](https://discourse.slicer.org/t/how-to-export-position-parameters-like-slice-center-and-the-normal-vector-for-the-slice-plane/35266/2 "2024-04-04T07:52:50Z")

</div>

You can get the slice transformation matrix using the slice Id (here for the default red slice). This returns the 4x4 transform matrix, from which you can retrieve the slice origin and the normal vector.

```auto
sliceNode = slicer.util.getNode('vtkMRMLSliceNodeRed')
sliceToRas = sliceNode..GetSliceToRAS()
origin = np.array([sliceToRas.GetElement(i, 3) for i in range(3)])
normal = np.array([sliceToRas.GetElement(0, 2), sliceToRas.GetElement(1, 2), sliceToRas.GetElement(2, 2)])

```

---

<div class="post-metadata">

**Author:** ![Arjun](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/arjun/32/69892_2.png) [@Arjun](https://discourse.slicer.org/u/Arjun)\
**Post date:** [April 17, 2024, 12:23am UTC](https://discourse.slicer.org/t/how-to-export-position-parameters-like-slice-center-and-the-normal-vector-for-the-slice-plane/35266/3 "2024-04-17T00:23:46Z")

</div>

Hi! Thank you so much! I tried this but it does seem to be updating the slice we are seeing on the Red, Green and Yellow panels. The 4x4 transform matrix remains the same, is there something else I need to do for getting the transform matrix for the slice I see on the screen after interacting with it?

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [April 17, 2024, 1:29am UTC](https://discourse.slicer.org/t/how-to-export-position-parameters-like-slice-center-and-the-normal-vector-for-the-slice-plane/35266/4 "2024-04-17T01:29:19Z")

</div>

`sliceNode.GetSliceToRAS()` will give you the updated 4x4 matrix after interaction. The `sliceToRas` matrix in the code above is just a stored copy of that information at the point when that code is run, and will not be dynamically updated as the slice location is changed.
