10 from SegmentEditorEffects
import *
14 """ AutoCompleteEffect is an effect that can create a full segmentation 15 from a partial segmentation (not all slices are segmented or only 16 part of the target structures are painted). 20 AbstractScriptedSegmentEditorAutoCompleteEffect.__init__(self, scriptedEffect)
21 scriptedEffect.name =
'Grow from seeds' 28 import qSlicerSegmentationsEditorEffectsPythonQt
as effects
29 clonedEffect = effects.qSlicerSegmentEditorScriptedEffect(
None)
30 clonedEffect.setPythonSource(__file__.replace(
'\\',
'/'))
34 iconPath = os.path.join(os.path.dirname(__file__),
'Resources/Icons/GrowFromSeeds.png')
35 if os.path.exists(iconPath):
36 return qt.QIcon(iconPath)
40 return """<html>Growing segments to create complete segmentation<br>. 41 Location, size, and shape of initial segments and content of master volume are taken into account. 42 Final segment boundaries will be placed where master volume brightness changes abruptly. Instructions:<p> 43 <ul style="margin: 0"> 44 <li>Use Paint or other offects to draw seeds in each region that should belong to a separate segment. 45 Paint each seed with a different segment. Minimum two segments are required.</li> 46 <li>Click <dfn>Initialize</dfn> to compute preview of full segmentation.</li> 47 <li>Browse through image slices. If previewed segmentation result is not correct then switch to 48 Paint or other effects and add more seeds in the misclassified region. Full segmentation will be 49 updated automatically within a few seconds</li> 50 <li>Click <dfn>Apply</dfn> to update segmentation with the previewed result.</li> 52 If segments overlap, segment higher in the segments table will have priority. 53 The effect uses <a href="http://interactivemedical.org/imic2014/CameraReadyPapers/Paper%204/IMIC_ID4_FastGrowCut.pdf">fast grow-cut method</a>. 58 AbstractScriptedSegmentEditorAutoCompleteEffect.reset(self)
62 AbstractScriptedSegmentEditorAutoCompleteEffect.setupOptionsFrame(self)
74 ' thereby reducing leaks, but requires seed regions to be more evenly distributed in the image.' 75 ' The value is specified as an additional "intensity level difference" per "unit distance."')
80 AbstractScriptedSegmentEditorAutoCompleteEffect.setMRMLDefaults(self)
81 self.scriptedEffect.setParameterDefault(
"SeedLocalityFactor", 0.0)
84 AbstractScriptedSegmentEditorAutoCompleteEffect.updateGUIFromMRML(self)
85 if self.scriptedEffect.parameterDefined(
"SeedLocalityFactor"):
86 seedLocalityFactor = self.scriptedEffect.doubleParameter(
"SeedLocalityFactor")
88 seedLocalityFactor = 0.0
94 AbstractScriptedSegmentEditorAutoCompleteEffect.updateMRMLFromGUI(self)
101 if self.getPreviewNode():
102 self.delayedAutoUpdateTimer.start()
105 import vtkSlicerSegmentationsModuleLogicPython
as vtkSlicerSegmentationsModuleLogic
108 self.
growCutFilter = vtkSlicerSegmentationsModuleLogic.vtkImageGrowCutSegment()
109 self.
growCutFilter.SetIntensityVolume(self.clippedMasterImageData)
111 maskExtent = self.clippedMaskImageData.GetExtent()
if self.clippedMaskImageData
else None 112 if maskExtent
is not None and maskExtent[0] <= maskExtent[1]
and maskExtent[2] <= maskExtent[3]
and maskExtent[4] <= maskExtent[5]:
121 if self.scriptedEffect.parameterDefined(
"SeedLocalityFactor"):
122 seedLocalityFactor = self.scriptedEffect.doubleParameter(
"SeedLocalityFactor")
124 seedLocalityFactor = 0.0
127 startTime = time.time()
129 logging.info(
'Grow-cut operation on volume of {}x{}x{} voxels was completed in {:3.1f} seconds.'.format(
130 self.clippedMasterImageData.GetDimensions()[0],
131 self.clippedMasterImageData.GetDimensions()[1],
132 self.clippedMasterImageData.GetDimensions()[2],
133 time.time() - startTime))
136 imageToWorld = vtk.vtkMatrix4x4()
137 mergedImage.GetImageToWorldMatrix(imageToWorld)
138 outputLabelmap.SetImageToWorldMatrix(imageToWorld)
def updateAlgorithmParameterFromGUI(self)
clippedMasterImageDataRequired
def updateGUIFromMRML(self)
def __init__(self, scriptedEffect)
def computePreviewLabelmap(self, mergedImage, outputLabelmap)
def setupOptionsFrame(self)
def setMRMLDefaults(self)
clippedMaskImageDataRequired
def updateMRMLFromGUI(self)