# Loaded models are sometimes in different coordinate system, and sometimes not. What exactly is going on?

**URL:** https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792
**Category:** Support
**Created:** [February 3, 2022, 10:30pm UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792 "2022-02-03T22:30:57Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![MJJ](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MJJ](https://discourse.slicer.org/u/MJJ)
#### Post date: [February 3, 2022, 10:30pm UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792/1 "2022-02-03T22:30:57Z")

</div>

Operating system: Windows  
Slicer version: 4.11.20210226  
Expected behavior: A model should be loaded into a consistent coordinate system  
Actual behavior: When I load some models, it appears to interpret the vertices as being in the RAS coordinate system. And for other models, it appears to use the world coordinates.

For example,

I have .vtu file. I load it up into 3d slicer. The x and y coordinates of all the vertices are flipped. I assume this is because the application is interpretting the vertex values to be in the RAS coordinates. No problem, I just apply a transformation [[-1,0,0,0, 0,-1,0,0, 0,0,1,0, 0,0,0,1]] and all is fine!

However, i have a .ply model too. When I load this model the application uses the actual coordinates of the vertices and it does not appear to be loaded in the RAS coordinate system, so I dont have to apply the transformation above to this model.

Why is there an inconsistency here?

How can I control which coordinate system a model’s vertices are interpreted to be in?

Thanks!

---

<div class="post-metadata">

### Author: ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)
#### Post date: [February 3, 2022, 10:38pm UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792/2 "2022-02-03T22:38:10Z")

</div>

If you know the model’s coordinate system, when loading expand the dialog box and specify whether it is LPS or RAS and your model should be imported correctly.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/d/5d9c81c0b4fdf15a5e8661a0aecd17e22679714b.png)

Inconsistency comes from the lack of standardization in those formats.

---

<div class="post-metadata">

### Author: ![MJJ](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MJJ](https://discourse.slicer.org/u/MJJ)
#### Post date: [February 3, 2022, 10:44pm UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792/3 "2022-02-03T22:44:46Z")

</div>

Thank you for the reply. I noticed this dialogue box, and I tested it by importing the same model twice but with the different options (LPS and RAS) chosen. There was no difference (and my model is definitely not symmetric about the x and y axes!)

---

<div class="post-metadata">

### Author: ![MJJ](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MJJ](https://discourse.slicer.org/u/MJJ)
#### Post date: [February 3, 2022, 10:47pm UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792/4 "2022-02-03T22:47:41Z")

</div>

For VTU files, it actually works. I see a difference depending on the LPS / RAS option chosen in that dialogue box.

For my .ply file it does not work. There is no difference between RAS and LPS option

---

<div class="post-metadata">

### Author: ![MJJ](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MJJ](https://discourse.slicer.org/u/MJJ)
#### Post date: [February 3, 2022, 10:48pm UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792/5 "2022-02-03T22:48:56Z")

</div>

Ok, update:

It must be something weird with this specific .ply file. I just tried another .ply file and it worked…

---

<div class="post-metadata">

### Author: ![MJJ](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MJJ](https://discourse.slicer.org/u/MJJ)
#### Post date: [February 3, 2022, 10:52pm UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792/6 "2022-02-03T22:52:57Z")

</div>

Confirmed. The file must have been corrupted somehow. I loaded it up in paraview, and exported it to a new .ply file, and then tried it in slicer, and it works!

My last question on this topic, is how do I do this programtically in python when i load a model?

i’m using slicer.util.loadModel(…) function

---

<div class="post-metadata">

### Author: ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)
#### Post date: [February 4, 2022, 12:35am UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792/7 "2022-02-04T00:35:11Z")

</div>

You will need to use the `slicer.util.loadNodeFromFile()` function and specify this somehow in the `properties`.

[slicer package — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/slicer.html#slicer.util.loadNodeFromFile)

`slicer.util.loadModel()` is a simplified wrapper for `loadNodeFromFile()` but lacks the ability to pass in properties. I couldn’t quickly find an example, but perhaps you can follow the code a bit deeper to find out what the property you want is and how to specify it: [https://github.com/Slicer/Slicer/blob/10fc1df859fa094691e2358d6c0b420bce477700/Base/Python/slicer/util.py#L619](https://github.com/Slicer/Slicer/blob/10fc1df859fa094691e2358d6c0b420bce477700/Base/Python/slicer/util.py#L619)

---

<div class="post-metadata">

### Author: ![MJJ](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MJJ](https://discourse.slicer.org/u/MJJ)
#### Post date: [February 4, 2022, 12:51am UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792/8 "2022-02-04T00:51:26Z")

</div>

I cannot seem to locate it by following the python code.  
I’m wondering if it is even possible.

I noticed this noted in one of the files:

```auto

  /// Coordinate system options
  /// LPS coordinate system is used the most commonly in medical image computing.
  /// Slicer is moving towards using this coordinate system in all files by default
  /// (while keep using RAS coordinate system internally).
  /// RAS coordinate system is used in Slicer internally. For many years, Slicer used
  /// this coordinate system in files that it created, too.
  enum
  {
    CoordinateSystemRAS = 0,
    RAS = 0, ///< for backward compatibility
    CoordinateSystemLPS = 1,
    LPS = 1, ///< for backward compatibility
    CoordinateSystemType_Last
  };

```

from:

> <https://github.com/Slicer/Slicer/blob/936675ac035c38999f4ed8d3c9d03fb4e2c9cbdc/Libs/MRML/Core/vtkMRMLStorageNode.h>

---

<div class="post-metadata">

### Author: ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)
#### Post date: [February 4, 2022, 1:14am UTC](https://discourse.slicer.org/t/loaded-models-are-sometimes-in-different-coordinate-system-and-sometimes-not-what-exactly-is-going-on/21792/9 "2022-02-04T01:14:40Z")

</div>

Found it! Check out here: [https://github.com/Slicer/Slicer/blob/49320e0294eee6b0a471d97664f32aaaf31e5a17/Modules/Loadable/Models/qSlicerModelsReader.cxx#L118](https://github.com/Slicer/Slicer/blob/49320e0294eee6b0a471d97664f32aaaf31e5a17/Modules/Loadable/Models/qSlicerModelsReader.cxx#L118)

The property is called “coordinateSystem” and the correct value is the integer 0 (for RAS) or 1 (for LPS). For these you could also use a more descriptively named enum.

An example of using properties for a different kind of node can be found here: [Script repository — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#load-volume-from-file)

So, properties are given as python dictionaries, where the key is the property name and the value is the property value.
