我想做2个Segmentation的交集…遇到了问题…大神帮帮我
I want to use python to do the intersection of 2 Segmentations…I have a problem…Help me please
seg = slicer.util.getNode("segment")
# Cyl = Logic.p2pCyl(P0,P1,radius=1)
modNode = getNode("Cylinder")
cylSegnode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLSegmentationNode")
cylSegnode.SetName("segCly")
slicer.modules.segmentations.logic().ImportModelToSegmentationNode(
modNode, cylSegnode
)
# 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(cylSegnode)
# segmentEditorWidget.setMasterVolumeNode(masterVolumeNode)
segmentEditorNode.SetOverwriteMode(slicer.vtkMRMLSegmentEditorNode.OverwriteNone)
segmentEditorNode.SetMaskMode(slicer.vtkMRMLSegmentEditorNode.PaintAllowedEverywhere)
segmentEditorWidget.setCurrentSegmentID(cylSegnode.GetID())
segmentEditorWidget.setActiveEffectByName("Logical operators")
effect = segmentEditorWidget.activeEffect()
effect.setParameter("Operation", "INTERSECT")
35 >>> effect.setParameter("ModifierSegmentID", seg.GetID())
effect.self().onApply()
Line 35:
File /Applications/Slice98.app/Contents/lib/Slicer-4.13/qt-scripted-modules/SegmentEditorEffects/SegmentEditorLogicalEffect.py, in onApply:
Line 244: vtkSegmentationCore.vtkOrientedImageDataResample.OPERATION_MINIMUM, selectedSegmentLabelmap.GetExtent())
AttributeError: 'NoneType' object has no attribute 'GetExtent'