# vtkOrientedImageData giving offset when sampling segmented tumor volume

**URL:** <https://discourse.slicer.org/t/vtkorientedimagedata-giving-offset-when-sampling-segmented-tumor-volume/6760>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [May 11, 2019, 3:48pm UTC](https://discourse.slicer.org/t/vtkorientedimagedata-giving-offset-when-sampling-segmented-tumor-volume/6760 "2019-05-11T15:48:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshicola](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joshicola/32/3676_2.png) [@joshicola](https://discourse.slicer.org/u/joshicola)\
**Post date:** [May 11, 2019, 3:48pm UTC](https://discourse.slicer.org/t/vtkorientedimagedata-giving-offset-when-sampling-segmented-tumor-volume/6760/1 "2019-05-11T15:48:06Z")

</div>

I have several segmented tumors with catheters inserted to sample the biological environment. I know the shape and location of each catheter membrane. I want to sample this to determine what percentage of the membrane is in the tumor versus out of the tumor.

Using Slicer 4.10.1

```python
N = slicer.util.getNodes('Segmentation').GetSegmentation()
B=Seg.GetSegmentRepresentation('Segment_1','Binary labelmap')

```

Gives me a `vtkSegmentationCorePython.vtkOrientedImageData` object.

Using,

```python
cell_ID=B.FindCell(point,...)
cell=B.GetCell(cell_ID) 
for i in range(8):
       pointValue+= weights[i]*pointData.GetValue(cell.GetPointId(i))

```

I can check for a given “point” on my membrane being within or without the segmented tumor.

However, the above predicts points that are offset from world coordinates by a consistent direction (scale invariant)…that varies between original volumes.

Exporting the above segmentation to a new labelmap (“Segmentation-label”) and sampling:

```python
SegLabel=slicer.util.getNode('Segmentation-label')
B=SegLabel.GetImageData()

```

I am able to sample points and tell if they are within or without the segmented tumor.

Is there something I could do better to get the point-by-point segmentation label?

---

<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:** [May 11, 2019, 6:17pm UTC](https://discourse.slicer.org/t/vtkorientedimagedata-giving-offset-when-sampling-segmented-tumor-volume/6760/2 "2019-05-11T18:17:10Z")

</div>

This [example in the script repository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_centroid_of_a_segment_in_world_.28RAS.29_coordinates) contains everything you need.

You can also [export segments to a labelmap volume node](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Export_labelmap_node_from_segmentation_node) and convert between IJK and RAS coordinatesas shown in these examples: [RAS-\>IJK](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_volume_voxel_coordinates_from_markup_fiducial_RAS_coordinates) and [IJK-\>RAS](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_markup_fiducial_RAS_coordinates_from_volume_voxel_coordinates).

Oriented images have been recently introduced in VTK, which will allow us to simplify image coordinate system transformations in Slicer, but it will take us at least a couple of months to make all the necessary updates.

---

<div class="post-metadata">

**Author:** ![joshicola](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joshicola/32/3676_2.png) [@joshicola](https://discourse.slicer.org/u/joshicola)\
**Post date:** [May 14, 2019, 3:47pm UTC](https://discourse.slicer.org/t/vtkorientedimagedata-giving-offset-when-sampling-segmented-tumor-volume/6760/3 "2019-05-14T15:47:23Z")

</div>

Thank You!

The insight is appreciated!
