# Python code for getting current displayed slice on a red window

**URL:** <https://discourse.slicer.org/t/python-code-for-getting-current-displayed-slice-on-a-red-window/35891>\
**Category:** Development\
**Tags:** python\
**Created:** [May 3, 2024, 2:08pm UTC](https://discourse.slicer.org/t/python-code-for-getting-current-displayed-slice-on-a-red-window/35891 "2024-05-03T14:08:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mlh/32/70285_2.png) [@mlh](https://discourse.slicer.org/u/mlh)\
**Post date:** [May 3, 2024, 2:08pm UTC](https://discourse.slicer.org/t/python-code-for-getting-current-displayed-slice-on-a-red-window/35891/1 "2024-05-03T14:08:09Z")

</div>

Hi all!  
Would you please share to me python snippet on how to get a slice index which is shown on a red window?  
Please point me to similar post if already answered. I couldn’t find it though.

Thanks a lot!

---

<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:** [May 3, 2024, 2:59pm UTC](https://discourse.slicer.org/t/python-code-for-getting-current-displayed-slice-on-a-red-window/35891/2 "2024-05-03T14:59:01Z")

</div>

Do you mean the slice offset (in mm, displayed in the top right corner of the view)?  
If so, you can do:

```auto
redSliceNode = slicer.util.getNode('vtkMRMLSliceNodeRed')
redSliceNode.GetSliceOffset()

```

---

<div class="post-metadata">

**Author:** ![mlh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mlh/32/70285_2.png) [@mlh](https://discourse.slicer.org/u/mlh)\
**Post date:** [May 16, 2024, 12:03pm UTC](https://discourse.slicer.org/t/python-code-for-getting-current-displayed-slice-on-a-red-window/35891/3 "2024-05-16T12:03:35Z")

</div>

Alright, thanks. And how to convert it to image coordinate (IJK)? @rfenioux
