# Get segment status in code

**URL:** <https://discourse.slicer.org/t/get-segment-status-in-code/24613>\
**Category:** Development\
**Tags:** segmentation\
**Created:** [August 3, 2022, 6:31am UTC](https://discourse.slicer.org/t/get-segment-status-in-code/24613 "2022-08-03T06:31:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karthik](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@Karthik](https://discourse.slicer.org/u/Karthik)\
**Post date:** [August 3, 2022, 6:31am UTC](https://discourse.slicer.org/t/get-segment-status-in-code/24613/1 "2022-08-03T06:31:10Z")

</div>

I have multiple segments in Segment Editor. I set the segment status flag to ‘Flagged’ if I think there is some problem with the output displayed on screen. I would then like to apply the effect based on if the segment status has been flagged or not.  
How can I know the status of a segment through python code. “vtkSegment” class doesn’t seem to have any GetStatus method

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [August 3, 2022, 2:46pm UTC](https://discourse.slicer.org/t/get-segment-status-in-code/24613/2 "2022-08-03T14:46:29Z")

</div>

The code to get the segment status is in vtkSlicerSegmentationsModuleLogic:

```python
segment = getNode("Segmentation").GetSegmentation().GetNthSegment(0)
logic = slicer.modules.segmentations.logic()
logic.GetSegmentStatus(segment)

# Status enum:
# slicer.vtkSlicerSegmentationsModuleLogic.NotStarted
# slicer.vtkSlicerSegmentationsModuleLogic.InProgress
# slicer.vtkSlicerSegmentationsModuleLogic.Completed
# slicer.vtkSlicerSegmentationsModuleLogic.Flagged

```

---

<div class="post-metadata">

**Author:** ![Karthik](https://avatars.discourse-cdn.com/v4/letter/k/9fc348/32.png) [@Karthik](https://discourse.slicer.org/u/Karthik)\
**Post date:** [August 4, 2022, 3:16am UTC](https://discourse.slicer.org/t/get-segment-status-in-code/24613/3 "2022-08-04T03:16:15Z")

</div>

Hi Kyle Sunderland,  
Thanks for the help.  
Slicer has by default segment status of four types.  
0 - Not Started  
1 - In Progress  
2 - Completed  
3 - Flagged  
I was wondering if its possible for me to add my own segment status flags through code changes which could then be selected through the UI. If changes to the segment status were to be made, would they be done at python effect level (or) C++ level?

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [August 4, 2022, 2:54pm UTC](https://discourse.slicer.org/t/get-segment-status-in-code/24613/4 "2022-08-04T14:54:52Z")

</div>

The changes would have to be made in C++.

What additional status flags were you planning to add?

---

<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:** [August 4, 2022, 3:50pm UTC](https://discourse.slicer.org/t/get-segment-status-in-code/24613/5 "2022-08-04T15:50:39Z")

</div>

@karthik You can use the “flagged” state for any purpose. You can also store any custom metadata in each segment as tag:value pairs (by using `vtkSegment.SetTag()`, `vtkSegment.GetTag()`, etc.).
