Пример #1
0
    def onSendButtonClicked(self):
        """Send the data to the Extral Devices which support the OpenIGTLink protocal"""
        # Get the number of the 'vtkMRMLIGTLConnectorNode'
        n = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLIGTLConnectorNode')
        # Set the 'vtkMRMLIGTLConnectorNode' node
        if n > 0:
            for i in range(n):
                if slicer.mrmlScene.GetNthNodeByClass(i, 'vtkMRMLIGTLConnectorNode').GetName() == 'Send-Data':
                    connectorNode = slicer.mrmlScene.GetNthNodeByClass(i, 'vtkMRMLIGTLConnectorNode')
                else:
                    connectorNode = slicer.vtkMRMLIGTLConnectorNode()
                    slicer.mrmlScene.AddNode(connectorNode)
                    connectorNode.SetName('Send-Data')
        else:
            connectorNode = slicer.vtkMRMLIGTLConnectorNode()
            slicer.mrmlScene.AddNode(connectorNode)
            connectorNode.SetName('Send-Data')

        hostname = self.hostnameLineEdit.text
        port = int(self.portLineEdit.text)
        connectorNode.SetTypeClient(hostname, port)
        checker = connectorNode.Start()

        #Get the number of the 'vtkMRMLLinearTransformNode'
        n = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLLinearTransformNode')
        #Set the 'vtkMRMLLinearTransformNode' node
        nodes = []
        for i in range(n):
            nodes.append(slicer.mrmlScene.GetNthNodeByClass(i, 'vtkMRMLLinearTransformNode'))
        for i in range(n):
            if nodes[i].GetName() == 'Result-Data':
                slicer.mrmlScene.RemoveNode(nodes[i])
        transformNode = slicer.vtkMRMLLinearTransformNode()
        slicer.mrmlScene.AddNode(transformNode)
        transformNode.SetName('Result-Data')

        connectorNode.RegisterOutgoingMRMLNode(transformNode)
        matrix = transformNode.GetMatrixTransformToParent()
        theta = self.result.angleRed
        omega = self.result.angleGreen
        phi = self.result.angleBlue
        e1 = numpy.cos(phi)*numpy.cos(omega)
        e2 = numpy.sin(phi)*numpy.cos(theta) + numpy.cos(phi)*numpy.sin(omega)*numpy.sin(theta)
        e3 = numpy.sin(phi)*numpy.sin(theta) - numpy.cos(phi)*numpy.sin(omega)*numpy.cos(theta)
        e4 = self.result.distance

        e5 = numpy.sin(phi)*numpy.cos(omega)*(-1)
        e6 = numpy.cos(phi)*numpy.cos(theta) - numpy.sin(phi)*numpy.sin(omega)*numpy.sin(theta)
        e7 = numpy.cos(phi)*numpy.sin(theta) + numpy.sin(phi)*numpy.sin(omega)*numpy.cos(theta)
        e8 = 0

        e9 = numpy.sin(omega)
        e10 = numpy.cos(omega)*numpy.sin(theta)*(-1)
        e11 = numpy.cos(omega)*numpy.cos(theta)
        e12 = 0
        
        time.sleep(1)
        matrix.DeepCopy((e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,0,0,0,1))
        time.sleep(1)
        connectorNode.Stop()       
Пример #2
0
  def onButtonConnectClicked(self):
    if self.connectTag:  # check already has a connect node
      print "Olalalalala!!!"

    else:  # first time to create the connect node
      self.connectNode = slicer.vtkMRMLIGTLConnectorNode()
      self.connectNode.SetName('testConnectNode')
      slicer.mrmlScene.AddNode(self.connectNode)

      lenHost = len(self.lineEditHostname.text)
      lenPort = len(self.lineEditPort.text)
      # check the input
      if lenHost == 0 or lenPort == 0:
        qt.QMessageBox.information(
          slicer.util.mainWindow(),
          "Slicer Python", "Hostname/Port invalid!")
      else:
        self.strHostname = str(self.lineEditHostname.text)
        self.intPort = int(self.lineEditPort.text)
        self.connectNode.SetTypeClient(self.strHostname, self.intPort)
        self.connectNode.Start()  # connect

        self.activeEvent()  # active the monitor
        self.buttonDisconnect.setEnabled(True)
        self.connectTag = True
Пример #3
0
    def setOpenIGTConnections(self):
        self.cnode_1 = slicer.vtkMRMLIGTLConnectorNode()
        slicer.mrmlScene.AddNode(self.cnode_1)
        self.cnode_1.SetName('Connector1')
        self.cnode_1.SetTypeClient('localhost', 18944)

        self.cnode_2 = slicer.vtkMRMLIGTLConnectorNode()
        slicer.mrmlScene.AddNode(self.cnode_2)
        self.cnode_2.SetName('Connector2')
        self.cnode_2.SetTypeClient('localhost', 18945)
        events = [[slicer.vtkMRMLIGTLConnectorNode.ConnectedEvent, self.onConnectorNodeConnected], [slicer.vtkMRMLIGTLConnectorNode.DisconnectedEvent, self.onConnectorNodeDisconnected]]
        for tagEventHandler in events:
            connectorNodeObserverTag_2 = self.cnode_2.AddObserver(tagEventHandler[0], tagEventHandler[1])
            connectorNodeObserverTag_1 = self.cnode_1.AddObserver(tagEventHandler[0], tagEventHandler[1])
            self.connectorNodeObserverTagList.append(connectorNodeObserverTag_1)
            self.connectorNodeObserverTagList.append(connectorNodeObserverTag_2)
Пример #4
0
 def createAndAssociateConectorNodeWithScene(self):
   cn=slicer.util.getNode('Plus Server Connection')  
   if cn == None:
      cn=slicer.vtkMRMLIGTLConnectorNode()
      slicer.mrmlScene.AddNode(cn)
      cn.SetName('Plus Server Connection')
      print("IGTL Connector node was created!")
   self.connectorNode = cn
Пример #5
0
 def createAndAssociateConectorNodeWithScene(self):
   cn = slicer.util.getNode('Plus Server Connection')  
   if cn == None:
      cn = slicer.vtkMRMLIGTLConnectorNode()
      slicer.mrmlScene.AddNode(cn)
      cn.SetName('Plus Server Connection')
      print("IGTL Connector node was created!")
   self.connectorNode = cn
Пример #6
0
 def setupConnectorNode(self):
   self.connectorNode = slicer.util.getNode('PlusConnector')
   if not self.connectorNode:
     self.connectorNode = slicer.vtkMRMLIGTLConnectorNode()
     slicer.mrmlScene.AddNode(self.connectorNode)
     self.connectorNode.SetName('PlusConnector')      
     hostNamePort = self.parameterNode.GetParameter('PlusServerHostNamePort') # example: "localhost:18944"
     [hostName, port] = hostNamePort.split(':')
     self.connectorNode.SetTypeClient(hostName, int(port))
     logging.debug("PlusConnector created")
   self.connectorNode.Start()
Пример #7
0
 def createPlusConnector(self):
   connectorNode = slicer.util.getNode('PlusConnector')
   if not connectorNode:
     connectorNode = slicer.vtkMRMLIGTLConnectorNode()
     slicer.mrmlScene.AddNode(connectorNode)
     connectorNode.SetName('PlusConnector')      
     hostNamePort = "localhost:18944"
     [hostName, port] = hostNamePort.split(':')
     connectorNode.SetTypeClient(hostName, int(port))
     logging.debug("PlusConnector created")
   return connectorNode
Пример #8
0
 def createPlusConnector(self):
   connectorNode = slicer.util.getNode('PlusConnector')
   if not connectorNode:
     connectorNode = slicer.vtkMRMLIGTLConnectorNode()
     slicer.mrmlScene.AddNode(connectorNode)
     connectorNode.SetName('PlusConnector')
     hostNamePort = self.guideletParent.parameterNode.GetParameter('PlusServerHostNamePort') # example: "localhost:18944"
     [hostName, port] = hostNamePort.split(':')
     connectorNode.SetTypeClient(hostName, int(port))
     logging.debug("PlusConnector created")
   return connectorNode
Пример #9
0
 def createPlusConnector(self):
     connectorNode = slicer.mrmlScene.GetFirstNodeByName('PlusConnector')
     if not connectorNode:
         connectorNode = slicer.vtkMRMLIGTLConnectorNode()
         slicer.mrmlScene.AddNode(connectorNode)
         connectorNode.SetName('PlusConnector')
         hostNamePort = self.guideletParent.parameterNode.GetParameter(
             'PlusServerHostNamePort')  # example: "localhost:18944"
         [hostName, port] = hostNamePort.split(':')
         connectorNode.SetTypeClient(hostName, int(port))
         logging.debug("PlusConnector created")
     return connectorNode
Пример #10
0
 def createPlusConnector(self):
     connectorNode = slicer.util.getNode("PlusConnector")
     if not connectorNode:
         connectorNode = slicer.vtkMRMLIGTLConnectorNode()
         connectorNode.SetLogErrorIfServerConnectionFailed(False)
         slicer.mrmlScene.AddNode(connectorNode)
         connectorNode.SetName("PlusConnector")
         hostNamePort = self.guideletParent.parameterNode.GetParameter(
             "PlusServerHostNamePort"
         )  # example: "localhost:18944"
         [hostName, port] = hostNamePort.split(":")
         connectorNode.SetTypeClient(hostName, int(port))
         logging.debug("PlusConnector created")
     return connectorNode
Пример #11
0
 def __init__(self, parent = None):
   if not parent:
     self.parent = slicer.qMRMLWidget()
     self.parent.setLayout(qt.QVBoxLayout())
     self.parent.setMRMLScene(slicer.mrmlScene)
   else:
     self.parent = parent
   self.layout = self.parent.layout()
   if not parent:
     self.setup()
     self.parent.show()
   
   #initialize some variables and settings
   self.connection_node = slicer.vtkMRMLIGTLConnectorNode()
   slicer.mrmlScene.AddNode(self.connection_node)
   self.next_node = 0
Пример #12
0
 def __init__(self, parent):
   ScriptedLoadableModuleLogic.__init__(self, parent)
   
   self.scene = slicer.mrmlScene
   self.scene.AddObserver(slicer.vtkMRMLScene.NodeRemovedEvent, self.onNodeRemovedEvent)
   self.colorList = ([0.5, 0, 0], [0, 0.5, 0], [0, 0, 0.5],[0.5, 0, 0.5],[0, 0.5, 0.5])
   self.colorMap = dict()
   self.SelectedRowNum = None
   
   @vtk.calldata_type(vtk.VTK_OBJECT)
   def updateLocator(caller, event, callerdata):
     node = callerdata
     if isinstance(node, slicer.vtkMRMLLinearTransformNode) :
       firstSelector = self.widget.transformSelector[0]
       tCollection = self.scene.GetNodesByClass("vtkMRMLLinearTransformNode")
       channelNum = tCollection.GetReferenceCount()
       setNum = self.widget.nLocators
       if channelNum < setNum:
         setNum = channelNum
       for i in range(setNum+1):
         selector = self.widget.transformSelector[i]
         selector.setCurrentNodeIndex(i)
         if self.scene.GetNodeByID(selector.currentNodeID):
           self.colorMap[self.scene.GetNodeByID(selector.currentNodeID).GetName()] = self.colorList[i]
     pass
   self.scene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, updateLocator)
   self.widget = None
   self.cnode = slicer.vtkMRMLIGTLConnectorNode()
   self.metaDataQueryNode = vtkSlicerOpenIGTLinkIFModuleMRML.vtkMRMLIGTLQueryNode()
   self.scene.AddNode(self.cnode)
   self.scene.AddNode(self.metaDataQueryNode)
   
   self.eventTag = {}
   
   # IGTL Conenctor Node ID
   self.connectorNodeID = ''
   
   self.count = 0
Пример #13
0
# This module was tested on 3D Slicer version 4.3.1
Пример #14
0
# This module was tested on 3D Slicer version 4.3.1
Пример #15
0
 def setupConnection(self):
   self.connectNode = slicer.vtkMRMLIGTLConnectorNode()
   self.connectNode.SetName('testConnect')
   slicer.mrmlScene.AddNode(self.connectNode)
   self.connectNode.SetTypeClient('localhost', 10000)
   self.connectNode.Start()  # connect
Пример #16
0
    def __init__(self, parent, logic, configurationName='Default'):
        self.slice3DChartCustomLayoutId = 5000  # Must come before Guidelet.__init__
        Guidelet.__init__(self, parent, logic, configurationName)

        logging.debug('EpiGuideGuidelet.__init__')
        self.logic.addValuesToDefaultConfiguration()

        # for debugging purposes only, to be removed
        slicer.epi = self

        self.navigationCollapsibleButton = None

        self.imageData = None
        self.imageDimensions = None
        self.line = None
        self.table = None
        self.chart = None
        self.view = None
        self.signalArray = None
        self.distanceArray = None
        self.boundsRecalculated = False
        self.fitUltrasoundImageToViewOnConnect = True

        self.firstPeakToSETTipTransformNode = None
        self.secondPeakToSETTipTransformNode = None
        self.thirdPeakToSETTipTransformNode = None

        self.firstPeakModelNode = None
        self.secondPeakModelNode = None
        self.thirdPeakModelNode = None

        self.needleWithTipModel = None
        self.trajectoryModel_needleModel = None
        self.trajectoryModel_needleTip = None

        self.referenceToRasTransform = None
        self.needleTipToNeedleTransform = None
        self.needleModelToNeedleTipTransform = None
        self.trajModelToNeedleTipTransform = None
        self.needleToReferenceTransform = None
        self.setTipToReferenceTransformNode = None

        self.aModeImageNode = None

        self.timer = qt.QTimer()

        self.agilentCommandLogic = PlusRemoteLogic()
        self.agilentConnectorNode = slicer.mrmlScene.AddNode(
            slicer.vtkMRMLIGTLConnectorNode())
        self.agilentConnectorNode.SetLogErrorIfServerConnectionFailed(False)

        hostNamePort = self.parameterNode.GetParameter(
            'AgilentServerHostNamePort')  # example: "localhost:18944"
        [hostName, port] = hostNamePort.split(':')

        self.agilentConnectorNode.SetTypeClient(hostName, int(port))
        self.agilentConnectorNode.Start()

        self.needleModelTipRadius = 0.0

        # Set up main frame
        self.sliceletDockWidget.setObjectName('EpiGuidePanel')
        self.sliceletDockWidget.setWindowTitle('EpiGuideNav')
        self.mainWindow.setWindowTitle('Epidural injection navigation')

        self.navigationView = self.VIEW_TRIPLE_3D  # should we change to VIEW_ULTRASOUND_3D_3DCHART ???