# How to convert a .vtk mesh from LPS to RAS coordinates for proper alignment with NIfTI volumes in NiiVue?

**URL:** https://discourse.vtk.org/t/how-to-convert-a-vtk-mesh-from-lps-to-ras-coordinates-for-proper-alignment-with-nifti-volumes-in-niivue/15859
**Category:** Development
**Tags:** python, code
**Created:** [July 24, 2025, 12:48pm UTC](https://discourse.vtk.org/t/how-to-convert-a-vtk-mesh-from-lps-to-ras-coordinates-for-proper-alignment-with-nifti-volumes-in-niivue/15859 "2025-07-24T12:48:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Natalia\_Fabiano](https://discourse.vtk.org/user_avatar/discourse.vtk.org/natalia_fabiano/32/10154_2.png) [@Natalia\_Fabiano](https://discourse.vtk.org/u/Natalia_Fabiano)
#### Post date: [July 24, 2025, 12:48pm UTC](https://discourse.vtk.org/t/how-to-convert-a-vtk-mesh-from-lps-to-ras-coordinates-for-proper-alignment-with-nifti-volumes-in-niivue/15859/1 "2025-07-24T12:48:19Z")

</div>

![Capture d’écran 2025-07-24 à 10.45.47](https://discourse.vtk.org/uploads/default/original/2X/5/5e16589be5eb2bf3281b337e3ef5f64542c10b1f.png)  
**Question:**  
I’m working with a `.vtk` surface mesh that was saved in **LPS (Left-Posterior-Superior)** coordinate space, and I want to overlay it correctly on a `.nii.gz` volume image in **NiiVue** , which uses **RAS (Right-Anterior-Superior)** coordinates.

Currently, when I try to display both in NiiVue, the mesh appears completely misaligned—likely due to the coordinate system mismatch.

**My questions are:**

1. Is there a recommended way (in VTK or otherwise) to convert the `.vtk` mesh from **LPS to RAS**?
2. Should this be handled manually with a transformation matrix, or is there a VTK-native method for this conversion?
3. Alternatively, would it be more appropriate to preprocess the mesh in another tool like **3D Slicer** , and if so, how?

Any guidance or best practices for handling this kind of coordinate transformation in VTK would be greatly appreciated!

Thanks!

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [July 24, 2025, 1:11pm UTC](https://discourse.vtk.org/t/how-to-convert-a-vtk-mesh-from-lps-to-ras-coordinates-for-proper-alignment-with-nifti-volumes-in-niivue/15859/2 "2025-07-24T13:11:11Z")

</div>

It should be possible with vtkTransform and vtkTransformPolyDataFilter.

```plaintext
transform = vtkTransform()
transform.Scale(-1.0, -1.0, 1.0)

filter = vtkTransformPolyDataFilter()
filter.SetTransform(transform)
filter.SetInputData(...)

```

The LPS → RAS transform just reverses the L-R and A-P directions.
