Hi, all,
I just started learning slicer+jupyter and recently I have a problem that I can’t solve, I would appreciate if someone tell me:
Before activating LocalTreshold(from extensions module named “SegmentEditorExtraEffects”), I followed the link to fit ROI to volume.
Then, I have set the basic parameters as shown, but how can I set the ROI with code?
"effect.setParameter(“ROI”,)" doesn’t seem to work (: sampleID/name/vtkMRMLAnnotationROINode).
segmentEditorWidget.setActiveEffectByName("Local Threshold")
effect = segmentEditorWidget.activeEffect()
effect.setParameter("MinimumThreshold",str(40000))
effect.setParameter("MaximumThreshold",str(200000))
effect.setParameter("MinimumDiameterMm",str(4))
#How to select a ROI?
Hi, all,
I just started learning slicer+jupyter and recently I have a problem that I can’t solve, I would appreciate if someone tell me:
Before activating the effect of LocalThreshold (an effect of SegmentEditorExtraEffects), I followed the link to fit an existing ROI to volume, the ROI is smaller than the volume. Then,I have set the basic parameters as shown, how can I set the ROI with code?
"effect.setParameter(“ROI”,)" seems to have no effect (: sampleID/name/vtkMRMLAnnotationROINode)
segmentEditorWidget.setActiveEffectByName("Local Threshold")
effect = segmentEditorWidget.activeEffect()
# You can change parameters by calling: effect.setParameter("MyParameterName", someValue)
effect.setParameter("MinimumThreshold",str(40000))
effect.setParameter("MaximumThreshold",str(200000))
effect.setParameter("MinimumDiameterMm",str(4))
#How to selcet ROI?
It seems that thw. ROI is not stored in MRML, but it is directly read from the GUI. This is not ideal, but it happens for extensions that are still somewhat experimental, being in the the “SegmentEditorExtraEffects” extension.
Until this is fixed (by adding a MRML node reference), you may access the effect’s GUI and set the ROI node calling effectWidget.roiSelector.setCurrentNode(SomeROI).
@Sunderlandkyl when you find some time could you update the Local Threshold effect to store the ROI in a node reference and post here when it is done? Thank you!
This code snippet may give you enough insight for a workaround.
# The segment editor module must have been shown at least once.
mainWindow = slicer.util.mainWindow()
mainWindow.moduleSelector().selectModule('SegmentEditor')
# Select an effect.
widgetEditor = slicer.modules.SegmentEditorWidget.editor
widgetEditor.setActiveEffectByName("Local Threshold")
activeEffect = widgetEditor.activeEffect()
# Get the ROI combobox.
roiSelector = activeEffect.optionsFrame().children()[14]
"""
'activeEffect.optionsFrame().children()' lists all widgets of an effect.
If a widget has a name you can access it as such :
activeEffect.optionsFrame().findChild(qt.QPushButton, "SegmentEditorEffectApply")
If a widget does not have a name, guess and count its index sequentially.
An MRML node reference for this effect would be nicer of course.
"""