I have two segment “skin1” and “skin2”. And when I apply threshold with CLI, I donot know how to select the second one. I don’t know how to set parameters for skin2
# Thresholding
segmentEditorWidget.setActiveEffectByName("Threshold")
effect = segmentEditorWidget.activeEffect()
effect.setParameter("MinimumThreshold","54")
effect.setParameter("MaximumThreshold","78")
effect.self().onApply()
cpinter
(Csaba Pinter)
September 14, 2018, 4:20pm
2
This should do the trick
/// Set segmentation MRML node
void setSegmentationNode(vtkMRMLNode* node);
/// Set segmentation MRML node by its ID
void setSegmentationNodeID(const QString& nodeID);
/// Set master volume MRML node
void setMasterVolumeNode(vtkMRMLNode* node);
/// Set master volume MRML node by its ID
void setMasterVolumeNodeID(const QString& nodeID);
/// Set selected segment by its ID
void setCurrentSegmentID(const QString segmentID);
/// Set active effect by name
void setActiveEffectByName(QString effectName);
/// Save current segmentation before performing an edit operation
/// to allow reverting to the current state by using undo
void saveStateForUndo();
/// Update modifierLabelmap, maskLabelmap, or alignedMasterVolumeNode
void updateVolume(void* volumePtr, bool& success);
OK, Csaba Pinter, thank you very much.
Another problem, can I define the color of a segment
addedSegmentID = segmentationNode.GetSegmentation().AddEmptySegment("skin11",*red*)
cpinter
(Csaba Pinter)
September 14, 2018, 5:25pm
4
To change the primary color of the segment (that is also saved to disk etc.)
s=getNode('vtkMRMLSegmentationNode1')
se=s.GetSegmentation()
seg=se.GetSegment('Segment_1')
seg.SetColor(1,0,0)
To change the override color (only for display)
d=s.GetDisplayNode()
d.SetSegmentOverrideColor('Segment_1', 0,1,0)
1 Like