Get segment status in code

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

The code to get the segment status is in vtkSlicerSegmentationsModuleLogic:

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

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

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?

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

What additional status flags were you planning to add?

@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.).