hi, I am using a python script to threshold an image after first testing in the GUI.
I am noticing that the threshold behaves differently ( different results) between the script and when doing threshold in the GUI.
The pain reason I think is that the Lower bound of the threshold in the GUI seems to be updated automatically. How can I recreate this in a script ?
segmentationNode = slicer.mrmlScene.AddNewNodeByClass('vtkMRMLSegmentationNode') segmentationNode.SetName('Segmentation_Image') segmentationNode.CreateDefaultDisplayNodes() # only needed for display segmentationNode.SetReferenceImageGeometryParameterFromVolumeNode(inputVolumeNode) addedSegmentID = segmentationNode.GetSegmentation().AddEmptySegment("Segment_BBs") # Create segment editor to get access to effects segmentEditorWidget = slicer.qMRMLSegmentEditorWidget() segmentEditorWidget.setMRMLScene(slicer.mrmlScene) segmentEditorNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentEditorNode") segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode) segmentEditorWidget.setSegmentationNode(segmentationNode) segmentEditorWidget.setSourceVolumeNode(inputVolumeNode) # Thresholding segmentEditorWidget.setActiveEffectByName("Threshold") effect = segmentEditorWidget.activeEffect() effect.setParameter("AutoThresholdMethod", "Maximum entropy") effect.setParameter("AutoThresholdMode", "SET_LOWER_MAX") effect.self().onApply()
Thanks
Result in GUI:
Result from scrip:
GT