# How to determine RAS coordinates by voxel position

**URL:** <https://discourse.slicer.org/t/how-to-determine-ras-coordinates-by-voxel-position/31112>\
**Category:** Development\
**Tags:** python\
**Created:** [August 12, 2023, 1:06am UTC](https://discourse.slicer.org/t/how-to-determine-ras-coordinates-by-voxel-position/31112 "2023-08-12T01:06:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slicer365](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/slicer365/32/67549_2.png) [@slicer365](https://discourse.slicer.org/u/slicer365)\
**Post date:** [August 12, 2023, 1:06am UTC](https://discourse.slicer.org/t/how-to-determine-ras-coordinates-by-voxel-position/31112/1 "2023-08-12T01:06:37Z")

</div>

Throughout the scene, the center point of each voxel has a corresponding RAS coordinate, and I can place a marker point anywhere to see the RAS coordinates of that location.  
Now I have a requirement, and I want to loop to find out the location of the maximum CT value in the current 2D view and display its RAS coordinates.  
For example, in the following picture, I found this voxel position, and I need to calculate its approximate RAS coordinates, and the error is permissible, because this voxel is not a point, but a very small rectangular region.  
Relative to the whole matrix, its position is (346,235,136), and I need to get its approximate RAS coordinates, which can be the coordinates of any point in the whole voxel, or its central coordinates.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/6/76e25602c5d2b77a99d915798c2345fc76e04ca8.png)

---

<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:** [August 12, 2023, 3:44pm UTC](https://discourse.slicer.org/t/how-to-determine-ras-coordinates-by-voxel-position/31112/2 "2023-08-12T15:44:31Z")

</div>

You can look at the code of the DataProbe module, and also this example should help:

[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#get-reformatted-image-from-a-slice-viewer-as-numpy-array](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-reformatted-image-from-a-slice-viewer-as-numpy-array)
