# How to use linear transform to convert X,Y Coordinate to RAS coordinates

**URL:** <https://discourse.slicer.org/t/how-to-use-linear-transform-to-convert-x-y-coordinate-to-ras-coordinates/23735>\
**Category:** Support\
**Tags:** transforms, python, coordinates\
**Created:** [June 6, 2022, 1:58pm UTC](https://discourse.slicer.org/t/how-to-use-linear-transform-to-convert-x-y-coordinate-to-ras-coordinates/23735 "2022-06-06T13:58:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhtan16](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@minhtan16](https://discourse.slicer.org/u/minhtan16)\
**Post date:** [June 6, 2022, 1:58pm UTC](https://discourse.slicer.org/t/how-to-use-linear-transform-to-convert-x-y-coordinate-to-ras-coordinates/23735/1 "2022-06-06T13:58:10Z")

</div>

Hi everyone,

I have multiples 2D coordinates (X,Y). These coordinates are all mapped by a linear transform in which I have access. I’m wondering if there’s a way to convert a 2D coordinates using the linear transform matrix to RAS programatically using python.

For exemple, my 2D coordinate would look like this [220, 100] and my linear transform matrix :  
[-0.28146, 0.958297, 0.0494615, 142.429, 0.955756, 0.275374, 0.103442, 134.392, 0.0855075, 0.0763878, -0.993405, -37.0582, 0, 0, 0, 1]

I want to convert my coordinate to RAS so I can then programatically display **segmentations** in 3D.  
I’m new to slicer and is wondering if this is possible to do?

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [June 7, 2022, 10:43am UTC](https://discourse.slicer.org/t/how-to-use-linear-transform-to-convert-x-y-coordinate-to-ras-coordinates/23735/2 "2022-06-07T10:43:22Z")

</div>

You can get the xy to RAS transform for a given slice view from the slice node, using this function: [Slicer/vtkMRMLSliceNode.h at 177f3b324247de4e77d4497cc9121fe37dd5b3f3 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/blob/177f3b324247de4e77d4497cc9121fe37dd5b3f3/Libs/MRML/Core/vtkMRMLSliceNode.h#L319)

You can get the slice node like this:  
[https://slicer.readthedocs.io/en/latest/developer\_guide/script\_repository.html#change-slice-orientation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#change-slice-orientation)
