Example #1
0
    def setupScene(self):  #applet specific
        logging.debug('setupScene')
        Guidelet.setupScene(self)

        logging.debug('Create transforms')

        self.cauteryTipToCautery = slicer.util.getNode('CauteryTipToCautery')
        if not self.cauteryTipToCautery:
            self.cauteryTipToCautery = slicer.vtkMRMLLinearTransformNode()
            self.cauteryTipToCautery.SetName("CauteryTipToCautery")
            m = self.readTransformFromSettings('CauteryTipToCautery')
            if m:
                self.cauteryTipToCautery.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.cauteryTipToCautery)

        self.cauteryModelToCauteryTip = slicer.util.getNode(
            'CauteryModelToCauteryTip')
        if not self.cauteryModelToCauteryTip:
            self.cauteryModelToCauteryTip = slicer.vtkMRMLLinearTransformNode()
            self.cauteryModelToCauteryTip.SetName("CauteryModelToCauteryTip")
            m = self.readTransformFromSettings('CauteryModelToCauteryTip')
            if m:
                self.cauteryModelToCauteryTip.SetMatrixTransformToParent(m)
            self.cauteryModelToCauteryTip.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.cauteryModelToCauteryTip)

        self.needleTipToNeedle = slicer.util.getNode('NeedleTipToNeedle')
        if not self.needleTipToNeedle:
            self.needleTipToNeedle = slicer.vtkMRMLLinearTransformNode()
            self.needleTipToNeedle.SetName("NeedleTipToNeedle")
            m = self.readTransformFromSettings('NeedleTipToNeedle')
            if m:
                self.needleTipToNeedle.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.needleTipToNeedle)

        self.needleModelToNeedleTip = slicer.util.getNode(
            'NeedleModelToNeedleTip')
        if not self.needleModelToNeedleTip:
            self.needleModelToNeedleTip = slicer.vtkMRMLLinearTransformNode()
            self.needleModelToNeedleTip.SetName("NeedleModelToNeedleTip")
            m = self.readTransformFromSettings('NeedleModelToNeedleTip')
            if m:
                self.needleModelToNeedleTip.SetMatrixTransformToParent(m)
            self.needleModelToNeedleTip.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.needleModelToNeedleTip)

        self.cauteryCameraToCautery = slicer.util.getNode(
            'CauteryCameraToCautery')
        if not self.cauteryCameraToCautery:
            self.cauteryCameraToCautery = slicer.vtkMRMLLinearTransformNode()
            self.cauteryCameraToCautery.SetName("CauteryCameraToCautery")
            m = vtk.vtkMatrix4x4()
            m.SetElement(0, 0, 0)
            m.SetElement(0, 2, -1)
            m.SetElement(1, 1, 0)
            m.SetElement(1, 0, 1)
            m.SetElement(2, 2, 0)
            m.SetElement(2, 1, -1)
            self.cauteryCameraToCautery.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.cauteryCameraToCautery)

        self.CauteryToNeedle = slicer.util.getNode('CauteryToNeedle')
        if not self.CauteryToNeedle:
            self.CauteryToNeedle = slicer.vtkMRMLLinearTransformNode()
            self.CauteryToNeedle.SetName("CauteryToNeedle")
            slicer.mrmlScene.AddNode(self.CauteryToNeedle)

        # Create transforms that will be updated through OpenIGTLink

        self.cauteryToReference = slicer.util.getNode('CauteryToReference')
        if not self.cauteryToReference:
            self.cauteryToReference = slicer.vtkMRMLLinearTransformNode()
            self.cauteryToReference.SetName("CauteryToReference")
            slicer.mrmlScene.AddNode(self.cauteryToReference)

        self.needleToReference = slicer.util.getNode('NeedleToReference')
        if not self.needleToReference:
            self.needleToReference = slicer.vtkMRMLLinearTransformNode()
            self.needleToReference.SetName("NeedleToReference")
            slicer.mrmlScene.AddNode(self.needleToReference)

        # Cameras
        logging.debug('Create cameras')

        self.LeftCamera = slicer.util.getNode('Left Camera')
        if not self.LeftCamera:
            self.LeftCamera = slicer.vtkMRMLCameraNode()
            self.LeftCamera.SetName("Left Camera")
            slicer.mrmlScene.AddNode(self.LeftCamera)

        self.RightCamera = slicer.util.getNode('Right Camera')
        if not self.RightCamera:
            self.RightCamera = slicer.vtkMRMLCameraNode()
            self.RightCamera.SetName("Right Camera")
            slicer.mrmlScene.AddNode(self.RightCamera)

        # Models
        logging.debug('Create models')

        self.cauteryModel_CauteryTip = slicer.util.getNode('CauteryModel')
        if not self.cauteryModel_CauteryTip:
            if (self.parameterNode.GetParameter('TestMode') == 'True'):
                moduleDirectoryPath = slicer.modules.lumpnav.path.replace(
                    'LumpNav.py', '')
                slicer.util.loadModel(
                    qt.QDir.toNativeSeparators(
                        moduleDirectoryPath +
                        '../../../models/temporary/cautery.stl'))
                self.cauteryModel_CauteryTip = slicer.util.getNode(
                    pattern="cautery")
            else:
                slicer.modules.createmodels.logic().CreateNeedle(
                    100, 1.0, 2.5, 0)
                self.cauteryModel_CauteryTip = slicer.util.getNode(
                    pattern="NeedleModel")
                self.cauteryModel_CauteryTip.GetDisplayNode().SetColor(
                    1.0, 1.0, 0)
            self.cauteryModel_CauteryTip.SetName("CauteryModel")

        self.needleModel_NeedleTip = slicer.util.getNode('NeedleModel')
        if not self.needleModel_NeedleTip:
            slicer.modules.createmodels.logic().CreateNeedle(80, 1.0, 2.5, 0)
            self.needleModel_NeedleTip = slicer.util.getNode(
                pattern="NeedleModel")
            self.needleModel_NeedleTip.GetDisplayNode().SetColor(
                0.333333, 1.0, 1.0)
            self.needleModel_NeedleTip.SetName("NeedleModel")
            self.needleModel_NeedleTip.GetDisplayNode(
            ).SliceIntersectionVisibilityOn()

        # Create surface from point set

        logging.debug('Create surface from point set')

        self.tumorModel_Needle = slicer.util.getNode('TumorModel')
        if not self.tumorModel_Needle:
            self.tumorModel_Needle = slicer.vtkMRMLModelNode()
            self.tumorModel_Needle.SetName("TumorModel")
            sphereSource = vtk.vtkSphereSource()
            sphereSource.SetRadius(0.001)
            self.tumorModel_Needle.SetPolyDataConnection(
                sphereSource.GetOutputPort())
            slicer.mrmlScene.AddNode(self.tumorModel_Needle)
            # Add display node
            modelDisplayNode = slicer.vtkMRMLModelDisplayNode()
            modelDisplayNode.SetColor(0, 1, 0)  # Green
            modelDisplayNode.BackfaceCullingOff()
            modelDisplayNode.SliceIntersectionVisibilityOn()
            modelDisplayNode.SetSliceIntersectionThickness(4)
            modelDisplayNode.SetOpacity(0.3)  # Between 0-1, 1 being opaque
            slicer.mrmlScene.AddNode(modelDisplayNode)
            self.tumorModel_Needle.SetAndObserveDisplayNodeID(
                modelDisplayNode.GetID())

        tumorMarkups_Needle = slicer.util.getNode('T')
        if not tumorMarkups_Needle:
            tumorMarkups_Needle = slicer.vtkMRMLMarkupsFiducialNode()
            tumorMarkups_Needle.SetName("T")
            slicer.mrmlScene.AddNode(tumorMarkups_Needle)
            tumorMarkups_Needle.CreateDefaultDisplayNodes()
            tumorMarkups_Needle.GetDisplayNode().SetTextScale(0)
        self.setAndObserveTumorMarkupsNode(tumorMarkups_Needle)

        # Set up breach warning node
        logging.debug('Set up breach warning')
        self.breachWarningNode = slicer.util.getNode('LumpNavBreachWarning')

        if not self.breachWarningNode:
            self.breachWarningNode = slicer.mrmlScene.CreateNodeByClass(
                'vtkMRMLBreachWarningNode')
            self.breachWarningNode.SetName("LumpNavBreachWarning")
            slicer.mrmlScene.AddNode(self.breachWarningNode)
            self.breachWarningNode.SetPlayWarningSound(True)
            self.breachWarningNode.SetWarningColor(1, 0, 0)
            self.breachWarningNode.SetOriginalColor(
                self.tumorModel_Needle.GetDisplayNode().GetColor())
            self.breachWarningNode.SetAndObserveToolTransformNodeId(
                self.cauteryTipToCautery.GetID())
            self.breachWarningNode.SetAndObserveWatchedModelNodeID(
                self.tumorModel_Needle.GetID())

        # Set up breach warning light
        import BreachWarningLight
        logging.debug('Set up breach warning light')
        self.breachWarningLightLogic = BreachWarningLight.BreachWarningLightLogic(
        )
        self.breachWarningLightLogic.setMarginSizeMm(
            float(
                self.parameterNode.GetParameter(
                    'BreachWarningLightMarginSizeMm')))
        if (self.parameterNode.GetParameter('EnableBreachWarningLight') ==
                'True'):
            logging.debug("BreachWarningLight: active")
            self.breachWarningLightLogic.startLightFeedback(
                self.breachWarningNode, self.connectorNode)
        else:
            logging.debug("BreachWarningLight: shutdown")
            self.breachWarningLightLogic.shutdownLight(self.connectorNode)

        # Build transform tree
        logging.debug('Set up transform tree')
        self.cauteryToReference.SetAndObserveTransformNodeID(
            self.ReferenceToRas.GetID())
        self.cauteryCameraToCautery.SetAndObserveTransformNodeID(
            self.cauteryToReference.GetID())
        self.cauteryTipToCautery.SetAndObserveTransformNodeID(
            self.cauteryToReference.GetID())
        self.cauteryModelToCauteryTip.SetAndObserveTransformNodeID(
            self.cauteryTipToCautery.GetID())
        self.needleToReference.SetAndObserveTransformNodeID(
            self.ReferenceToRas.GetID())
        self.needleTipToNeedle.SetAndObserveTransformNodeID(
            self.needleToReference.GetID())
        self.needleModelToNeedleTip.SetAndObserveTransformNodeID(
            self.needleTipToNeedle.GetID())
        self.cauteryModel_CauteryTip.SetAndObserveTransformNodeID(
            self.cauteryModelToCauteryTip.GetID())
        self.needleModel_NeedleTip.SetAndObserveTransformNodeID(
            self.needleModelToNeedleTip.GetID())
        self.tumorModel_Needle.SetAndObserveTransformNodeID(
            self.needleToReference.GetID())
        self.tumorMarkups_Needle.SetAndObserveTransformNodeID(
            self.needleToReference.GetID())
        # self.liveUltrasoundNode_Reference.SetAndObserveTransformNodeID(self.ReferenceToRas.GetID())

        # Hide slice view annotations (patient name, scale, color bar, etc.) as they
        # decrease reslicing performance by 20%-100%
        logging.debug('Hide slice view annotations')
        import DataProbe
        dataProbeUtil = DataProbe.DataProbeLib.DataProbeUtil()
        dataProbeParameterNode = dataProbeUtil.getParameterNode()
        dataProbeParameterNode.SetParameter('showSliceViewAnnotations', '0')
Example #2
0
 def initViewpoint(self):
   if self.rigidBodyToTrackerTransformNode:
     # ConoProbeModelToMeasurement
     conoProbeModelToMeasurement = slicer.util.getNode('ConoProbeModelToMeasurement')      
     if not conoProbeModelToMeasurement:
       conoProbeModelToMeasurement=slicer.vtkMRMLLinearTransformNode()
       conoProbeModelToMeasurement.SetName("ConoProbeModelToMeasurement")
       m = vtk.vtkMatrix4x4()
       # Large lens
       # m.SetElement( 0, 0, -0.92 ) # Row 1
       # m.SetElement( 0, 1, -0.16 )
       # m.SetElement( 0, 2, 0.37 )
       # m.SetElement( 0, 3, 63.53 )      
       # m.SetElement( 1, 0, -0.38 )  # Row 2
       # m.SetElement( 1, 1, 0.06 )
       # m.SetElement( 1, 2, -0.92 )
       # m.SetElement( 1, 3, 81.99 )       
       # m.SetElement( 2, 0, 0.13 )  # Row 3
       # m.SetElement( 2, 1, -0.98 )
       # m.SetElement( 2, 2, -0.12 )
       # m.SetElement( 2, 3, -40.15 )
       # Small lens
       m.SetElement( 0, 0, -0.92 ) # Row 1
       m.SetElement( 0, 1, -0.16 )
       m.SetElement( 0, 2, 0.37 )
       m.SetElement( 0, 3, 63.53 )      
       m.SetElement( 1, 0, -0.38 )  # Row 2
       m.SetElement( 1, 1, 0.06 )
       m.SetElement( 1, 2, -0.92 )
       m.SetElement( 1, 3, 81.99 )       
       m.SetElement( 2, 0, 0.13 )  # Row 3
       m.SetElement( 2, 1, -0.98 )
       m.SetElement( 2, 2, -0.12 )
       m.SetElement( 2, 3, 129.85 )
       conoProbeModelToMeasurement.SetMatrixTransformToParent(m)
       slicer.mrmlScene.AddNode(conoProbeModelToMeasurement)
     conoProbeModelToMeasurement.SetAndObserveTransformNodeID(self.rigidBodyToTrackerTransformNode.GetID())    
     # ViewPointToMeasurement
     viewPointToMeasurement = slicer.util.getNode('ViewPointToMeasurement')
     if not viewPointToMeasurement:
       viewPointToMeasurement=slicer.vtkMRMLLinearTransformNode()
       viewPointToMeasurement.SetName("ViewPointToMeasurement")
       m = vtk.vtkMatrix4x4()
       # Large lens
       # m.SetElement( 0, 0, -1 ) # Row 1
       # m.SetElement( 0, 1, 0 )
       # m.SetElement( 0, 2, 0 )
       # m.SetElement( 0, 3, 53.00 )      
       # m.SetElement( 1, 0, 0 )  # Row 2
       # m.SetElement( 1, 1, -1 )
       # m.SetElement( 1, 2, 0 )
       # m.SetElement( 1, 3, 88.00 )       
       # m.SetElement( 2, 0, 0 )  # Row 3
       # m.SetElement( 2, 1, 0 )
       # m.SetElement( 2, 2, 1 )
       # m.SetElement( 2, 3, -106 )
       # Small lens
       m.SetElement( 0, 0, -1 ) # Row 1
       m.SetElement( 0, 1, 0 )
       m.SetElement( 0, 2, 0 )
       m.SetElement( 0, 3, 53.00 )      
       m.SetElement( 1, 0, 0 )  # Row 2
       m.SetElement( 1, 1, -1 )
       m.SetElement( 1, 2, 0 )
       m.SetElement( 1, 3, 88.00 )       
       m.SetElement( 2, 0, 0 )  # Row 3
       m.SetElement( 2, 1, 0 )
       m.SetElement( 2, 2, 1 )
       m.SetElement( 2, 3, 54 )
       viewPointToMeasurement.SetMatrixTransformToParent(m)
       slicer.mrmlScene.AddNode(viewPointToMeasurement)
     viewPointToMeasurement.SetAndObserveTransformNodeID(self.rigidBodyToTrackerTransformNode.GetID())  
     # ConoProbeModel
     conoProbeModel = slicer.util.getNode('ConoProbeModel')
     if not conoProbeModel:
       moduleDirectoryPath = slicer.modules.conoprobeconnector.path.replace('ConoProbeConnector.py', '')
       slicer.util.loadModel(qt.QDir.toNativeSeparators(moduleDirectoryPath + '../../Data/Models/ConoProbeModel.stl'))
       conoProbeModel=slicer.util.getNode(pattern="ConoProbeModel")
       conoProbeModel.SetName("ConoProbeModel")   
       conoProbeModel.GetDisplayNode().SetOpacity(0.7)
     conoProbeModel.SetAndObserveTransformNodeID(conoProbeModelToMeasurement.GetID())      
     # Camera
     camera = slicer.util.getNode('Camera')
     if not camera:
       camera=slicer.vtkMRMLCameraNode()
       camera.SetName("Camera")
       slicer.mrmlScene.AddNode(camera)
     threeDView = slicer.util.getNode("view1")
     camera.SetActiveTag(threeDView.GetID())        
     # Viewpoint
     self.viewpointLogic.setCameraNode(camera)
     self.viewpointLogic.setTransformNode(viewPointToMeasurement)
     self.viewpointLogic.setModelPOVOnNode(conoProbeModel)
     self.viewpointLogic.SetCameraXPosMm(53)
     self.viewpointLogic.SetCameraYPosMm(72)
     self.viewpointLogic.SetCameraZPosMm(119)
     self.viewpointLogic.startViewpoint()
Example #3
0
    def setupScene(self):  # applet specific
        logging.debug("setupScene")
        Guidelet.setupScene(self)

        logging.debug("Create transforms")

        self.cauteryTipToCautery = slicer.util.getNode("CauteryTipToCautery")
        if not self.cauteryTipToCautery:
            self.cauteryTipToCautery = slicer.vtkMRMLLinearTransformNode()
            self.cauteryTipToCautery.SetName("CauteryTipToCautery")
            m = self.readTransformFromSettings("CauteryTipToCautery")
            if m:
                self.cauteryTipToCautery.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.cauteryTipToCautery)

        self.cauteryModelToCauteryTip = slicer.util.getNode("CauteryModelToCauteryTip")
        if not self.cauteryModelToCauteryTip:
            self.cauteryModelToCauteryTip = slicer.vtkMRMLLinearTransformNode()
            self.cauteryModelToCauteryTip.SetName("CauteryModelToCauteryTip")
            m = self.readTransformFromSettings("CauteryModelToCauteryTip")
            if m:
                self.cauteryModelToCauteryTip.SetMatrixTransformToParent(m)
            self.cauteryModelToCauteryTip.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.cauteryModelToCauteryTip)

        self.needleTipToNeedle = slicer.util.getNode("NeedleTipToNeedle")
        if not self.needleTipToNeedle:
            self.needleTipToNeedle = slicer.vtkMRMLLinearTransformNode()
            self.needleTipToNeedle.SetName("NeedleTipToNeedle")
            m = self.readTransformFromSettings("NeedleTipToNeedle")
            if m:
                self.needleTipToNeedle.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.needleTipToNeedle)

        self.needleModelToNeedleTip = slicer.util.getNode("NeedleModelToNeedleTip")
        if not self.needleModelToNeedleTip:
            self.needleModelToNeedleTip = slicer.vtkMRMLLinearTransformNode()
            self.needleModelToNeedleTip.SetName("NeedleModelToNeedleTip")
            m = self.readTransformFromSettings("NeedleModelToNeedleTip")
            if m:
                self.needleModelToNeedleTip.SetMatrixTransformToParent(m)
            self.needleModelToNeedleTip.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.needleModelToNeedleTip)

        self.cauteryCameraToCautery = slicer.util.getNode("CauteryCameraToCautery")
        if not self.cauteryCameraToCautery:
            self.cauteryCameraToCautery = slicer.vtkMRMLLinearTransformNode()
            self.cauteryCameraToCautery.SetName("CauteryCameraToCautery")
            m = vtk.vtkMatrix4x4()
            m.SetElement(0, 0, 0)
            m.SetElement(0, 2, -1)
            m.SetElement(1, 1, 0)
            m.SetElement(1, 0, 1)
            m.SetElement(2, 2, 0)
            m.SetElement(2, 1, -1)
            self.cauteryCameraToCautery.SetMatrixTransformToParent(m)
            slicer.mrmlScene.AddNode(self.cauteryCameraToCautery)

        self.CauteryToNeedle = slicer.util.getNode("CauteryToNeedle")
        if not self.CauteryToNeedle:
            self.CauteryToNeedle = slicer.vtkMRMLLinearTransformNode()
            self.CauteryToNeedle.SetName("CauteryToNeedle")
            slicer.mrmlScene.AddNode(self.CauteryToNeedle)

        # Create transforms that will be updated through OpenIGTLink

        self.cauteryToReference = slicer.util.getNode("CauteryToReference")
        if not self.cauteryToReference:
            self.cauteryToReference = slicer.vtkMRMLLinearTransformNode()
            self.cauteryToReference.SetName("CauteryToReference")
            slicer.mrmlScene.AddNode(self.cauteryToReference)

        self.needleToReference = slicer.util.getNode("NeedleToReference")
        if not self.needleToReference:
            self.needleToReference = slicer.vtkMRMLLinearTransformNode()
            self.needleToReference.SetName("NeedleToReference")
            slicer.mrmlScene.AddNode(self.needleToReference)

        # Cameras
        logging.debug("Create cameras")

        self.LeftCamera = slicer.util.getNode("Left Camera")
        if not self.LeftCamera:
            self.LeftCamera = slicer.vtkMRMLCameraNode()
            self.LeftCamera.SetName("Left Camera")
            slicer.mrmlScene.AddNode(self.LeftCamera)

        self.RightCamera = slicer.util.getNode("Right Camera")
        if not self.RightCamera:
            self.RightCamera = slicer.vtkMRMLCameraNode()
            self.RightCamera.SetName("Right Camera")
            slicer.mrmlScene.AddNode(self.RightCamera)

        # Models
        logging.debug("Create models")

        self.cauteryModel_CauteryTip = slicer.util.getNode("CauteryModel")
        if not self.cauteryModel_CauteryTip:
            if self.parameterNode.GetParameter("TestMode") == "True":
                moduleDirectoryPath = slicer.modules.lumpnav.path.replace("LumpNav.py", "")
                slicer.util.loadModel(
                    qt.QDir.toNativeSeparators(moduleDirectoryPath + "../../../models/temporary/cautery.stl")
                )
                self.cauteryModel_CauteryTip = slicer.util.getNode(pattern="cautery")
            else:
                slicer.modules.createmodels.logic().CreateNeedle(100, 1.0, 2.5, 0)
                self.cauteryModel_CauteryTip = slicer.util.getNode(pattern="NeedleModel")
                self.cauteryModel_CauteryTip.GetDisplayNode().SetColor(1.0, 1.0, 0)
            self.cauteryModel_CauteryTip.SetName("CauteryModel")

        self.needleModel_NeedleTip = slicer.util.getNode("NeedleModel")
        if not self.needleModel_NeedleTip:
            slicer.modules.createmodels.logic().CreateNeedle(80, 1.0, 2.5, 0)
            self.needleModel_NeedleTip = slicer.util.getNode(pattern="NeedleModel")
            self.needleModel_NeedleTip.GetDisplayNode().SetColor(0.333333, 1.0, 1.0)
            self.needleModel_NeedleTip.SetName("NeedleModel")
            self.needleModel_NeedleTip.GetDisplayNode().SliceIntersectionVisibilityOn()

        # Create surface from point set

        logging.debug("Create surface from point set")

        self.tumorModel_Needle = slicer.util.getNode("TumorModel")
        if not self.tumorModel_Needle:
            self.tumorModel_Needle = slicer.vtkMRMLModelNode()
            self.tumorModel_Needle.SetName("TumorModel")
            sphereSource = vtk.vtkSphereSource()
            sphereSource.SetRadius(0.001)
            self.tumorModel_Needle.SetPolyDataConnection(sphereSource.GetOutputPort())
            slicer.mrmlScene.AddNode(self.tumorModel_Needle)
            # Add display node
            modelDisplayNode = slicer.vtkMRMLModelDisplayNode()
            modelDisplayNode.SetColor(0, 1, 0)  # Green
            modelDisplayNode.BackfaceCullingOff()
            modelDisplayNode.SliceIntersectionVisibilityOn()
            modelDisplayNode.SetSliceIntersectionThickness(4)
            modelDisplayNode.SetOpacity(0.3)  # Between 0-1, 1 being opaque
            slicer.mrmlScene.AddNode(modelDisplayNode)
            self.tumorModel_Needle.SetAndObserveDisplayNodeID(modelDisplayNode.GetID())

        tumorMarkups_Needle = slicer.util.getNode("T")
        if not tumorMarkups_Needle:
            tumorMarkups_Needle = slicer.vtkMRMLMarkupsFiducialNode()
            tumorMarkups_Needle.SetName("T")
            slicer.mrmlScene.AddNode(tumorMarkups_Needle)
            tumorMarkups_Needle.CreateDefaultDisplayNodes()
            tumorMarkups_Needle.GetDisplayNode().SetTextScale(0)
        self.setAndObserveTumorMarkupsNode(tumorMarkups_Needle)

        # Set up breach warning node
        logging.debug("Set up breach warning")
        self.breachWarningNode = slicer.util.getNode("LumpNavBreachWarning")

        if not self.breachWarningNode:
            self.breachWarningNode = slicer.mrmlScene.CreateNodeByClass("vtkMRMLBreachWarningNode")
            self.breachWarningNode.SetName("LumpNavBreachWarning")
            slicer.mrmlScene.AddNode(self.breachWarningNode)
            self.breachWarningNode.SetPlayWarningSound(True)
            self.breachWarningNode.SetWarningColor(1, 0, 0)
            self.breachWarningNode.SetOriginalColor(self.tumorModel_Needle.GetDisplayNode().GetColor())
            self.breachWarningNode.SetAndObserveToolTransformNodeId(self.cauteryTipToCautery.GetID())
            self.breachWarningNode.SetAndObserveWatchedModelNodeID(self.tumorModel_Needle.GetID())

        # Set up breach warning light
        import BreachWarningLight

        logging.debug("Set up breach warning light")
        self.breachWarningLightLogic = BreachWarningLight.BreachWarningLightLogic()
        self.breachWarningLightLogic.setMarginSizeMm(
            float(self.parameterNode.GetParameter("BreachWarningLightMarginSizeMm"))
        )
        if self.parameterNode.GetParameter("EnableBreachWarningLight") == "True":
            logging.debug("BreachWarningLight: active")
            self.breachWarningLightLogic.startLightFeedback(self.breachWarningNode, self.connectorNode)
        else:
            logging.debug("BreachWarningLight: shutdown")
            self.breachWarningLightLogic.shutdownLight(self.connectorNode)

        # Build transform tree
        logging.debug("Set up transform tree")
        self.cauteryToReference.SetAndObserveTransformNodeID(self.ReferenceToRas.GetID())
        self.cauteryCameraToCautery.SetAndObserveTransformNodeID(self.cauteryToReference.GetID())
        self.cauteryTipToCautery.SetAndObserveTransformNodeID(self.cauteryToReference.GetID())
        self.cauteryModelToCauteryTip.SetAndObserveTransformNodeID(self.cauteryTipToCautery.GetID())
        self.needleToReference.SetAndObserveTransformNodeID(self.ReferenceToRas.GetID())
        self.needleTipToNeedle.SetAndObserveTransformNodeID(self.needleToReference.GetID())
        self.needleModelToNeedleTip.SetAndObserveTransformNodeID(self.needleTipToNeedle.GetID())
        self.cauteryModel_CauteryTip.SetAndObserveTransformNodeID(self.cauteryModelToCauteryTip.GetID())
        self.needleModel_NeedleTip.SetAndObserveTransformNodeID(self.needleModelToNeedleTip.GetID())
        self.tumorModel_Needle.SetAndObserveTransformNodeID(self.needleToReference.GetID())
        self.tumorMarkups_Needle.SetAndObserveTransformNodeID(self.needleToReference.GetID())
        # self.liveUltrasoundNode_Reference.SetAndObserveTransformNodeID(self.ReferenceToRas.GetID())

        # Hide slice view annotations (patient name, scale, color bar, etc.) as they
        # decrease reslicing performance by 20%-100%
        logging.debug("Hide slice view annotations")
        import DataProbe

        dataProbeUtil = DataProbe.DataProbeLib.DataProbeUtil()
        dataProbeParameterNode = dataProbeUtil.getParameterNode()
        dataProbeParameterNode.SetParameter("showSliceViewAnnotations", "0")