2 import vtk, qt, ctk, slicer
4 from SegmentEditorEffects
import *
7 """ AutoCompleteEffect is an effect that can create a full segmentation 8 from a partial segmentation (not all slices are segmented or only 9 part of the target structures are painted). 13 AbstractScriptedSegmentEditorAutoCompleteEffect.__init__(self, scriptedEffect)
14 scriptedEffect.name =
'Grow from seeds' 21 import qSlicerSegmentationsEditorEffectsPythonQt
as effects
22 clonedEffect = effects.qSlicerSegmentEditorScriptedEffect(
None)
23 clonedEffect.setPythonSource(__file__.replace(
'\\',
'/'))
27 iconPath = os.path.join(os.path.dirname(__file__),
'Resources/Icons/GrowFromSeeds.png')
28 if os.path.exists(iconPath):
29 return qt.QIcon(iconPath)
33 return """<html>Growing segments to create complete segmentation<br>. 34 Location, size, and shape of initial segments and content of master volume are taken into account. 35 Final segment boundaries will be placed where master volume brightness changes abruptly. Instructions:<p> 36 <ul style="margin: 0"> 37 <li>Use Paint or other offects to draw seeds in each region that should belong to a separate segment. 38 Paint each seed with a different segment. Minimum two segments are required.</li> 39 <li>Click <dfn>Initialize</dfn> to compute preview of full segmentation.</li> 40 <li>Browse through image slices. If previewed segmentation result is not correct then switch to 41 Paint or other effects and add more seeds in the misclassified region. Full segmentation will be 42 updated automatically within a few seconds</li> 43 <li>Click <dfn>Apply</dfn> to update segmentation with the previewed result.</li> 45 If segments overlap, segment higher in the segments table will have priority. 46 The effect uses <a href="https://www.spl.harvard.edu/publications/item/view/2761">fast grow-cut method</a>. 52 AbstractScriptedSegmentEditorAutoCompleteEffect.reset(self)
53 self.updateGUIFromMRML()
56 import vtkSlicerSegmentationsModuleLogicPython
as vtkSlicerSegmentationsModuleLogic
59 self.
growCutFilter = vtkSlicerSegmentationsModuleLogic.vtkImageGrowCutSegment()
60 self.
growCutFilter.SetIntensityVolume(self.clippedMasterImageData)
62 maskExtent = self.clippedMaskImageData.GetExtent()
if self.clippedMaskImageData
else None 63 if maskExtent
is not None and maskExtent[0] <= maskExtent[1]
and maskExtent[2] <= maskExtent[3]
and maskExtent[4] <= maskExtent[5]:
clippedMasterImageDataRequired
def __init__(self, scriptedEffect)
def computePreviewLabelmap(self, mergedImage, outputLabelmap)
clippedMaskImageDataRequired