Hi, guys.
today I am trying to access the visibility of objects created in 3d models by code.
What I’m trying to do is what’s in the image just show Left-Cerebral-Cortex and remove the visibility of all the others.
thanks
Try something like this:
displayNode.SetAllSegmentsVisibility(False)
displayNode.SetSegmentVisibility(leftCerebralCortexSegmentID, True)
SetAllSegmentsVisibility (bool visible)
SetSegmentVisibility (std::string segmentID, bool visible)
If you still want all of the the 2D representations to be visible, you can use these functions:
SetAllSegmentsVisibility3D (bool visible, bool changeVisibleSegmentsOnly=false)
SetSegmentVisibility3D (std::string segmentID, bool visible)
hi
this works to hide all segmentation:
disp=slicer.util.getNode('Segmentation')
disp.SetDisplayVisibility(False)
but I can’t make it show only Left-Cerebral-Cortex .
try this:
slicer.vtkMRMLSegmentationDisplayNode('Segmentation').SetAllSegmentsVisibility(False)
but I have the following error:
ValueError: could not extract hexadecimal address from argument string
segmentationNode = slicer.util.getNode('Segmentation')
displayNode = segmentationNode.GetDisplayNode()
displayNode.SetAllSegmentsVisibility(False) # Hide all segments
displayNode.SetSegmentVisibility(leftCerebralCortexSegmentID, True) # Show specific segment
1 Like
How can I see the ID of
leftCerebralCortexSegmentID
the label name is Left-Cerebral-Cortex
You can use this:
segmentation = segmentationNode.GetSegmentation()
leftCerebralCortexSegmentID = segmentation.GetSegmentIdBySegmentName("Left-Cerebral-Cortex")
GetSegmentIdBySegmentName (std::string name)
1 Like
thank you so much it works perfect i leave the code here:
segmentationNode=getNode('Segmentation')
segmentation = segmentationNode.GetSegmentation()
leftCerebralCortexSegmentID = segmentation.GetSegmentIdBySegmentName("Left-Cerebral-Cortex")
displayNode = segmentationNode.GetDisplayNode()
displayNode.SetAllSegmentsVisibility(False) # Hide all segments
displayNode.SetSegmentVisibility(leftCerebralCortexSegmentID, True) # Show specific segment
2 Likes