def registerCustomLayouts(self): Guidelet.registerCustomLayouts(self) layoutLogic = self.layoutManager.layoutLogic() customLayout = ( "<layout type=\"horizontal\" split=\"false\" >" " <item>" " <view class=\"vtkMRMLViewNode\" singletontag=\"1\">" " <property name=\"viewlabel\" action=\"default\">1</property>" " </view>" " </item>" " <item>" " <layout type=\"vertical\" split=\"false\" >" " <item>" " <view class=\"vtkMRMLSliceNode\" singletontag=\"Red\">" " <property name=\"orientation\" action=\"default\">Axial</property>" " <property name=\"viewlabel\" action=\"default\">R</property>" " <property name=\"viewcolor\" action=\"default\">#F34A33</property>" " </view>" " </item>" " <item>" " <view class=\"vtkMRMLViewNode\" singletontag=\"2\">" " <property name=\"viewlabel\" action=\"default\">1</property>" " </view>" " </item>" " </layout>" " </item>" "</layout>") layoutLogic.GetLayoutNode().AddLayoutDescription( self.slice3DChartCustomLayoutId, customLayout)
def setupConnections(self): logging.debug('ScoliUs.setupConnections()') Guidelet.setupConnections(self) self.calibrationCollapsibleButton.connect( 'toggled(bool)', self.onPatientSetupPanelToggled) self.exampleButton.connect('clicked(bool)', self.onExampleButtonClicked)
def disconnect(self): logging.debug('USRegistrationGuidelet.disconnect') Guidelet.disconnect(self) # panels self.ui.captureCollapsibleButton.disconnect('clicked(bool)', self.onCapturePanelToggled) self.ui.registerCollapsibleButton.disconnect( 'clicked(bool)', self.onRegisterPanelToggled) self.ui.segmentCollapsibleButton.disconnect('clicked(bool)', self.onSegmentPanelToggled) # load & segment panel self.ui.loadPatientDataButton.disconnect('clicked(bool)', self.onLoadPatientDataClicked) self.ui.createModelButton.disconnect('clicked(bool)', self.onCreateModelClicked) # capture panel self.ui.deleteSeqButton.disconnect('clicked(bool)', self.onDeleteSeqClicked) self.ui.loadTFModelButton.disconnect('clicked(bool)', self.onLoadTFModelClicked) self.ui.pauseRecButton.disconnect('clicked(bool)', self.onPauseRecClicked) self.ui.startStopRecButton.disconnect('clicked(bool)', self.onStartStopRec) # register panel self.ui.performRegButton.disconnect('clicked(bool)', self.onPerformRegClicked)
def __init__(self, parent, logic, configurationName='Default'): self.calibrationCollapsibleButton = None Guidelet.__init__(self, parent, logic, configurationName) logging.debug('ExampleGuideletGuidelet.__init__') self.logic.addValuesToDefaultConfiguration() moduleDirectoryPath = slicer.modules.exampleguidelet.path.replace( 'ExampleGuidelet.py', '') # Set up main frame. self.sliceletDockWidget.setObjectName('ExampleGuideletPanel') self.sliceletDockWidget.setWindowTitle('Example guidelet') self.mainWindow.setWindowTitle('ExampleGuidelet') self.mainWindow.windowIcon = qt.QIcon( moduleDirectoryPath + '/Resources/Icons/ExampleGuidelet.png') self.setupScene() self.navigationView = self.VIEW_ULTRASOUND_3D # Setting button open on startup. self.calibrationCollapsibleButton.setProperty('collapsed', False)
def __init__(self, parent, logic, configurationName='Default'): # init guidelet Guidelet.__init__(self, parent, logic, configurationName) # module intrinsics self.logic.addValuesToDefaultConfiguration() self.modulePath = os.path.dirname(slicer.modules.usregistration.path) self.moduleTransformsPath = os.path.join(self.modulePath, 'Resources/Transforms') self.moduleModelsPath = os.path.join(self.modulePath, 'Resources/Models') self.moduleIconsPath = os.path.join(self.modulePath, 'Resources/Icons') self.referenceInView = False self.probeInView = False self.stylusInView = False # set up main frame self.sliceletDockWidget.setObjectName('USRegistration') self.sliceletDockWidget.setWindowTitle('Skull US Registration') self.mainWindow.setWindowTitle('Skull US Registration') self.mainWindow.windowIcon = qt.QIcon( os.path.join(self.moduleIconsPath, 'USRegistration.png')) # hide slicer status bar slicer.util.mainWindow().statusBar().hide() # setup self.setupScene() # tool visibility icons self.setupToolWatchdog()
def setupConnections(self): logging.debug('EpiGuide.setupConnections()') Guidelet.setupConnections(self) self.navigationCollapsibleButton.connect('toggled(bool)', self.onNavigationPanelToggled) # Add our own behaviour (in addition to the default behavior) of the Ultrasound record button self.ultrasound.startStopRecordingButton.connect( 'clicked(bool)', self.onStartStopRecordingButtonClicked)
def disconnect(self): # see setupConnections logging.debug('EpiGuide.disconnect()') Guidelet.disconnect(self) # Remove observer self.navigationCollapsibleButton.disconnect( 'toggled(bool)', self.onNavigationPanelToggled) self.ultrasound.startStopRecordingButton.disconnect( 'clicked(bool)', self.onStartStopRecordingButtonClicked)
def disconnect(self): #TODO see connect logging.debug('ScoliUs.disconnect()') Guidelet.disconnect(self) # Remove observer to old parameter node self.calibrationCollapsibleButton.disconnect( 'toggled(bool)', self.onPatientSetupPanelToggled) self.exampleButton.disconnect('clicked(bool)', self.onExampleButtonClicked)
def disconnect(self):#TODO see connect logging.debug('ScoliUs.disconnect()') Guidelet.disconnect(self) # Remove observer to old parameter node if self.patientSLandmarks_Reference and self.patientSLandmarks_ReferenceObserver: self.patientSLandmarks_Reference.RemoveObserver(self.patientSLandmarks_ReferenceObserver) self.patientSLandmarks_ReferenceObserver = None self.calibrationCollapsibleButton.disconnect('toggled(bool)', self.onPatientSetupPanelToggled) self.exampleButton.disconnect('clicked(bool)', self.onExampleButtonClicked)
def disconnect(self): #TODO see connect logging.debug('ScoliUs.disconnect()') Guidelet.disconnect(self) # Remove observer to old parameter node if self.patientSLandmarks_Reference and self.patientSLandmarks_ReferenceObserver: self.patientSLandmarks_Reference.RemoveObserver( self.patientSLandmarks_ReferenceObserver) self.patientSLandmarks_ReferenceObserver = None self.calibrationCollapsibleButton.disconnect( 'toggled(bool)', self.onPatientSetupPanelToggled) self.exampleButton.disconnect('clicked(bool)', self.onExampleButtonClicked)
def __init__(self, parent, logic, configurationName='Default'): Guidelet.__init__(self, parent, logic, configurationName) logging.debug('UltrasoundTrainingSystemGuidelet.__init__') self.logic.addValuesToDefaultConfiguration() # Set default layout name to the simulator training layout self.defaultLayoutName = self.VIEW_US_SIMULATOR_TRAINING # Set up main frame self.sliceletDockWidget.setObjectName('UltrasoundTrainingSystemPanel') self.sliceletDockWidget.setWindowTitle('UltrasoundTrainingSystem') self.mainWindow.setWindowTitle('UltrasoundTrainingSystem') self.selectView(self.VIEW_US_SIMULATOR_TRAINING)
def setupScene(self): #applet specific parameterNode = self.logic.getParameterNode() Guidelet.setupScene(self) moduleDir = os.path.dirname(slicer.modules.usneedleguide.path) # Load transform probeModelToImageFullpath = os.path.join( moduleDir, 'Resources', self.PROBEMODEL_TO_IMAGE_FILENAME) probeModelToImageNode = slicer.mrmlScene.GetFirstNodeByName( self.PROBEMODEL_TO_IMAGE) if probeModelToImageNode is None: probeModelToImageNode = slicer.util.loadTransform( probeModelToImageFullpath) probeModelToImageNode.SetName(self.PROBEMODEL_TO_IMAGE) parameterNode.SetNodeReferenceID(self.PROBEMODEL_TO_IMAGE, probeModelToImageNode.GetID()) # Load models modelFileNames = ['Guide06cm', 'Guide08cm', 'Guide10cm', 'Guide12cm'] for i in range(len(modelFileNames)): modelNode = parameterNode.GetNodeReference(modelFileNames[i]) if modelNode is None: fileName = modelFileNames[i] modelFullpath = os.path.join(moduleDir, 'Resources', fileName + '.vtk') modelNode = slicer.util.loadModel(modelFullpath) displayNode = modelNode.GetDisplayNode() displayNode.SetVisibility(True) displayNode.SetColor(self.GUIDECOLORS[i][0], self.GUIDECOLORS[i][1], self.GUIDECOLORS[i][2]) displayNode.SetSliceIntersectionVisibility(True) displayNode.SetSliceIntersectionThickness(2) modelNode.SetAndObserveTransformNodeID( probeModelToImageNode.GetID()) parameterNode.SetNodeReferenceID(modelFileNames[i], modelNode.GetID()) # Hide slice view annotations (patient name, scale, color bar, etc.) as they # decrease reslicing performance by 20%-100% import DataProbe dataProbeUtil = DataProbe.DataProbeLib.DataProbeUtil() dataProbeParameterNode = dataProbeUtil.getParameterNode() dataProbeParameterNode.SetParameter('showSliceViewAnnotations', '0')
def createFeaturePanels(self): logging.debug('USRegistrationGuidelet.createFeaturePanels') moduleDirectoryPath = slicer.modules.usregistration.path.replace( 'USRegistration.py', '') self.uiWidget = slicer.util.loadUI(moduleDirectoryPath + 'Resources/UI/USRegistration.ui') self.sliceletPanelLayout.addWidget(self.uiWidget) self.ui = slicer.util.childWidgetVariables(self.uiWidget) self.ui.line.setFrameShadow(qt.QFrame.Plain) self.ui.line_2.setFrameShadow(qt.QFrame.Plain) featurePanelList = [ self.ui.captureCollapsibleButton, self.ui.segmentCollapsibleButton, self.ui.registerCollapsibleButton, ] featurePanelList[len(featurePanelList ):] = Guidelet.createFeaturePanels(self) self.sliceletPanelLayout.addItem( qt.QSpacerItem(20, 40, qt.QSizePolicy.Minimum, qt.QSizePolicy.Expanding)) return featurePanelList
def onViewSelect(self, layoutIndex): # Check out layout request first, then pass on to parent to handle the existing ones text = self.viewSelectorComboBox.currentText if text == self.VIEW_ULTRASOUND_3D_3DCHART: # self.layoutManager.setLayout(self.slice3DChartCustomLayoutId) # self.delayedFitUltrasoundImageToView() # (8.30.17) may want to add this, but no change: # self.showUltrasoundIn3dView(True) # ####### this should keep the 2 panel self.layoutManager.setLayout(self.red3dCustomLayoutId) self.delayedFitUltrasoundImageToView() self.showUltrasoundIn3dView(True) # ###### self.populateChart() return Guidelet.onViewSelect(self, layoutIndex)
def setupScene(self): logging.debug('USRegistrationGuidelet.setupScene') Guidelet.setupScene(self) self.setupTransforms() self.setupModels() self.setupTransformTree() self.setupSegmentEditor() # hide slice view annotations (patient name, scale, color bar, etc.) as they # decrease reslicing performance by 20%-100% logging.debug('USRegistrationGuidelet: Hide slice view annotations') import DataProbe dataProbeUtil = DataProbe.DataProbeLib.DataProbeUtil() dataProbeParameterNode = dataProbeUtil.getParameterNode() dataProbeParameterNode.SetParameter('showSliceViewAnnotations', '0')
def setupScene(self): logging.debug('setupScene') Guidelet.setupScene(self) logging.debug('Create transforms') algiaCervicalModuleDataPath = slicer.modules.zalgiacervical.path.replace("zAlgiaCervical.py","") + 'Data/' self.AlgiaCervicalLogic = zAlgiaCervicalLogic() self.AlgiaCervicalLogic.variableSetUp() # 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') # Load head model self.headModel = slicer.util.getNode('head') if not self.headModel: slicer.util.loadModel(algiaCervicalModuleDataPath + 'head.stl') self.headModel = slicer.util.getNode(pattern="head") # Views self.registerCustomLayoutsAlgia() self.layoutManager.setLayout(self.dual3dcuantitativeCustomLayoutId) #Delete Ultrasound created by Guidelet by default scene = slicer.mrmlScene red = scene.GetNodeByID('vtkMRMLSliceNodeRed') red.SetSliceVisible(False)
def __init__(self, parent, logic, configurationName='Default'): Guidelet.__init__(self, parent, logic, configurationName) logging.debug('AlgiaCervicalGuidelet.__init__') #Init del logic zAlgiaCervical # Member variables self.m = vtk.vtkMatrix4x4() self.transform=numpy.zeros((4,4), dtype=numpy.float64) self.observedNode = None self.outputObserverTag = -1 self.record = False self.timerActive=False self.recordingTime_mode1=5 # 5 seconds to record initial position self.recordingTime_mode2=20 # 5 seconds to record initial position self.mode=0 self.myTimer=Timer() self.translation_x=numpy.array([]) self.translation_y=numpy.array([]) self.translation_z=numpy.array([]) self.rotation_x=numpy.array([]) self.rotation_y=numpy.array([]) self.rotation_z=numpy.array([]) self.timeStamp=numpy.array([]) # Set up main frame. self.sliceletDockWidget.setObjectName('AlgiaCervicalPanel') self.sliceletDockWidget.setWindowTitle('AlgiaCervical') self.mainWindow.setWindowTitle('Algia Cervical') #self.mainWindow.windowIcon = qt.QIcon(moduleDirectoryPath + '/Resources/Icons/zAlgiaCervical.png') self.setupScene() #self.showChart() #sliceletPanelLayout = self.sliceletPanelLayout #sliceletPanelLayout.removeWidget(self.ultrasoundCollapsibleButton) # self.ultrasound.cleanup() self.ultrasoundCollapsibleButton.setProperty('collapsed', True) self.ultrasoundCollapsibleButton.setVisible(False) self.advancedCollapsibleButton.setProperty('collapsed', True)
def createFeaturePanels(self): # Create GUI panels. featurePanelList = Guidelet.createFeaturePanels(self) self.navigationCollapsibleButton = ctk.ctkCollapsibleButton() featurePanelList[len(featurePanelList):] = [ self.navigationCollapsibleButton ] return featurePanelList
def createFeaturePanels(self): # Create GUI panels. self.calibrationCollapsibleButton = ctk.ctkCollapsibleButton() self.patientSetupPanel() featurePanelList = Guidelet.createFeaturePanels(self) featurePanelList[len(featurePanelList):] = [self.calibrationCollapsibleButton] return featurePanelList
def createFeaturePanels(self): # Create GUI panels. self.transformsCollapsibleButton = ctk.ctkCollapsibleButton() self.setupMainPanel() featurePanelList = Guidelet.createFeaturePanels(self) #Due to this, Transforms collapsible button can't be collapsed... featurePanelList = [self.transformsCollapsibleButton] return featurePanelList
def createFeaturePanels(self): # Create GUI panels. self.calibrationCollapsibleButton = ctk.ctkCollapsibleButton() self.patientSetupPanel() featurePanelList = Guidelet.createFeaturePanels(self) featurePanelList[len(featurePanelList):] = [ self.calibrationCollapsibleButton ] return featurePanelList
def createFeaturePanels(self): # Create GUI panels. logging.debug('UltrasoundTrainingSystem.createFeaturePanels()') self.LoadSceneCollapsibleButton = ctk.ctkCollapsibleButton() self.SetupLoadSceneCollapsibleButton() featurePanelList = Guidelet.createFeaturePanels(self) featurePanelList[len(featurePanelList):] = [ self.LoadSceneCollapsibleButton ] return featurePanelList
def __init__(self, parent, logic, configurationName='Default'): self.calibrationCollapsibleButton = None Guidelet.__init__(self, parent, logic, configurationName) logging.debug('ExampleGuideletGuidelet.__init__') self.logic.addValuesToDefaultConfiguration() moduleDirectoryPath = slicer.modules.exampleguidelet.path.replace('ExampleGuidelet.py', '') # Set up main frame. self.sliceletDockWidget.setObjectName('ExampleGuideletPanel') self.sliceletDockWidget.setWindowTitle('Example guidelet') self.mainWindow.setWindowTitle('ExampleGuidelet') self.mainWindow.windowIcon = qt.QIcon(moduleDirectoryPath + '/Resources/Icons/ExampleGuidelet.png') self.setupScene() self.navigationView = self.VIEW_ULTRASOUND_3D # Setting button open on startup. self.calibrationCollapsibleButton.setProperty('collapsed', False)
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 ???
def setupScene(self): #applet specific logging.debug('setupScene') ''' ReferenceToRas transform is used in almost all IGT applications. Reference is the coordinate system of a tool fixed to the patient. Tools are tracked relative to Reference, to compensate for patient motion. ReferenceToRas makes sure that everything is displayed in an anatomical coordinate system, i.e. R, A, and S (Right, Anterior, and Superior) directions in Slicer are correct relative to any images or tracked tools displayed. ReferenceToRas is needed for initialization, so we need to set it up before calling Guidelet.setupScene(). ''' self.referenceToRas = slicer.util.getNode('ReferenceToRas') if not self.referenceToRas: self.referenceToRas=slicer.vtkMRMLLinearTransformNode() self.referenceToRas.SetName("ReferenceToRas") m = self.logic.readTransformFromSettings('ReferenceToRas', self.configurationName) if m is None: m = self.logic.createMatrixFromString('1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1') self.referenceToRas.SetMatrixTransformToParent(m) slicer.mrmlScene.AddNode(self.referenceToRas) Guidelet.setupScene(self) # Transforms logging.debug('Create transforms') ''' In this example we assume that there is a tracked needle in the system. The needle is not tracked at its tip, so we need a NeedleTipToNeedle transform to define where the needle tip is. In your application Needle may be called Stylus, or maybe you don't need such a tool at all. ''' self.needleToReference = slicer.util.getNode('NeedleToReference') if not self.needleToReference: self.needleToReference = slicer.vtkMRMLLinearTransformNode() self.needleToReference.SetName('NeedleToReference') slicer.mrmlScene.AddNode(self.needleToReference) self.needleTipToNeedle = slicer.util.getNode('NeedleTipToNeedle') if not self.needleTipToNeedle: self.needleTipToNeedle = slicer.vtkMRMLLinearTransformNode() self.needleTipToNeedle.SetName('NeedleTipToNeedle') m = self.logic.readTransformFromSettings('NeedleTipToNeedle', self.configurationName) if m: self.needleTipToNeedle.SetMatrixTransformToParent(m) slicer.mrmlScene.AddNode(self.needleTipToNeedle) # Models logging.debug('Create models') self.needleModel = slicer.util.getNode('NeedleModel') if not self.needleModel: self.needleModel = slicer.modules.createmodels.logic().CreateNeedle(80, 1.0, 2.5, 0) self.needleModel.SetName('NeedleModel') # Build transform tree logging.debug('Set up transform tree') self.needleToReference.SetAndObserveTransformNodeID(self.referenceToRas.GetID()) self.needleTipToNeedle.SetAndObserveTransformNodeID(self.needleToReference.GetID()) self.needleModel.SetAndObserveTransformNodeID(self.needleTipToNeedle.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')
def setupViewerLayouts(self): Guidelet.setupViewerLayouts(self) # Now we can add our own layout to the drop down list self.viewSelectorComboBox.addItem(self.VIEW_ULTRASOUND_3D_3DCHART)
def preCleanup(self):#common Guidelet.preCleanup(self) logging.debug('preCleanup')
def setupConnections(self): logging.debug('ScoliUs.setupConnections()') Guidelet.setupConnections(self) self.calibrationCollapsibleButton.connect('toggled(bool)', self.onPatientSetupPanelToggled) self.exampleButton.connect('clicked(bool)', self.onExampleButtonClicked)
def disconnect(self): #TODO: see connect logging.debug('UsSimulatorTraining.disconnect()') Guidelet.disconnect(self)
def setupScene(self): #applet specific logging.debug('setupScene') ''' ReferenceToRas transform is used in almost all IGT applications. Reference is the coordinate system of a tool fixed to the patient. Tools are tracked relative to Reference, to compensate for patient motion. ReferenceToRas makes sure that everything is displayed in an anatomical coordinate system, i.e. R, A, and S (Right, Anterior, and Superior) directions in Slicer are correct relative to any images or tracked tools displayed. ReferenceToRas is needed for initialization, so we need to set it up before calling Guidelet.setupScene(). ''' self.referenceToRas = slicer.util.getNode('ReferenceToRas') if not self.referenceToRas: self.referenceToRas = slicer.vtkMRMLLinearTransformNode() self.referenceToRas.SetName("ReferenceToRas") m = self.logic.readTransformFromSettings('ReferenceToRas', self.configurationName) if m is None: m = self.logic.createMatrixFromString( '1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1') self.referenceToRas.SetMatrixTransformToParent(m) slicer.mrmlScene.AddNode(self.referenceToRas) Guidelet.setupScene(self) # Transforms logging.debug('Create transforms') ''' In this example we assume that there is a tracked needle in the system. The needle is not tracked at its tip, so we need a NeedleTipToNeedle transform to define where the needle tip is. In your application Needle may be called Stylus, or maybe you don't need such a tool at all. ''' self.needleToReference = slicer.util.getNode('NeedleToReference') if not self.needleToReference: self.needleToReference = slicer.vtkMRMLLinearTransformNode() self.needleToReference.SetName('NeedleToReference') slicer.mrmlScene.AddNode(self.needleToReference) self.needleTipToNeedle = slicer.util.getNode('NeedleTipToNeedle') if not self.needleTipToNeedle: self.needleTipToNeedle = slicer.vtkMRMLLinearTransformNode() self.needleTipToNeedle.SetName('NeedleTipToNeedle') m = self.logic.readTransformFromSettings('NeedleTipToNeedle', self.configurationName) if m: self.needleTipToNeedle.SetMatrixTransformToParent(m) slicer.mrmlScene.AddNode(self.needleTipToNeedle) # Models logging.debug('Create models') self.needleModel = slicer.util.getNode('NeedleModel') if not self.needleModel: self.needleModel = slicer.modules.createmodels.logic( ).CreateNeedle(80, 1.0, 2.5, 0) self.needleModel.SetName('NeedleModel') # Build transform tree logging.debug('Set up transform tree') self.needleToReference.SetAndObserveTransformNodeID( self.referenceToRas.GetID()) self.needleTipToNeedle.SetAndObserveTransformNodeID( self.needleToReference.GetID()) self.needleModel.SetAndObserveTransformNodeID( self.needleTipToNeedle.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')
def setupConnections(self): logging.debug('UltrasoundTrainingSystem.setupConnections()') Guidelet.setupConnections(self) self.LoadSceneButton.connect('clicked()', self.openLoadSceneDialog)
def disconnect(self): #TODO: see connect logging.debug('UltrasoundTrainingSystem.disconnect()') Guidelet.disconnect(self)
def cleanup(self):#common Guidelet.cleanup(self) logging.debug('cleanup')
def preCleanup(self): #common Guidelet.preCleanup(self) logging.debug('preCleanup')
def cleanup(self): #common Guidelet.cleanup(self) logging.debug('cleanup')
def preCleanup(self): logging.debug('USRegistrationGuidelet.preCleanup') Guidelet.preCleanup(self)
def setupConnections(self): logging.debug('UsSimulatorTraining.setupConnections()') Guidelet.setupConnections(self) self.LoadSceneButton.connect('clicked()', self.openLoadSceneDialog)
def preCleanup(self): Guidelet.preCleanup(self) logging.debug('precleanup')
def setupConnectorNode(self): Guidelet.setupConnectorNode(self) self.connectorNode.SetLogErrorIfServerConnectionFailed(False)
def setupScene(self): #applet specific logging.debug('setupScene') # ReferenceToRas is needed for ultrasound initialization, so we need to # set it up before calling Guidelet.setupScene(). self.referenceToRas = slicer.util.getNode('ReferenceToRas') if not self.referenceToRas: self.referenceToRas=slicer.vtkMRMLLinearTransformNode() self.referenceToRas.SetName("ReferenceToRas") m = self.logic.readTransformFromSettings('ReferenceToRas', self.configurationName) if m is None: # The following line should not be needed. m = self.logic.createMatrixFromString('1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1') self.referenceToRas.SetMatrixTransformToParent(m) slicer.mrmlScene.AddNode(self.referenceToRas) Guidelet.setupScene(self) # Transforms logging.debug('Create transforms') moduleDir = os.path.dirname(slicer.modules.exampleguidelet.path) self.transdToReference = slicer.util.getNode('TransdToReference') if not self.transdToReference: self.transdToReference = slicer.vtkMRMLLinearTransformNode() self.transdToReference.SetName("TransdToReference") m = self.logic.readTransformFromSettings('TransdToReference', self.configurationName) if m: self.transdToReference.SetMatrixTransformToParent(m) slicer.mrmlScene.AddNode(self.transdToReference) self.probeToReference = slicer.util.getNode('ProbeToReference') if not self.probeToReference: self.probeToReference = slicer.vtkMRMLLinearTransformNode() self.probeToReference.SetName("ProbeToReference") slicer.mrmlScene.AddNode(self.probeToReference) self.needleToReference = slicer.util.getNode('NeedleToReference') if not self.needleToReference: self.needleToReference = slicer.vtkMRMLLinearTransformNode() self.needleToReference.SetName('NeedleToReference') slicer.mrmlScene.AddNode(self.needleToReference) self.needleTipToNeedle = slicer.util.getNode('NeedleTipToNeedle') if not self.needleTipToNeedle: self.needleTipToNeedle = slicer.vtkMRMLLinearTransformNode() self.needleTipToNeedle.SetName('NeedleTipToNeedle') m = self.logic.readTransformFromSettings('NeedleTipToNeedle', self.configurationName) if m: self.needleTipToNeedle.SetMatrixTransformToParent(m) slicer.mrmlScene.AddNode(self.needleTipToNeedle) # Models logging.debug('Create models') self.needleModel = slicer.util.getNode('NeedleModel') if not self.needleModel: self.needleModel = slicer.modules.createmodels.logic().CreateNeedle(80, 1.0, 2.5, 0) self.needleModel.SetName('NeedleModel') # Build transform tree logging.debug('Set up transform tree') self.transdToReference.SetAndObserveTransformNodeID(self.referenceToRas.GetID()) self.probeToReference.SetAndObserveTransformNodeID(self.referenceToRas.GetID()) self.needleToReference.SetAndObserveTransformNodeID(self.referenceToRas.GetID()) self.needleTipToNeedle.SetAndObserveTransformNodeID(self.needleToReference.GetID()) self.needleModel.SetAndObserveTransformNodeID(self.needleTipToNeedle.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')
def setupAdvancedPanel(self): Guidelet.setupAdvancedPanel(self) self.registerCustomLayouts()