2 import vtk, qt, ctk, slicer
4 from SegmentEditorEffects
import *
7 """ ThresholdEffect is an Effect implementing the global threshold 8 operation in the segment editor 10 This is also an example for scripted effects, and some methods have no 11 function. The methods that are not needed (i.e. the default implementation in 12 qSlicerSegmentEditorAbstractEffect is satisfactory) can simply be omitted. 16 AbstractScriptedSegmentEditorEffect.__init__(self, scriptedEffect)
17 scriptedEffect.name =
'Threshold' 38 self.
stencil = vtk.vtkPolyDataToImageStencil()
42 self.
reslice.AutoCropOutputOff()
44 self.
reslice.SetOutputOrigin(0, 0, 0)
45 self.
reslice.SetOutputSpacing(1, 1, 1)
46 self.
reslice.SetOutputDimensionality(3)
47 self.
reslice.GenerateStencilOutputOn()
57 import qSlicerSegmentationsEditorEffectsPythonQt
as effects
58 clonedEffect = effects.qSlicerSegmentEditorScriptedEffect(
None)
59 clonedEffect.setPythonSource(__file__.replace(
'\\',
'/'))
63 iconPath = os.path.join(os.path.dirname(__file__),
'Resources/Icons/Threshold.png')
64 if os.path.exists(iconPath):
65 return qt.QIcon(iconPath)
69 return """<html>Fill segment based on master volume intensity range<br>. Options:<p> 70 <ul style="margin: 0"> 71 <li><b>Use for masking:</b> set the selected intensity range as <dfn>Editable intensity range</dfn> and switch to Paint effect.</li> 72 <li><b>Apply:</b> set the previewed segmentation in the selected segment. Previous contents of the segment is overwritten.</li> 94 """Save current segment opacity and set it to zero 95 to temporarily hide the segment so that threshold preview 97 It also restores opacity of previously previewed segment. 98 Call restorePreviewedSegmentTransparency() to restore original 101 segmentationNode = self.scriptedEffect.parameterSetNode().GetSegmentationNode()
102 if not segmentationNode:
104 displayNode = segmentationNode.GetDisplayNode()
107 segmentID = self.scriptedEffect.parameterSetNode().GetSelectedSegmentID()
122 displayNode.SetSegmentOpacity2DFill(segmentID, 0)
123 displayNode.SetSegmentOpacity2DOutline(segmentID, 0)
126 """Restore previewed segment's opacity that was temporarily 127 made transparen by calling setCurrentSegmentTransparent().""" 128 segmentationNode = self.scriptedEffect.parameterSetNode().GetSegmentationNode()
129 if not segmentationNode:
131 displayNode = segmentationNode.GetDisplayNode()
143 self.
thresholdSliderLabel.setToolTip(
"Set the range of the background values that should be labeled.")
180 +
" Useful for iterating through all available methods.")
185 +
" Useful for iterating through all available methods.")
192 qSize = qt.QSizePolicy()
193 qSize.setHorizontalPolicy(qt.QSizePolicy.Expanding)
196 autoThresholdFrame = qt.QHBoxLayout()
203 autoThresholdGroupBox = ctk.ctkCollapsibleGroupBox()
204 autoThresholdGroupBox.setTitle(
"Automatic threshold")
205 autoThresholdGroupBox.setLayout(autoThresholdFrame)
206 autoThresholdGroupBox.collapsed =
True 207 self.scriptedEffect.addOptionsWidget(autoThresholdGroupBox)
209 histogramFrame = qt.QVBoxLayout()
211 histogramBrushFrame = qt.QHBoxLayout()
212 histogramFrame.addLayout(histogramBrushFrame)
291 histogramItemFrame = qt.QHBoxLayout()
292 histogramFrame.addLayout(histogramItemFrame)
297 lowerGroupBox = qt.QGroupBox(
"Lower")
298 lowerHistogramLayout = qt.QHBoxLayout()
299 lowerGroupBox.setLayout(lowerHistogramLayout)
300 histogramItemFrame.addWidget(lowerGroupBox)
328 upperGroupBox = qt.QGroupBox(
"Upper")
329 upperHistogramLayout = qt.QHBoxLayout()
330 upperGroupBox.setLayout(upperHistogramLayout)
331 histogramItemFrame.addWidget(upperGroupBox)
356 histogramGroupBox = ctk.ctkCollapsibleGroupBox()
357 histogramGroupBox.setTitle(
"Local histogram")
358 histogramGroupBox.setLayout(histogramFrame)
359 histogramGroupBox.collapsed =
True 360 self.scriptedEffect.addOptionsWidget(histogramGroupBox)
363 self.
useForPaintButton.setToolTip(
"Use specified intensity range for masking and switch to Paint effect.")
367 self.
applyButton.objectName = self.__class__.__name__ +
'Apply' 368 self.
applyButton.setToolTip(
"Fill selected segment in regions that are in the specified intensity range.")
369 self.scriptedEffect.addOptionsWidget(self.
applyButton)
382 return slicer.util.mainWindow().cursor
386 import vtkSegmentationCorePython
as vtkSegmentationCore
387 masterImageData = self.scriptedEffect.masterVolumeImageData()
389 lo, hi = masterImageData.GetScalarRange()
392 if (self.scriptedEffect.doubleParameter(
"MinimumThreshold") == self.scriptedEffect.doubleParameter(
"MaximumThreshold")):
394 self.scriptedEffect.setParameter(
"MinimumThreshold", lo+(hi-lo)*0.25)
395 self.scriptedEffect.setParameter(
"MaximumThreshold", hi)
401 self.scriptedEffect.setParameterDefault(
"MinimumThreshold", 0.)
402 self.scriptedEffect.setParameterDefault(
"MaximumThreshold", 0)
403 self.scriptedEffect.setParameterDefault(
"AutoThresholdMethod", METHOD_OTSU)
404 self.scriptedEffect.setParameterDefault(
"AutoThresholdMode", MODE_SET_LOWER_MAX)
405 self.scriptedEffect.setParameterDefault(HISTOGRAM_BRUSH_TYPE_PARAMETER_NAME, HISTOGRAM_BRUSH_TYPE_CIRCLE)
406 self.scriptedEffect.setParameterDefault(HISTOGRAM_SET_LOWER_PARAMETER_NAME, HISTOGRAM_SET_LOWER)
407 self.scriptedEffect.setParameterDefault(HISTOGRAM_SET_UPPER_PARAMETER_NAME, HISTOGRAM_SET_UPPER)
411 self.
thresholdSlider.setMinimumValue(self.scriptedEffect.doubleParameter(
"MinimumThreshold"))
412 self.
thresholdSlider.setMaximumValue(self.scriptedEffect.doubleParameter(
"MaximumThreshold"))
425 histogramBrushType = self.scriptedEffect.parameter(HISTOGRAM_BRUSH_TYPE_PARAMETER_NAME)
426 self.
boxROIButton.checked = (histogramBrushType == HISTOGRAM_BRUSH_TYPE_BOX)
427 self.
circleROIButton.checked = (histogramBrushType == HISTOGRAM_BRUSH_TYPE_CIRCLE)
428 self.
drawROIButton.checked = (histogramBrushType == HISTOGRAM_BRUSH_TYPE_DRAW)
429 self.
lineROIButton.checked = (histogramBrushType == HISTOGRAM_BRUSH_TYPE_LINE)
431 histogramSetModeLower = self.scriptedEffect.parameter(HISTOGRAM_SET_LOWER_PARAMETER_NAME)
436 histogramSetModeUpper = self.scriptedEffect.parameter(HISTOGRAM_SET_UPPER_PARAMETER_NAME)
444 with slicer.util.NodeModify(self.scriptedEffect.parameterSetNode()):
445 self.scriptedEffect.setParameter(
"MinimumThreshold", self.
thresholdSlider.minimumValue)
446 self.scriptedEffect.setParameter(
"MaximumThreshold", self.
thresholdSlider.maximumValue)
450 self.scriptedEffect.setParameter(
"AutoThresholdMethod", autoThresholdMethod)
454 self.scriptedEffect.setParameter(
"AutoThresholdMode", autoThresholdMode)
456 histogramParameterChanged =
False 458 histogramBrushType = HISTOGRAM_BRUSH_TYPE_CIRCLE
460 histogramBrushType = HISTOGRAM_BRUSH_TYPE_BOX
462 histogramBrushType = HISTOGRAM_BRUSH_TYPE_CIRCLE
464 histogramBrushType = HISTOGRAM_BRUSH_TYPE_DRAW
466 histogramBrushType = HISTOGRAM_BRUSH_TYPE_LINE
468 if histogramBrushType != self.scriptedEffect.parameter(HISTOGRAM_BRUSH_TYPE_PARAMETER_NAME):
469 self.scriptedEffect.setParameter(HISTOGRAM_BRUSH_TYPE_PARAMETER_NAME, histogramBrushType)
470 histogramParameterChanged =
True 472 histogramSetModeLower = HISTOGRAM_SET_LOWER
474 histogramSetModeLower = HISTOGRAM_SET_MINIMUM
476 histogramSetModeLower = HISTOGRAM_SET_LOWER
478 histogramSetModeLower = HISTOGRAM_SET_AVERAGE
479 if histogramSetModeLower != self.scriptedEffect.parameter(HISTOGRAM_SET_LOWER_PARAMETER_NAME):
480 self.scriptedEffect.setParameter(HISTOGRAM_SET_LOWER_PARAMETER_NAME, histogramSetModeLower)
481 histogramParameterChanged =
True 483 histogramSetModeUpper = HISTOGRAM_SET_UPPER
485 histogramSetModeUpper = HISTOGRAM_SET_AVERAGE
487 histogramSetModeUpper = HISTOGRAM_SET_UPPER
489 histogramSetModeUpper = HISTOGRAM_SET_MAXIMUM
490 if histogramSetModeUpper != self.scriptedEffect.parameter(HISTOGRAM_SET_UPPER_PARAMETER_NAME):
491 self.scriptedEffect.setParameter(HISTOGRAM_SET_UPPER_PARAMETER_NAME, histogramSetModeUpper)
492 histogramParameterChanged =
True 494 if histogramParameterChanged:
504 parameterSetNode = self.scriptedEffect.parameterSetNode()
505 parameterSetNode.MasterVolumeIntensityMaskOn()
508 self.scriptedEffect.selectEffect(
"Paint")
526 autoThresholdMethod = self.scriptedEffect.parameter(
"AutoThresholdMethod")
527 autoThresholdMode = self.scriptedEffect.parameter(
"AutoThresholdMode")
531 if autoThresholdMethod == METHOD_HUANG:
533 elif autoThresholdMethod == METHOD_INTERMODES:
535 elif autoThresholdMethod == METHOD_ISO_DATA:
537 elif autoThresholdMethod == METHOD_KITTLER_ILLINGWORTH:
539 elif autoThresholdMethod == METHOD_LI:
541 elif autoThresholdMethod == METHOD_MAXIMUM_ENTROPY:
543 elif autoThresholdMethod == METHOD_MOMENTS:
545 elif autoThresholdMethod == METHOD_OTSU:
547 elif autoThresholdMethod == METHOD_RENYI_ENTROPY:
549 elif autoThresholdMethod == METHOD_SHANBHAG:
551 elif autoThresholdMethod == METHOD_TRIANGLE:
553 elif autoThresholdMethod == METHOD_YEN:
556 logging.error(
"Unknown AutoThresholdMethod {0}".format(autoThresholdMethod))
558 masterImageData = self.scriptedEffect.masterVolumeImageData()
564 masterVolumeMin, masterVolumeMax = masterImageData.GetScalarRange()
566 if autoThresholdMode == MODE_SET_UPPER:
567 self.scriptedEffect.setParameter(
"MaximumThreshold", computedThreshold)
568 elif autoThresholdMode == MODE_SET_LOWER:
569 self.scriptedEffect.setParameter(
"MinimumThreshold", computedThreshold)
570 elif autoThresholdMode == MODE_SET_MIN_UPPER:
571 self.scriptedEffect.setParameter(
"MinimumThreshold", masterVolumeMin)
572 self.scriptedEffect.setParameter(
"MaximumThreshold", computedThreshold)
573 elif autoThresholdMode == MODE_SET_LOWER_MAX:
574 self.scriptedEffect.setParameter(
"MinimumThreshold", computedThreshold)
575 self.scriptedEffect.setParameter(
"MaximumThreshold", masterVolumeMax)
577 logging.error(
"Unknown AutoThresholdMode {0}".format(autoThresholdMode))
580 if not self.scriptedEffect.confirmCurrentSegmentVisible():
585 import vtkSegmentationCorePython
as vtkSegmentationCore
586 masterImageData = self.scriptedEffect.masterVolumeImageData()
588 modifierLabelmap = self.scriptedEffect.defaultModifierLabelmap()
589 originalImageToWorldMatrix = vtk.vtkMatrix4x4()
590 modifierLabelmap.GetImageToWorldMatrix(originalImageToWorldMatrix)
592 min = self.scriptedEffect.doubleParameter(
"MinimumThreshold")
593 max = self.scriptedEffect.doubleParameter(
"MaximumThreshold")
595 self.scriptedEffect.saveStateForUndo()
598 thresh = vtk.vtkImageThreshold()
599 thresh.SetInputData(masterImageData)
600 thresh.ThresholdBetween(min, max)
602 thresh.SetOutValue(0)
603 thresh.SetOutputScalarType(modifierLabelmap.GetScalarType())
605 modifierLabelmap.DeepCopy(thresh.GetOutput())
607 logging.error(
'apply: Failed to threshold master volume!')
611 self.scriptedEffect.modifySelectedSegmentByLabelmap(modifierLabelmap, slicer.qSlicerSegmentEditorAbstractEffect.ModificationModeSet)
614 self.scriptedEffect.selectEffect(
"")
618 self.scriptedEffect.removeActor2D(sliceWidget, pipeline.actor)
631 layoutManager = slicer.app.layoutManager()
632 if layoutManager
is None:
636 for sliceViewName
in layoutManager.sliceViewNames():
637 sliceWidget = layoutManager.sliceWidget(sliceViewName)
638 if not self.scriptedEffect.segmentationDisplayableInView(sliceWidget.mrmlSliceNode()):
640 renderer = self.scriptedEffect.renderer(sliceWidget)
642 logging.error(
"setupPreviewDisplay: Failed to get renderer!")
650 self.scriptedEffect.addActor2D(sliceWidget, pipeline.actor)
655 min = self.scriptedEffect.doubleParameter(
"MinimumThreshold")
656 max = self.scriptedEffect.doubleParameter(
"MaximumThreshold")
659 segmentationNode = self.scriptedEffect.parameterSetNode().GetSegmentationNode()
660 if not segmentationNode:
663 displayNode = segmentationNode.GetDisplayNode()
664 if displayNode
is None:
665 logging.error(
"preview: Invalid segmentation display node!")
666 color = [0.5,0.5,0.5]
667 segmentID = self.scriptedEffect.parameterSetNode().GetSelectedSegmentID()
673 r,g,b = segmentationNode.GetSegmentation().GetSegment(segmentID).GetColor()
678 pipeline.lookupTable.SetTableValue(1, r, g, b, opacity)
680 pipeline.thresholdFilter.SetInputConnection(layerLogic.GetReslice().GetOutputPort())
681 pipeline.thresholdFilter.ThresholdBetween(min, max)
682 pipeline.actor.VisibilityOn()
683 sliceWidget.sliceView().scheduleRender()
694 masterImageData = self.scriptedEffect.masterVolumeImageData()
695 if masterImageData
is None:
699 if viewWidget.className() !=
"qMRMLSliceWidget":
703 if eventId == vtk.vtkCommand.LeftButtonPressEvent
and not callerInteractor.GetShiftKey():
709 xy = callerInteractor.GetEventPosition()
710 ras = self.xyToRas(xy, viewWidget)
712 if eventId == vtk.vtkCommand.LeftButtonPressEvent
and not callerInteractor.GetShiftKey():
717 elif eventId == vtk.vtkCommand.LeftButtonReleaseEvent:
719 elif eventId == vtk.vtkCommand.MouseMoveEvent:
726 brushType = HISTOGRAM_BRUSH_TYPE_CIRCLE
728 brushType = HISTOGRAM_BRUSH_TYPE_BOX
730 brushType = HISTOGRAM_BRUSH_TYPE_DRAW
732 brushType = HISTOGRAM_BRUSH_TYPE_LINE
743 if (button == qt.Qt.RightButton):
752 if (button == qt.Qt.RightButton):
758 if (button == qt.Qt.RightButton):
763 masterVolumeNode = self.scriptedEffect.parameterSetNode().GetMasterVolumeNode()
764 sliceLogic = sliceWidget.sliceLogic()
766 backgroundLogic = sliceLogic.GetBackgroundLayer()
767 backgroundVolumeNode = backgroundLogic.GetVolumeNode()
768 if masterVolumeNode == backgroundVolumeNode:
769 return backgroundLogic
771 foregroundLogic = sliceLogic.GetForegroundLayer()
772 foregroundVolumeNode = foregroundLogic.GetVolumeNode()
773 if masterVolumeNode == foregroundVolumeNode:
774 return foregroundLogic
776 logging.warning(
"Master volume is not set as either the foreground or background")
778 foregroundOpacity = 0.0
779 if foregroundVolumeNode:
780 compositeNode = sliceLogic.GetSliceCompositeNode()
781 foregroundOpacity = compositeNode.GetForegroundOpacity()
783 if foregroundOpacity > 0.5:
784 return foregroundLogic
786 return backgroundLogic
789 masterImageData = self.scriptedEffect.masterVolumeImageData()
801 brushBounds = brushPolydata.GetBounds()
802 brushExtent = [0, -1, 0, -1, 0, -1]
804 brushExtent[2*i] = vtk.vtkMath.Floor(brushBounds[2*i])
805 brushExtent[2*i+1] = vtk.vtkMath.Ceil(brushBounds[2*i+1])
806 if brushExtent[0] > brushExtent[1]
or brushExtent[2] > brushExtent[3]
or brushExtent[4] > brushExtent[5]:
811 self.
reslice.SetInputConnection(layerLogic.GetReslice().GetInputConnection(0, 0))
812 self.
reslice.SetResliceTransform(layerLogic.GetReslice().GetResliceTransform())
813 self.
reslice.SetInterpolationMode(layerLogic.GetReslice().GetInterpolationMode())
814 self.
reslice.SetOutputExtent(brushExtent)
816 maxNumberOfBins = 1000
817 masterImageData = self.scriptedEffect.masterVolumeImageData()
818 scalarRange = masterImageData.GetScalarRange()
819 scalarType = masterImageData.GetScalarType()
820 if scalarType == vtk.VTK_FLOAT
or scalarType == vtk.VTK_DOUBLE:
821 numberOfBins = maxNumberOfBins
823 numberOfBins = int(scalarRange[1] - scalarRange[0]) + 1
824 if numberOfBins > maxNumberOfBins:
825 numberOfBins = maxNumberOfBins
826 binSpacing = (scalarRange[1] - scalarRange[0] + 1) / numberOfBins
828 self.
imageAccumulate.SetComponentExtent(0, numberOfBins - 1, 0, 0, 0, 0)
829 self.
imageAccumulate.SetComponentSpacing(binSpacing, binSpacing, binSpacing)
830 self.
imageAccumulate.SetComponentOrigin(scalarRange[0], scalarRange[0], scalarRange[0])
835 tableSize = self.
imageAccumulate.GetOutput().GetPointData().GetScalars().GetNumberOfTuples()
836 for i
in range(tableSize):
837 value = self.
imageAccumulate.GetOutput().GetPointData().GetScalars().GetTuple1(i)
852 lower = min(startX, endX)
853 average = (startX + endX) / 2.0
854 upper = max(startX, endX)
872 minimumThreshold = lower
873 maximumThreshold = upper
875 histogramSetModeLower = self.scriptedEffect.parameter(HISTOGRAM_SET_LOWER_PARAMETER_NAME)
876 if histogramSetModeLower == HISTOGRAM_SET_MINIMUM:
877 minimumThreshold = scalarRange[0]
878 elif histogramSetModeLower == HISTOGRAM_SET_LOWER:
879 minimumThreshold = lower
880 elif histogramSetModeLower == HISTOGRAM_SET_AVERAGE:
881 minimumThreshold = average
883 histogramSetModeUpper = self.scriptedEffect.parameter(HISTOGRAM_SET_UPPER_PARAMETER_NAME)
884 if histogramSetModeUpper == HISTOGRAM_SET_AVERAGE:
885 maximumThreshold = average
886 elif histogramSetModeUpper == HISTOGRAM_SET_UPPER:
887 maximumThreshold = upper
888 elif histogramSetModeUpper == HISTOGRAM_SET_MAXIMUM:
889 maximumThreshold = scalarRange[1]
891 self.scriptedEffect.setParameter(
"MinimumThreshold", minimumThreshold)
892 self.scriptedEffect.setParameter(
"MaximumThreshold", maximumThreshold)
897 masterImageData = self.scriptedEffect.masterVolumeImageData()
898 if masterImageData
is None:
901 scalarRange = masterImageData.GetScalarRange()
904 low = self.scriptedEffect.doubleParameter(
"MinimumThreshold")
905 upper = self.scriptedEffect.doubleParameter(
"MaximumThreshold")
906 low = max(scalarRange[0] + epsilon, low)
907 upper = min(scalarRange[1] - epsilon, upper)
922 """ Visualization objects and pipeline for each slice view for threshold preview 942 self.
dummyImage.AllocateScalars(vtk.VTK_UNSIGNED_INT, 1)
945 self.
actor.VisibilityOff()
947 self.
mapper.SetColorWindow(255)
948 self.
mapper.SetColorLevel(128)
959 thresholdEffect =
None 967 if (event.type() == qt.QEvent.GraphicsSceneMousePress
or 968 event.type() == qt.QEvent.GraphicsSceneMouseMove
or 969 event.type() == qt.QEvent.GraphicsSceneMouseRelease):
970 transferFunction = object.transferFunction()
971 if transferFunction
is None:
974 representation = transferFunction.representation()
975 x = representation.mapXFromScene(event.pos().x())
976 y = representation.mapYFromScene(event.pos().y())
979 if event.type() == qt.QEvent.GraphicsSceneMousePress:
981 elif event.type() == qt.QEvent.GraphicsSceneMouseMove:
983 elif event.type() == qt.QEvent.GraphicsSceneMouseRelease:
991 def __init__(self, thresholdEffect, scriptedEffect, sliceWidget, brushMode):
1043 lines = vtk.vtkCellArray()
1050 thinLines = vtk.vtkCellArray()
1056 self.
mapper.SetInputConnection(self.
cutter.GetOutputPort())
1061 actorProperty = self.
actor.GetProperty()
1062 actorProperty.SetColor(1,1,0)
1063 actorProperty.SetLineWidth(2)
1065 if renderer
is None:
1066 logging.error(
"pipelineForWidget: Failed to get renderer!")
1071 if self.
brushMode == HISTOGRAM_BRUSH_TYPE_DRAW:
1084 thinActorProperty = self.
thinActor.GetProperty()
1085 thinActorProperty.SetColor(1,1,0)
1086 thinActorProperty.SetLineWidth(1)
1088 elif self.
brushMode == HISTOGRAM_BRUSH_TYPE_LINE:
1092 if self.
actor is not None:
1106 if self.
brushMode == HISTOGRAM_BRUSH_TYPE_DRAW:
1107 newPointIndex = self.
rasPoints.InsertNextPoint(ras)
1108 previousPointIndex = newPointIndex - 1
1109 if (previousPointIndex >= 0):
1110 idList = vtk.vtkIdList()
1111 idList.InsertNextId(previousPointIndex)
1112 idList.InsertNextId(newPointIndex)
1113 self.
polyData.InsertNextCell(vtk.VTK_LINE, idList)
1116 thinLines.Initialize()
1117 idList = vtk.vtkIdList()
1118 idList.InsertNextId(newPointIndex)
1119 idList.InsertNextId(0)
1132 sliceXyToRas = self.
sliceWidget.sliceLogic().GetSliceNode().GetXYToRAS()
1133 rasToSliceXy = vtk.vtkMatrix4x4()
1134 vtk.vtkMatrix4x4.Invert(sliceXyToRas, rasToSliceXy)
1138 brushToWorldOriginTransformMatrix = vtk.vtkMatrix4x4()
1139 brushToWorldOriginTransformMatrix.DeepCopy(self.
sliceWidget.sliceLogic().GetSliceNode().GetSliceToRAS())
1140 brushToWorldOriginTransformMatrix.SetElement(0,3, 0)
1141 brushToWorldOriginTransformMatrix.SetElement(1,3, 0)
1142 brushToWorldOriginTransformMatrix.SetElement(2,3, 0)
1151 if self.
brushMode == HISTOGRAM_BRUSH_TYPE_CIRCLE:
1154 point1ToPoint2 = [0,0,0]
1155 vtk.vtkMath.Subtract(self.
point1, self.
point2, point1ToPoint2)
1156 radius = vtk.vtkMath.Normalize(point1ToPoint2)
1162 elif self.
brushMode == HISTOGRAM_BRUSH_TYPE_BOX:
1172 xLength = abs(vtk.vtkMath.Dot(xVector[:3], length))
1177 zLength = abs(vtk.vtkMath.Dot(zVector[:3], length))
1181 elif self.
brushMode == HISTOGRAM_BRUSH_TYPE_LINE:
1191 HISTOGRAM_BRUSH_TYPE_PARAMETER_NAME =
"BrushType" 1193 HISTOGRAM_BRUSH_TYPE_BOX =
'BOX' 1194 HISTOGRAM_BRUSH_TYPE_CIRCLE =
'CIRCLE' 1195 HISTOGRAM_BRUSH_TYPE_DRAW =
'DRAW' 1196 HISTOGRAM_BRUSH_TYPE_LINE =
'LINE' 1198 HISTOGRAM_STATE_OFF =
'OFF' 1199 HISTOGRAM_STATE_MOVING =
'MOVING' 1200 HISTOGRAM_STATE_PLACED =
'PLACED' 1202 HISTOGRAM_SET_LOWER_PARAMETER_NAME =
'HistogramSetLower' 1203 HISTOGRAM_SET_UPPER_PARAMETER_NAME =
'HistogramSetUpper' 1205 HISTOGRAM_SET_MINIMUM =
'MINIMUM' 1206 HISTOGRAM_SET_LOWER =
'LOWER' 1207 HISTOGRAM_SET_AVERAGE =
'AVERAGE' 1208 HISTOGRAM_SET_UPPER =
'UPPER' 1209 HISTOGRAM_SET_MAXIMUM =
'MAXIMUM' 1213 METHOD_HUANG =
'HUANG' 1214 METHOD_INTERMODES =
'INTERMODES' 1215 METHOD_ISO_DATA =
'ISO_DATA' 1216 METHOD_KITTLER_ILLINGWORTH =
'KITTLER_ILLINGWORTH' 1218 METHOD_MAXIMUM_ENTROPY =
'MAXIMUM_ENTROPY' 1219 METHOD_MOMENTS =
'MOMENTS' 1220 METHOD_OTSU =
'OTSU' 1221 METHOD_RENYI_ENTROPY =
'RENYI_ENTROPY' 1222 METHOD_SHANBHAG =
'SHANBHAG' 1223 METHOD_TRIANGLE =
'TRIANGLE' 1226 MODE_SET_UPPER =
'SET_UPPER' 1227 MODE_SET_LOWER =
'SET_LOWER' 1228 MODE_SET_MIN_UPPER =
'SET_MIN_UPPER' 1229 MODE_SET_LOWER_MAX =
'SET_LOWER_MAX'
def setThresholdEffect(self, thresholdEffect)
histogramUpperMethodButtonGroup
Upper histogram threshold buttons.
histogramUpperThresholdMaximumButton
def updateMRMLFromGUI(self)
worldOriginToWorldTransform
def onSelectNextAutoThresholdMethod(self)
def setMRMLDefaults(self)
def onThresholdValuesChanged(self, min, max)
def onHistogramMouseRelease(self, pos, button)
def createHistogramPipeline(self, sliceWidget)
histogramLowerThresholdAverageButton
def eventFilter(self, object, event)
histogramLowerThresholdLowerButton
histogramUpperThresholdAverageButton
histogramLowerThresholdMinimumButton
def processViewNodeEvents(self, callerViewNode, eventId, viewWidget)
def onSelectedAutoThresholdMethod(self)
backgroundFunctionContainer
def getMasterVolumeLayerLogic(self, sliceWidget)
def updateBrushModel(self)
histogramLowerMethodButtonGroup
Lower histogram threshold buttons.
histogramUpperThresholdUpperButton
thinWorldToSliceTransformer
def setupOptionsFrame(self)
def clearPreviewDisplay(self)
def onHistogramMouseClick(self, pos, button)
selectPreviousAutoThresholdButton
def updateHistogramBackground(self)
brushToWorldOriginTransformer
def clearHistogramDisplay(self)
def updateHistogram(self)
def autoThreshold(self, autoThresholdMethod, autoThresholdMode)
def restorePreviewedSegmentTransparency(self)
def setupPreviewDisplay(self)
def __init__(self, scriptedEffect)
def masterVolumeNodeChanged(self)
def onAutoThreshold(self)
def updateGUIFromMRML(self)
histogramFunctionContainer
selectNextAutoThresholdButton
def createCursor(self, widget)
def setCurrentSegmentTransparent(self)
autoThresholdModeSelectorComboBox
brushToWorldOriginTransform
worldOriginToWorldTransformer
def processInteractionEvents(self, callerInteractor, eventId, viewWidget)
def onSelectPreviousAutoThresholdMethod(self)
def __init__(self, thresholdEffect, scriptedEffect, sliceWidget, brushMode)
autoThresholdMethodSelectorComboBox
histogramBrushButtonGroup
def onHistogramMouseMove(self, pos, button)