# Create an online segmentation mask from navigation data

**URL:** <https://discourse.slicer.org/t/create-an-online-segmentation-mask-from-navigation-data/35518>\
**Category:** Development\
**Tags:** surgical-navigation, segmentation, python\
**Created:** [April 16, 2024, 8:51am UTC](https://discourse.slicer.org/t/create-an-online-segmentation-mask-from-navigation-data/35518 "2024-04-16T08:51:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davide\_Scorza](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/davide_scorza/32/70057_2.png) [@Davide\_Scorza](https://discourse.slicer.org/u/Davide_Scorza)\
**Post date:** [April 16, 2024, 8:51am UTC](https://discourse.slicer.org/t/create-an-online-segmentation-mask-from-navigation-data/35518/1 "2024-04-16T08:51:26Z")

</div>

Dear Slicer community,

I am developing a module which includes a navigation step of a surgical robot (it is related to an [older topic](https://discourse.slicer.org/t/update-3d-visualization-programmatically/30158) posted by a colleague some time ago) , and I would like to update the visualization of where we have already passed, with respect to a reference volume. We are currently mapping OPCUA position to slicer through an OpenIGTLink node as suggested in the linked topic, and we use the position to update a model.

Basically, what I am trying to achieve is the following behaviour, for visualization purposes:

- Activate the navigation of the system
- Navigate the system through a reference volume
- If the system is inside a predefined ROI, then colour the pixel to green value
- if the system pass the predefined ROI, then colour the pixel to a red value

The green and red values could be represented as a segmentation node displayed in the label layer (exactly as the Segmentation volumes).  
I believe the answer rely on the Segmentation Editor module, because the type of interaction that I am thinking it is similar to the paint brush, but I would like to activate it programmatically within a python module.  
I am assuming that I can do the processing without blocking the application.

I would appreciate any help or indication that you could provide.  
Thanks in advance.  
Davide
