Disapearing segment information after using importlabelmaptosegmentation


I am really loving 4.11 as I can now use scipy and pdflatex with ease. However ever since I started using 4.11 I have been having problems with my GUI for performing localised thresholing using simpleitk…

The first segment loses all it’s segment information as soon as another is created. The segment still exists in the list of segments and the segmentation node (when printed in the interactor) but it cannot be visualised - as if it were a newly created ‘blank’ segment.

I have tracked the issue down to this command:

slicer.vtkSlicerSegmentationsModuleLogic.ImportLabelmapToSegmentationNode(labelmap, segmentationNode, segmentVtkString)

Whenever this is run for a different segment, the first segment in the segmentation node is ‘cleared’ as described above. When creating multiple segments none of the subsequent segments are affected in the same way and it is possible to work around this problem by redefining the first segment after having completed all the others.

I am currently using the nightly from the 21st.

@sunderlandkyl could you please check if you can reproduce this issue?

Sure, I’ll take a look.

1 Like

@dominicrushforth I’ve tried importing lablemaps one after the other into the same segmentation, but I haven’t been able to reproduce this issue so far.

Could you provide mode information on when this occurs?
How many segments are in the labelmaps that you import?

I’m not entirely sure what is relevant,

I get a vtkMRMLSegmentEditorNode…

  self.segmentEditorNode = slicer.util.getNode('Dose Segment Editor')
  self.segmentEditorNode = slicer.vtkMRMLSegmentEditorNode()
self.segmentEditorNode.SetName('Dose Segment Editor')
# create a vtkMRMLSegmentationNode…
  self.segmentationNode = slicer.util.getNode('Dose Segmentation')
  self.segmentationNode = slicer.vtkMRMLSegmentationNode()
self.segmentationNode.SetName('Dose Segmentation')

I run the simple itk ConnectedThresholdImageFilter then use this function to put the resulting labelmap into a segment

# names of relevant nodes are looked up
currentSegmentText = self.segmentationSelector.currentText
# looks for segment
segmentID = self.segmentationNode.GetSegmentation().GetSegmentIdBySegmentName(currentSegmentText)
segment = self.segmentationNode.GetSegmentation().GetSegment(segmentID)
# if the mask segment has not already been created, this is done (it should have been but just in case!)
if segment is None:
  segmentID = self.segmentationNode.GetSegmentation().AddEmptySegment(currentSegmentText)
# convert resulting label map into a segment
segmentVtkString = vtk.vtkStringArray()
slicer.vtkSlicerSegmentationsModuleLogic.ImportLabelmapToSegmentationNode(labelmap, self.segmentationNode, segmentVtkString)

The problem occurs when creating the second segment. The original segment can still be seen if the function is ended before the last
line is run. Running the last line in the interactor then makes the first segment vanish (even if all the eyes are open). Creating a third segment has no effect on the second segment and so on… However if the first segment is removed the segment that is
now at the top of the list is affected in the same way if any new segments are created using this method. The problem doesn’t occur with other of creating or defining segments.

I am using
r28644 on windows. I can install the latest nightly if that might help?


Thanks for your help, I think I’ve found the cause of the issue.
I’ll let you know when it’s fixed.

Found the problem and made a fix (can be found here: https://github.com/Slicer/Slicer/pull/1268).

The fix should be found in the latest 4.11 nightly.

1 Like

I’ve installed the latest nightly and it’s working great. Thanks so much :slight_smile:

1 Like