Fill between slices by code

Hi,

I would like to perform the effect “Fill between slices” of the Segment Editor in my application on a Segment Node that I have.
I can’t figure out how to do that by code. Is there a way to do that?

I’m in Slicer 4.11.0-2019-09-25

Thank you for your help.

See examples here: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#How_to_run_segment_editor_effects_from_a_script

“Fill between slices” effect works the same way as “Grow from seeds” effect, so the “brain tumor segmentation using grow from seeds effect” example should work as is, you just need to change the effect name.

1 Like

Thank you very much, editing this piece of code from your link worked.

# Run filter
################################################

# Create segment editor to get access to effects
segmentEditorWidget = slicer.qMRMLSegmentEditorWidget()
# To show segment editor widget (useful for debugging): segmentEditorWidget.show()
segmentEditorWidget.setMRMLScene(slicer.mrmlScene)
segmentEditorNode = slicer.vtkMRMLSegmentEditorNode()
slicer.mrmlScene.AddNode(segmentEditorNode)
segmentEditorWidget.setMRMLSegmentEditorNode(segmentEditorNode)
segmentEditorWidget.setSegmentationNode(segmentationNode)
segmentEditorWidget.setMasterVolumeNode(masterVolumeNode)

# Run segmentation
segmentEditorWidget.setActiveEffectByName("Fill between slices")
effect = segmentEditorWidget.activeEffect()
# You can change parameters by calling: effect.setParameter("MyParameterName", someValue)
# Most effect don't have onPreview, you can just call onApply
effect.self().onPreview()
effect.self().onApply()
1 Like