Select segment IDs in a Segmentation with multiple segments

SANTIAGO_PENDON_MING
Mon, 08 Jan 2024 11:01:12 +0000
Support

Hi to everyone. Today I’m trying to solve a very concerning problem. The situation is the next one:

suffix = '_manualSegmentation'
segmentationName = f"{patientID}{suffix}"
segmentName = f"{patientID}_coronaryTree{suffix}"
namesCorrect = False

while(not namesCorrect):
    try:
        segmentationNode = slicer.util.getNode(segmentationName)
        segmentId = segmentationNode.GetSegmentation().GetSegmentIdBySegmentName(segmentName)

        if (not segmentId == ''):
            namesCorrect = True

    except:
        input("Check that segmentation name and segment name are: " +
              segmentationName + " and " + segmentName + ",respectively."
              + "And press key to continue...")
        namesCorrect = False

This code works properly to be sure that the user puts fine the segmentation and segment names. But only when I have one segment. If I have more than one, the code crashes and Slicer stops working… Am I doing something wrong ?

Thanks to everyone

2 posts - 2 participants

Read full topic