# Progamatically get slice view bounding box in RAS

**URL:** <https://discourse.slicer.org/t/progamatically-get-slice-view-bounding-box-in-ras/9989>\
**Category:** Support\
**Created:** [January 28, 2020, 7:34pm UTC](https://discourse.slicer.org/t/progamatically-get-slice-view-bounding-box-in-ras/9989 "2020-01-28T19:34:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felipe\_Silveira](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/felipe_silveira/32/5677_2.png) [@Felipe\_Silveira](https://discourse.slicer.org/u/Felipe_Silveira)\
**Post date:** [January 28, 2020, 7:34pm UTC](https://discourse.slicer.org/t/progamatically-get-slice-view-bounding-box-in-ras/9989/1 "2020-01-28T19:34:27Z")

</div>

Hi, I’d like to write a python script that gets the bounding box of a slice view.  
For example, with the attached images, I’d like to have 2 points: (-2.1, 133.1, -199.7) and (-2.1, -120.3, 178.3).

 ![bottom_left](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/2/2279cfa1ff2c86ef36cd7f464bd7af597907b1ad.jpeg) ![top_right](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/a/7a8d8668938ff38c27db4348983f1ef1cb94207e.jpeg)

Using vtkMRMLSliceNode::GetXYZOrigin and applying the XYToRAS matrix gives me the bottom left corner. But I don’t see how to get the top right corner.  
I played around with the field of view, but didn’t get the right results when switching between axial/coronal/sagittal presets.

How can I accomplish that?

---

<div class="post-metadata">

**Author:** ![fbordignon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fbordignon/32/5269_2.png) [@fbordignon](https://discourse.slicer.org/u/fbordignon)\
**Post date:** [January 28, 2020, 8:19pm UTC](https://discourse.slicer.org/t/progamatically-get-slice-view-bounding-box-in-ras/9989/2 "2020-01-28T20:19:09Z")

</div>

Get the RAS coordinates of the bottom left corner:

```
xytoras = sliceNode.GetXYToRAS()
xytoras.MultiplyPoint((0, 0 , 0, 1))

```

Get the coordinate of the top right corner:

```
dims = sliceNode.GetDimensions()
xytoras.MultiplyPoint((dims[0], dims[1] , 0, 1))
```
