# Changing the origin value, and nothing else

**URL:** <https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577>\
**Category:** Development\
**Created:** [March 6, 2020, 3:06pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577 "2020-03-06T15:06:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![giovform](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/giovform/32/4687_2.png) [@giovform](https://discourse.slicer.org/u/giovform)\
**Post date:** [March 6, 2020, 3:06pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/1 "2020-03-06T15:06:10Z")

</div>

Hello, I wanted to set a new origin point (to the last slice loaded), without modifying anything else (the volume must remain at the same spot in the world coordinates). In simple terms I just want that:

```
node.GetOrigin() == (0, 0, 0)

```

for the configuration in the picture bellow, instead of currently:

```
node.GetOrigin() == (0, 0, -100)

```

Is it possible to do that?

 ![problem](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/a/6a4bb776b20a6839cea5007d5f0151a709240930.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:** [March 6, 2020, 3:24pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/2 "2020-03-06T15:24:17Z")

</div>

Do you mean you want to also flip the directions? Did you try just calling `SetOrigin`? You can also use `volumeNode.SetKToRASDirection` and related methods.

---

<div class="post-metadata">

**Author:** ![giovform](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/giovform/32/4687_2.png) [@giovform](https://discourse.slicer.org/u/giovform)\
**Post date:** [March 6, 2020, 3:26pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/3 "2020-03-06T15:26:54Z")

</div>

Yes, I played around with some functions, but no success. I just really want to change the Origin point, but not translating the volume in the world as a consequence.

---

<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:** [March 6, 2020, 3:38pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/4 "2020-03-06T15:38:55Z")

</div>

The way we [use the term](https://www.slicer.org/wiki/Coordinate_systems), changing the origin would move the actual data in physical space unless you shuffle the data and change the directions. Can you give more info on what you need to achieve?

---

<div class="post-metadata">

**Author:** ![giovform](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/giovform/32/4687_2.png) [@giovform](https://discourse.slicer.org/u/giovform)\
**Post date:** [March 6, 2020, 5:16pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/5 "2020-03-06T17:16:31Z")

</div>

I managed to get the result I wanted by doind these two steps:

1. Revert the order of the files loaded into Slicer (I am using ‘DICOMScalarVolumePlugin’). By doing this, my volume is loaded upside down, and the origin is anchored where I want in the volume, i.e. at the top:

2. Apply a transform to rotate 180 degrees around the Sagittal or Coronal axis.

This way I have the volume origin at (0, 0, 0), at the top of volume.

I wanted to know if there is a more elegant way to achieve this result.

---

<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:** [March 6, 2020, 5:30pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/6 "2020-03-06T17:30:57Z")

</div>

It’s not clear to me why you need the origin to be at a specific spot. For example [in dicom](http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.2.html#sect_C.7.6.2.1.1) only the relative values of origin matter, and then only if they are in the same frame of reference.

---

<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:** [March 6, 2020, 5:41pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/7 "2020-03-06T17:41:27Z")

</div>

@giovform has multiple volumes with an outside-of-Slicer-coordinate of the volumes defined by the top (patient head). When he loads the volume into slicer and sets the volume origin, this coordinate is defined at the bottom (patient feet), hence he needs to shift the outside-coordinate by the height of the patient. When the user wants to inspect the volume and retrieve the outside-of-Slicer-coordinate, the slicer volume origin coordinate is shifted.  
We would like to set the imagedata (ijk) origin to start at the last slice (patient head), and increases as slices moves to the feet (I world direction).

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 6, 2020, 5:51pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/8 "2020-03-06T17:51:10Z")

</div>

> [@fbordignon](#):
>
> We would like to set the imagedata (ijk) origin to start at the last slice (patient head), and increases as slices moves to the feet (I world direction).

You cannot expect to have a particular voxel (IJK) to physical (LPS) coordinate system mapping in an image file that you load. If your application only works with one particular slice order then you need to normalize the images after you load them in your own software.

If you really want to do this normalization in Slicer, then you can still do it (as in general, Slicer does not reorder slices when it loads or saves an image volume), it is really not the right place to do it.

---

<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:** [March 6, 2020, 6:26pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/9 "2020-03-06T18:26:53Z")

</div>

Great Andras, I agree with you. But if you allow me, I am still curious about this issue.

Why does ImageData.setOrigin(0,0,-100) does not work for this case?  
Is it because slicer assumes ijk always starts at zero and goes up to the dimensions of the imagedata?  
Vtk seems to deal with this just fine, as the volume is rendered at the right position when I set the ImageData origin.  
Thank you for the insights and ideas.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 6, 2020, 7:12pm UTC](https://discourse.slicer.org/t/changing-the-origin-value-and-nothing-else/10577/10 "2020-03-06T19:12:07Z")

</div>

> [@fbordignon](#):
>
> Why does ImageData.setOrigin(0,0,-100) does not work for this case?

`SetOrigin()` method of vtkImageData must not be used. Origin, spacing, and axis directions of volumes are stored in the volume node, not in the vtkImageData (origin in vtkImageData must be kept (0,0,0)). The reason is that until recently, vtkImageData could not store image orientation and therefore the complete image geometry had to be stored outside the image data object. You can modify the origin by calling `SetOrigin()` method of the volume node.

Once we upgrade to VTK9, we can switch to using vtkImageData for storing image geometry, but probably this will take about a year.
