# IsPointInROI and GetPlanes not available

**URL:** <https://discourse.slicer.org/t/ispointinroi-and-getplanes-not-available/25054>\
**Category:** Development\
**Created:** [September 2, 2022, 2:08pm UTC](https://discourse.slicer.org/t/ispointinroi-and-getplanes-not-available/25054 "2022-09-02T14:08:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niels](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@Niels](https://discourse.slicer.org/u/Niels)\
**Post date:** [September 2, 2022, 2:08pm UTC](https://discourse.slicer.org/t/ispointinroi-and-getplanes-not-available/25054/1 "2022-09-02T14:08:39Z")

</div>

Hello Slicer users,

In my Python script I try to check if a voxel is inside a ROI. I searched the forum and found two options which are: IsPointInROI() and GetPlanes() on the vtkMRMLMarkupsROINode.

But on both I get an error that the attributes are not available. I use Slicer 4.11, maybe those methods are only available in newer versions of Slicer?

I use the new ROI node because that one has the possibility to rorate/place in the 3D window.

---

<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:** [September 3, 2022, 12:43pm UTC](https://discourse.slicer.org/t/ispointinroi-and-getplanes-not-available/25054/2 "2022-09-03T12:43:15Z")

</div>

Probably these methods are added in more recent Slicer versions.

---

<div class="post-metadata">

**Author:** ![Niels](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@Niels](https://discourse.slicer.org/u/Niels)\
**Post date:** [September 5, 2022, 11:39am UTC](https://discourse.slicer.org/t/ispointinroi-and-getplanes-not-available/25054/3 "2022-09-05T11:39:18Z")

</div>

I installed Slicer version 5.0.3 r30893 and tested with IsPointInROI. it works for the newer version

---

<div class="post-metadata">

**Author:** ![Niels](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@Niels](https://discourse.slicer.org/u/Niels)\
**Post date:** [September 6, 2022, 2:01pm UTC](https://discourse.slicer.org/t/ispointinroi-and-getplanes-not-available/25054/4 "2022-09-06T14:01:23Z")

</div>

The functions are available, but I need some help with the usage.  
I have a volume and I want to check which voxels are inside the ROI area.  
I assume that the IsPointInROI accepts world space coordinates and not voxel space coords. I tried the transformation but I am not successful.

Do we have an example where we check voxels again a rotated ROI?

---

<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:** [September 6, 2022, 3:28pm UTC](https://discourse.slicer.org/t/ispointinroi-and-getplanes-not-available/25054/5 "2022-09-06T15:28:38Z")

</div>

With a few rare exceptions (when you access voxels by indices) all 3D coordinates in Slicer are in physical coordinate system. You can transform between them by multiplying the coordinates by the volumes IJK to RAS transformation matrix.

What would you like to achieve? Blank out voxels or compute statistics in a ROI?

---

<div class="post-metadata">

**Author:** ![Niels](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@Niels](https://discourse.slicer.org/u/Niels)\
**Post date:** [September 6, 2022, 7:25pm UTC](https://discourse.slicer.org/t/ispointinroi-and-getplanes-not-available/25054/6 "2022-09-06T19:25:36Z")

</div>

My module is a tool to adjust a color volume (three scalars/rgb). I indeed would like to adjust the values within the region of interest. I iterate the voxels x,y,z and need to check if they are inside the roi.

If i understand you correctly, i can get the RAS value of each voxel like you described and use that on the rotated ROI using the IsInside function?

---

<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:** [September 6, 2022, 8:41pm UTC](https://discourse.slicer.org/t/ispointinroi-and-getplanes-not-available/25054/7 "2022-09-06T20:41:57Z")

</div>

Setting voxel values one by one would be extremely slow.

Instead, you can apply processing in a designated region very efficiently using numpy array indexing: Create a segment in Segment Editor to designate your region of interest (it can be a box shape but it can be a complex, free-form shape, too) and [export that into a numpy array](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#read-and-write-a-segment-as-a-numpy-array). You can then [use this array as a mask for numpy operations](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#modify-voxels-in-a-volume).
