本文整理汇总了Python中EditUtil.EditUtil.getLabel方法的典型用法代码示例。如果您正苦于以下问题:Python EditUtil.getLabel方法的具体用法?Python EditUtil.getLabel怎么用?Python EditUtil.getLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EditUtil.EditUtil
的用法示例。
在下文中一共展示了EditUtil.getLabel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from EditUtil import EditUtil [as 别名]
# 或者: from EditUtil.EditUtil import getLabel [as 别名]
def create(self):
self.frame = qt.QFrame(self.parent)
self.frame.objectName = 'EditColorFrame'
self.frame.setLayout(qt.QHBoxLayout())
self.parent.layout().addWidget(self.frame)
self.label = qt.QLabel(self.frame)
self.label.setText("Label: ")
self.frame.layout().addWidget(self.label)
self.labelName = qt.QLabel(self.frame)
self.labelName.setText("")
self.frame.layout().addWidget(self.labelName)
self.colorSpin = qt.QSpinBox(self.frame)
self.colorSpin.objectName = 'ColorSpinBox'
self.colorSpin.setMaximum( 64000)
self.colorSpin.setValue( EditUtil.getLabel() )
self.colorSpin.setToolTip( "Click colored patch at right to bring up color selection pop up window. Use the 'c' key to bring up color popup menu." )
self.frame.layout().addWidget(self.colorSpin)
self.colorPatch = qt.QPushButton(self.frame)
self.colorPatch.setObjectName('ColorPatchButton')
self.frame.layout().addWidget(self.colorPatch)
self.updateParameterNode(slicer.mrmlScene, vtk.vtkCommand.ModifiedEvent)
self.updateGUIFromMRML(self.parameterNode, vtk.vtkCommand.ModifiedEvent)
self.frame.connect( 'destroyed()', self.cleanup)
self.colorSpin.connect( 'valueChanged(int)', self.updateMRMLFromGUI)
self.colorPatch.connect( 'clicked()', self.showColorBox )
# TODO: change this to look for specfic events (added, removed...)
# but this requires being able to access events by number from wrapped code
self.addObserver(slicer.mrmlScene, vtk.vtkCommand.ModifiedEvent, self.updateParameterNode)
示例2: create
# 需要导入模块: from EditUtil import EditUtil [as 别名]
# 或者: from EditUtil.EditUtil import getLabel [as 别名]
def create(self):
self.frame = qt.QFrame(self.parent)
self.frame.objectName = 'EditColorFrame'
self.frame.setLayout(qt.QVBoxLayout())
self.parent.layout().addWidget(self.frame)
self.colorFrame = qt.QFrame(self.frame)
self.colorFrame.setLayout(qt.QHBoxLayout())
self.frame.layout().addWidget(self.colorFrame)
self.label = qt.QLabel(self.colorFrame)
self.label.setText("Label: ")
self.colorFrame.layout().addWidget(self.label)
self.labelName = qt.QLabel(self.colorFrame)
self.labelName.setText("")
self.colorFrame.layout().addWidget(self.labelName)
self.colorSpin = qt.QSpinBox(self.colorFrame)
self.colorSpin.objectName = 'ColorSpinBox'
self.colorSpin.setMaximum( 64000)
self.colorSpin.setValue( EditUtil.getLabel() )
self.colorSpin.setToolTip( "Click colored patch at right to bring up color selection pop up window. Use the 'c' key to bring up color popup menu." )
self.colorFrame.layout().addWidget(self.colorSpin)
self.colorPatch = qt.QPushButton(self.colorFrame)
self.colorPatch.setObjectName('ColorPatchButton')
self.colorFrame.layout().addWidget(self.colorPatch)
# hidden until needed terminology frames:
self.terminologyCollapsibleButton = slicer.qMRMLCollapsibleButton(self.frame)
self.terminologyCollapsibleButton.setText('Terminology')
self.terminologyCollapsibleButton .setLayout(qt.QVBoxLayout())
self.frame.layout().addWidget(self.terminologyCollapsibleButton)
# Category section:
self.terminologyCategoryFrame = qt.QFrame(self.terminologyCollapsibleButton)
self.terminologyCategoryFrame.setLayout(qt.QFormLayout())
self.terminologyCollapsibleButton.layout().addWidget(self.terminologyCategoryFrame)
# Category
self.terminologyCategory = qt.QLabel(self.terminologyCategoryFrame)
self.terminologyCategory.setText("")
# for now, read only
# self.terminologyCategory.setReadOnly(1);
self.terminologyCategoryFrame.layout().addRow("Category:", self.terminologyCategory )
# Category type:
self.terminologyCategoryType = qt.QLabel(self.terminologyCategoryFrame)
self.terminologyCategoryType.setText("")
# for now, read only
# self.terminologyCategoryType.setReadOnly(1);
self.terminologyCategoryFrame.layout().addRow("Type:", self.terminologyCategoryType )
# Category modifier:
self.terminologyCategoryModifier = qt.QLabel(self.terminologyCategoryFrame)
self.terminologyCategoryModifier.setText("")
# for now, read only
# self.terminologyCategoryModifier.setReadOnly(1);
self.terminologyCategoryFrame.layout().addRow("Modifier:", self.terminologyCategoryModifier )
# Region section
self.terminologyRegionFrame = qt.QFrame(self.terminologyCollapsibleButton)
self.terminologyRegionFrame.setLayout(qt.QFormLayout())
self.terminologyCollapsibleButton.layout().addWidget(self.terminologyRegionFrame)
# Region:
self.terminologyRegion = qt.QLabel(self.terminologyRegionFrame)
self.terminologyRegion.setText("")
# for now, read only
# self.terminologyRegion.setReadOnly(1);
self.terminologyRegionFrame.layout().addRow("Region:", self.terminologyRegion )
# Region modifier:
self.terminologyRegionModifier = qt.QLabel(self.terminologyRegionFrame)
self.terminologyRegionModifier.setText("")
# for now, read only
# self.terminologyRegionModifier.setReadOnly(1);
self.terminologyRegionFrame.layout().addRow("Modifier:", self.terminologyRegionModifier )
# hide the terminology until a LUT with associated terminology is chosen
self.hideTerminology(1)
self.updateParameterNode(slicer.mrmlScene, vtk.vtkCommand.ModifiedEvent)
self.updateGUIFromMRML(self.parameterNode, vtk.vtkCommand.ModifiedEvent)
self.frame.connect( 'destroyed()', self.cleanup)
self.colorSpin.connect( 'valueChanged(int)', self.updateMRMLFromGUI)
self.colorPatch.connect( 'clicked()', self.showColorBox )
# TODO: change this to look for specfic events (added, removed...)
# but this requires being able to access events by number from wrapped code
self.addObserver(slicer.mrmlScene, vtk.vtkCommand.ModifiedEvent, self.updateParameterNode)
示例3: makeModel
# 需要导入模块: from EditUtil import EditUtil [as 别名]
# 或者: from EditUtil.EditUtil import getLabel [as 别名]
def makeModel(self,modelName='EditorModel',smooth=True):
#
# create a model using the command line module
# based on the current editor parameters
#
volumeNode = EditUtil.getLabelVolume()
if not volumeNode:
return
#
# set up the model maker node
#
parameters = {}
parameters['Name'] = modelName
parameters["InputVolume"] = volumeNode.GetID()
parameters['FilterType'] = "Sinc"
# build only the currently selected model.
parameters['Labels'] = EditUtil.getLabel()
parameters["StartLabel"] = -1
parameters["EndLabel"] = -1
parameters['GenerateAll'] = False
parameters["JointSmoothing"] = False
parameters["SplitNormals"] = True
parameters["PointNormals"] = True
parameters["SkipUnNamed"] = True
if smooth:
parameters["Decimate"] = 0.25
parameters["Smooth"] = 10
else:
parameters["Decimate"] = 0
parameters["Smooth"] = 0
#
# output
# - make a new hierarchy node if needed
#
numNodes = slicer.mrmlScene.GetNumberOfNodesByClass( "vtkMRMLModelHierarchyNode" )
outHierarchy = None
for n in xrange(numNodes):
node = slicer.mrmlScene.GetNthNodeByClass( n, "vtkMRMLModelHierarchyNode" )
if node.GetName() == "Editor Models":
outHierarchy = node
break
if not outHierarchy:
outHierarchy = slicer.vtkMRMLModelHierarchyNode()
outHierarchy.SetScene( slicer.mrmlScene )
outHierarchy.SetName( "Editor Models" )
slicer.mrmlScene.AddNode( outHierarchy )
parameters["ModelSceneFile"] = outHierarchy
modelMaker = slicer.modules.modelmaker
#
# run the task (in the background)
# - use the GUI to provide progress feedback
# - use the GUI's Logic to invoke the task
# - model will show up when the processing is finished
#
slicer.cli.run(modelMaker, None, parameters)
slicer.util.showStatusMessage( "Model Making Started...", 2000 )
示例4: fastMarching
# 需要导入模块: from EditUtil import EditUtil [as 别名]
# 或者: from EditUtil.EditUtil import getLabel [as 别名]
def fastMarching(self,percentMax):
self.fm = None
# allocate a new filter each time March is hit
bgImage = EditUtil.getBackgroundImage()
labelImage = EditUtil.getLabelImage()
# collect seeds
if vtk.VTK_MAJOR_VERSION <= 5:
dim = bgImage.GetWholeExtent()
else:
dim = bgImage.GetDimensions()
print dim
# initialize the filter
self.fm = slicer.vtkPichonFastMarching()
scalarRange = bgImage.GetScalarRange()
depth = scalarRange[1]-scalarRange[0]
# this is more or less arbitrary; large depth values will bring the
# algorithm to the knees
scaleValue = 0
shiftValue = 0
if depth>300:
scaleValue = 300./depth
if scalarRange[0] < 0:
shiftValue = scalarRange[0]*-1
if scaleValue or shiftValue:
rescale = vtk.vtkImageShiftScale()
if vtk.VTK_MAJOR_VERSION <= 5:
rescale.SetInput(bgImage)
else:
rescale.SetInputData(bgImage)
rescale.SetScale(scaleValue)
rescale.SetShift(shiftValue)
rescale.Update()
bgImage = rescale.GetOutput()
scalarRange = bgImage.GetScalarRange()
depth = scalarRange[1]-scalarRange[0]
print('Input scalar range: '+str(depth))
if vtk.VTK_MAJOR_VERSION <= 5:
self.fm.init(dim[1]+1, dim[3]+1, dim[5]+1, depth, 1, 1, 1)
else:
self.fm.init(dim[0], dim[1], dim[2], depth, 1, 1, 1)
caster = vtk.vtkImageCast()
caster.SetOutputScalarTypeToShort()
if vtk.VTK_MAJOR_VERSION <= 5:
caster.SetInput(bgImage)
caster.Update()
self.fm.SetInput(caster.GetOutput())
else:
caster.SetInputData(bgImage)
self.fm.SetInputConnection(caster.GetOutputPort())
# self.fm.SetOutput(labelImage)
if vtk.VTK_MAJOR_VERSION <= 5:
npoints = int((dim[1]+1)*(dim[3]+1)*(dim[5]+1)*percentMax/100.)
else:
npoints = int(dim[0]*dim[1]*dim[2]*percentMax/100.)
self.fm.setNPointsEvolution(npoints)
print('Setting active label to '+str(EditUtil.getLabel()))
self.fm.setActiveLabel(EditUtil.getLabel())
nSeeds = self.fm.addSeedsFromImage(labelImage)
if nSeeds == 0:
return 0
self.fm.Modified()
self.fm.Update()
# TODO: need to call show() twice for data to be updated
self.fm.show(1)
self.fm.Modified()
self.fm.Update()
self.fm.show(1)
self.fm.Modified()
self.fm.Update()
self.undoRedo.saveState()
EditUtil.getLabelImage().DeepCopy(self.fm.GetOutput())
EditUtil.markVolumeNodeAsModified(self.sliceLogic.GetLabelLayer().GetVolumeNode())
# print('FastMarching output image: '+str(output))
print('FastMarching march update completed')
return npoints