def setup(self):
    #Se establecen los pasos del flujo de trabajo
    self.StepInicio=simuladorTornillosPedicularesWizard.Inicio('Inicio')
    self.StepRegistro=simuladorTornillosPedicularesWizard.IngresoAlumno('IngresoAlumno')
    self.StepHistoriaClinica=simuladorTornillosPedicularesWizard.HistoriaClinica('HistoriaClinica')
    self.StepModuloPlaneacion=simuladorTornillosPedicularesWizard.ModuloPlaneacion('ModuloPlaneacion')
    self.StepMenuProfesor=simuladorTornillosPedicularesWizard.MenuProfesor('MenuProfesor')
    self.StepCalibracion=simuladorTornillosPedicularesWizard.SimulatorTTPCalibration('SimulatorTTPCalibration')

    steps = [] #Se crea tupla que contenga los pasos del flujo de trabajo
    #Se añade a la tupla cada uno de los pasos del flujo de trabajo
    steps.append(self.StepInicio)

    #Se crea el flujo de trabajo
    self.workflow = ctk.ctkWorkflow()
    workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget.setWorkflow(self.workflow)

    #Se definen las transiciones entre los pasos del flujo de trabajo
    self.workflow.addTransition(self.StepInicio, self.StepRegistro,'1', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.StepInicio, self.StepHistoriaClinica,'2', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.StepInicio, self.StepMenuProfesor,'3', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.StepHistoriaClinica, self.StepModuloPlaneacion)
    self.workflow.addTransition(self.StepModuloPlaneacion,self.StepCalibracion)

    self.workflow.start()
    workflowWidget.visible = True
    self.layout.addWidget( workflowWidget ) 
 def setup(self):
     self.workflow = ctk.ctkWorkflow()
     
   
     workflowWidget = ctk.ctkWorkflowStackedWidget()
     workflowWidget.setWorkflow(self.workflow)
   
     steps = []
   
     steps.append(StenosisDetectorWizard.InputStep('Input'))
     steps.append(StenosisDetectorWizard.VesselnessFilterStep('Vesselness Filter'))
     steps.append(StenosisDetectorWizard.LevelSetSegmentationStep('Level Set Segmentation'))
 #    steps.append(OptimizationStep('Optimization'))
     steps.append(StenosisDetectorWizard.CenterlineComputationStep('Centerline Computation'))
     steps.append(StenosisDetectorWizard.VisualizationStep('Detect Stenosis'))
     
     logic = SlicerVmtk4CommonLib.StenosisDetectorLogic()
   
     # Add transition associated to steps
     for i in range(len(steps) - 1):
       steps[i].setLogic(logic)
       self.workflow.addTransition(steps[i], steps[i + 1])
   
     self.workflow.start()
   
     workflowWidget.visible = True
     self.layout.addWidget(workflowWidget)    
示例#3
0
    def setup(self):
        '''
    Create and start the EMSegment workflow.
    '''

        # Use the logic associated with the module
        if not self.__logic:
            self.__logic = self.parent.module().logic()

        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.onMRMLSceneChanged)

        workflow = ctk.ctkWorkflow()

        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(workflow)

        # Create all wizard steps
        step1 = EMSegmentWizard.EMSegmentQuickStep1(Helper.GetNthStepId(2))
        step2 = EMSegmentWizard.EMSegmentQuickStep2(Helper.GetNthStepId(3))
        step3 = EMSegmentWizard.EMSegmentQuickStep3(Helper.GetNthStepId(7))
        step4 = EMSegmentWizard.EMSegmentQuickStep4(Helper.GetNthStepId(9))
        step5 = EMSegmentWizard.EMSegmentQuickStep5(Helper.GetNthStepId(11))
        segmentStep = EMSegmentWizard.EMSegmentQuickSegmentationStep(
            Helper.GetNthStepId(10))

        # Add the wizard steps to an array for convenience
        allSteps = []

        allSteps.append(step1)
        allSteps.append(step2)
        allSteps.append(step3)
        allSteps.append(step4)
        allSteps.append(step5)
        allSteps.append(segmentStep)

        # Add transitions
        for i in range(0, len(allSteps) - 1):
            workflow.addTransition(allSteps[i], allSteps[i + 1])

        # Propagate the workflow, the logic and the MRML Manager to the steps
        for s in allSteps:
            s.setLogic(self.__logic)
            s.setMRMLManager(self.__logic.GetMRMLManager())

        # Disable the error text which showed up when jumping to the (invisible) segment step
        workflowWidget.workflowGroupBox().errorTextEnabled = False
        workflow.goBackToOriginStepUponSuccess = False

        slicer.modules.emsegmenteasystep1 = step1
        slicer.modules.emsegmenteasystep2 = step2

        # Start the workflow and show the widget
        workflow.start()
        workflowWidget.visible = True
        self.parent.layout().addWidget(workflowWidget)

        # Keep track of workflow and workflowWidget references
        self.__workflow = workflow
        self.__workflowWidget = workflowWidget
  def setup( self ):
    '''
    Create and start the EMSegment workflow.
    '''

    # Use the logic associated with the module
    if not self.__logic:
      self.__logic = self.parent.module().logic()

    self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)', self.onMRMLSceneChanged)

    workflow = ctk.ctkWorkflow()

    workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget.setWorkflow( workflow )


    # Create all wizard steps
    step1 = EMSegmentWizard.EMSegmentQuickStep1( Helper.GetNthStepId( 2 ) )
    step2 = EMSegmentWizard.EMSegmentQuickStep2( Helper.GetNthStepId( 3 ) )
    step3 = EMSegmentWizard.EMSegmentQuickStep3( Helper.GetNthStepId( 7 ) )
    step4 = EMSegmentWizard.EMSegmentQuickStep4( Helper.GetNthStepId( 9 ) )
    step5 = EMSegmentWizard.EMSegmentQuickStep5( Helper.GetNthStepId( 11 ) )
    segmentStep = EMSegmentWizard.EMSegmentQuickSegmentationStep( Helper.GetNthStepId( 10 ) )

    # Add the wizard steps to an array for convenience
    allSteps = []

    allSteps.append( step1 )
    allSteps.append( step2 )
    allSteps.append( step3 )
    allSteps.append( step4 )
    allSteps.append( step5 )
    allSteps.append( segmentStep )

    # Add transitions
    for i in range( 0, len( allSteps ) - 1 ):
      workflow.addTransition( allSteps[i], allSteps[i + 1] )

    # Propagate the workflow, the logic and the MRML Manager to the steps
    for s in allSteps:
      s.setLogic( self.__logic )
      s.setMRMLManager( self.__logic.GetMRMLManager() )

    # Disable the error text which showed up when jumping to the (invisible) segment step
    workflowWidget.workflowGroupBox().errorTextEnabled = False
    workflow.goBackToOriginStepUponSuccess = False

    slicer.modules.emsegmenteasystep1 = step1
    slicer.modules.emsegmenteasystep2 = step2

    # Start the workflow and show the widget
    workflow.start()
    workflowWidget.visible = True
    self.parent.layout().addWidget( workflowWidget )

    # Keep track of workflow and workflowWidget references
    self.__workflow = workflow
    self.__workflowWidget = workflowWidget
 def setup( self ):
     self.workflow = ctk.ctkWorkflow()
     
     workflowWidget = ctk.ctkWorkflowStackedWidget()
     workflowWidget.setWorkflow( self.workflow )
     
     # create all 4 wizard steps
     self.selectDataStep = LASegmentationResources.LASegmentationWorkflowSelectDataStep( 'SelectData' )
     self.registrationStep = LASegmentationResources.LASegmentationWorkflowImageRegistrationStep( 'ImageRegistration' )
     self.endoSegStep = LASegmentationResources.LASegmentationWorkflowEndoSegmentationStep( 'LAEndoSegmentation' )
     
     # add the wizard steps to an array for convenience
     allSteps = []
     
     allSteps.append( self.selectDataStep )
     allSteps.append( self.registrationStep )
     allSteps.append( self.endoSegStep )        
     
     self.workflow.addTransition( self.selectDataStep, self.registrationStep )
     self.workflow.addTransition( self.registrationStep, self.endoSegStep )
     
     nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')
     
     self.parameterNode = None
     
     for n in xrange(nNodes):
         compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
         nodeid = None
         if compNode.GetModuleName() == 'LASegmentationWorkflow':
             self.parameterNode = compNode
             print 'Found existing LASegmentationWorkflow parameter node'
             break
     
     if self.parameterNode == None:
         self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
         self.parameterNode.SetModuleName('LASegmentationWorkflow')
         slicer.mrmlScene.AddNode(self.parameterNode)
     
     for s in allSteps:
         s.setParameterNode (self.parameterNode)
     
     # restore workflow step
     currentStep = self.parameterNode.GetParameter('currentStep')
     if currentStep != '':
         print 'Restoring workflow step to ', currentStep
         if currentStep == 'SelectData':
             self.workflow.setInitialStep(self.selectDataStep)
         if currentStep == 'ImageRegistration':
             self.workflow.setInitialStep(self.registrationStep)
         if currentStep == 'LAEndoSegmentation':
             self.workflow.setInitialStep(self.endoSegStep)
     else:
         print 'currentStep in parameter node is empty!'
     
     # Start the workflow and show the widget
     self.workflow.start()
     workflowWidget.visible = True
     self.layout.addWidget( workflowWidget )
示例#6
0
    def setup(self):

        self.Step1 = Flujos.Step1('Step1')
        self.Step0 = Flujos.Step0('Step0')
        self.Step2 = Flujos.Step2('Step2')
        self.Step3 = Flujos.Step3('Step3')
        self.Step4 = Flujos.Step4('Step4')
        self.Step5 = Flujos.Step5('Step5')
        self.Step6 = Flujos.Step6('Step6')
        self.Step7 = Flujos.Step7('Step7')
        self.Step8 = Flujos.Step8('Step8')
        self.Step9 = Flujos.Step9('Step9')
        self.Step10 = Flujos.Step10('Step10')

        steps = []
        steps.append(self.Step1)
        steps.append(self.Step0)
        steps.append(self.Step2)
        steps.append(self.Step3)
        steps.append(self.Step4)
        steps.append(self.Step5)
        steps.append(self.Step6)
        steps.append(self.Step7)
        steps.append(self.Step8)
        steps.append(self.Step9)
        steps.append(self.Step10)

        self.workflow = ctk.ctkWorkflow()
        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(self.workflow)

        self.workflow.addTransition(self.Step1, self.Step2, 'pass',
                                    ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.Step1, self.Step3, 'fail',
                                    ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.Step1, self.Step0, 'Reg',
                                    ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.Step3, self.Step4)
        self.workflow.addTransition(self.Step2, self.Step5)
        self.workflow.addTransition(self.Step5, self.Step6, 'pass',
                                    ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.Step5, self.Step7, 'fail',
                                    ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.Step4, self.Step8, '1',
                                    ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.Step4, self.Step9, '2',
                                    ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.Step4, self.Step10, '3',
                                    ctk.ctkWorkflow.Bidirectional)

        self.workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget(workflowWidget)
示例#7
0
  def setup(self):

    self.Step1 = Flujos.Step1('Step1')
    self.Step0 = Flujos.Step0('Step0')
    self.Step2 = Flujos.Step2('Step2')
    self.Step3 = Flujos.Step3('Step3')
    self.Step4 = Flujos.Step4('Step4')
    self.Step5 = Flujos.Step5('Step5')
    self.Step6 = Flujos.Step6('Step6')
    self.Step7 = Flujos.Step7('Step7')
    self.Step8 = Flujos.Step8('Step8')
    self.Step9 = Flujos.Step9('Step9')
    self.Step10 = Flujos.Step10('Step10')

    steps = []
    steps.append(self.Step1)
    steps.append(self.Step0)
    steps.append(self.Step2)
    steps.append(self.Step3)
    steps.append(self.Step4)
    steps.append(self.Step5)
    steps.append(self.Step6)
    steps.append(self.Step7)
    steps.append(self.Step8)
    steps.append(self.Step9)
    steps.append(self.Step10)

    self.workflow = ctk.ctkWorkflow()
    workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget.setWorkflow(self.workflow)
    
    self.workflow.addTransition(self.Step1, self.Step2, 'pass', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.Step1, self.Step3, 'fail', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.Step1, self.Step0, 'Reg', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.Step3, self.Step4)
    self.workflow.addTransition(self.Step2, self.Step5)
    self.workflow.addTransition(self.Step5, self.Step6, 'pass', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.Step5, self.Step7, 'fail', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.Step4, self.Step8, '1', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.Step4, self.Step9, '2', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition(self.Step4, self.Step10, '3', ctk.ctkWorkflow.Bidirectional )  
    
    self.workflow.start()
    workflowWidget.visible = True
    self.layout.addWidget( workflowWidget )   
 def setup(self):
     self.workflow = ctk.ctkWorkflow()
     
   
     workflowWidget = ctk.ctkWorkflowStackedWidget()
     workflowWidget.setWorkflow(self.workflow)
   
     steps = []
   
     steps.append(ExampleStep('step1'))
     steps.append(ExampleStep('step2'))
     steps.append(ExampleStep('step3'))
   
     # Add transition associated to steps
     for i in range(len(steps) - 1):
       self.workflow.addTransition(steps[i], steps[i + 1])
   
     self.workflow.start()
   
     workflowWidget.visible = True
     self.layout.addWidget(workflowWidget)    
    def setup(self):
        #Se establecen los pasos del flujo de trabajo
        self.StepInicio = simuladorTornillosPedicularesWizard.Inicio('Inicio')
        self.StepRegistro = simuladorTornillosPedicularesWizard.IngresoAlumno(
            'IngresoAlumno')
        self.StepHistoriaClinica = simuladorTornillosPedicularesWizard.HistoriaClinica(
            'HistoriaClinica')
        self.StepModuloPlaneacion = simuladorTornillosPedicularesWizard.ModuloPlaneacion(
            'ModuloPlaneacion')
        self.StepMenuProfesor = simuladorTornillosPedicularesWizard.MenuProfesor(
            'MenuProfesor')
        self.StepCalibracion = simuladorTornillosPedicularesWizard.SimulatorTTPCalibration(
            'SimulatorTTPCalibration')

        steps = []  #Se crea tupla que contenga los pasos del flujo de trabajo
        #Se añade a la tupla cada uno de los pasos del flujo de trabajo
        steps.append(self.StepInicio)

        #Se crea el flujo de trabajo
        self.workflow = ctk.ctkWorkflow()
        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(self.workflow)

        #Se definen las transiciones entre los pasos del flujo de trabajo
        self.workflow.addTransition(self.StepInicio, self.StepRegistro, '1',
                                    ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.StepInicio, self.StepHistoriaClinica,
                                    '2', ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.StepInicio, self.StepMenuProfesor,
                                    '3', ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.StepHistoriaClinica,
                                    self.StepModuloPlaneacion)
        self.workflow.addTransition(self.StepModuloPlaneacion,
                                    self.StepCalibracion)

        self.workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget(workflowWidget)
    def setup(self):
        '''
    Create and start the ChangeTracker workflow.
    '''
        self.workflow = ctk.ctkWorkflow()

        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(self.workflow)

        # create all wizard steps
        self.selectScansStep = ChangeTrackerWizard.ChangeTrackerSelectScansStep(
            'SelectScans')
        self.defineROIStep = ChangeTrackerWizard.ChangeTrackerDefineROIStep(
            'DefineROI')
        self.segmentROIStep = ChangeTrackerWizard.ChangeTrackerSegmentROIStep(
            'SegmentROI')
        self.analyzeROIStep = ChangeTrackerWizard.ChangeTrackerAnalyzeROIStep(
            'AnalyzeROI')
        self.reportROIStep = ChangeTrackerWizard.ChangeTrackerReportROIStep(
            'ReportROI')

        # add the wizard steps to an array for convenience
        allSteps = []

        allSteps.append(self.selectScansStep)
        allSteps.append(self.defineROIStep)
        allSteps.append(self.segmentROIStep)
        allSteps.append(self.analyzeROIStep)
        allSteps.append(self.reportROIStep)

        # Add transition for the first step which let's the user choose between simple and advanced mode
        self.workflow.addTransition(self.selectScansStep, self.defineROIStep)
        self.workflow.addTransition(self.defineROIStep, self.segmentROIStep)
        self.workflow.addTransition(self.segmentROIStep, self.analyzeROIStep)
        self.workflow.addTransition(self.analyzeROIStep, self.reportROIStep)

        nNodes = slicer.mrmlScene.GetNumberOfNodesByClass(
            'vtkMRMLScriptedModuleNode')

        self.parameterNode = None
        for n in xrange(nNodes):
            compNode = slicer.mrmlScene.GetNthNodeByClass(
                n, 'vtkMRMLScriptedModuleNode')
            nodeid = None
            if compNode.GetModuleName() == 'ChangeTracker':
                self.parameterNode = compNode
                print 'Found existing ChangeTracker parameter node'
                break
        if self.parameterNode == None:
            self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
            self.parameterNode.SetModuleName('ChangeTracker')
            slicer.mrmlScene.AddNode(self.parameterNode)

        for s in allSteps:
            s.setParameterNode(self.parameterNode)

        # restore workflow step
        currentStep = self.parameterNode.GetParameter('currentStep')
        if currentStep != '':
            print 'Restoring workflow step to ', currentStep
            if currentStep == 'SelectScans':
                self.workflow.setInitialStep(self.selectScansStep)
            if currentStep == 'DefineROI':
                self.workflow.setInitialStep(self.defineROIStep)
            if currentStep == 'SegmentROI':
                self.workflow.setInitialStep(self.segmentROIStep)
            if currentStep == 'AnalyzeROI':
                self.workflow.setInitialStep(self.analyzeROIStep)
            if currentStep == 'ReportROI':
                self.workflow.setInitialStep(self.reportROIStep)
        else:
            print 'currentStep in parameter node is empty!'

        # start the workflow and show the widget
        self.workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget(workflowWidget)
示例#11
0
  def __init__(self, widgetClass=None):
    self.parent = qt.QFrame()
    self.parent.setLayout(qt.QHBoxLayout())
    
    self.moduleLogic = StylusBasedUSProbeCalibrationLogic()
    

    # TODO: should have way to pop up python interactor
    self.leftFrame = qt.QFrame(self.parent)
    self.leftFrame.setLayout(qt.QVBoxLayout())
    
    
    self.parent.layout().addWidget(self.leftFrame, 1)
    
    
    self.layoutSelectorFrame2 = qt.QFrame(self.parent)
    self.layoutSelectorFrame2.setLayout(qt.QHBoxLayout())
    self.leftFrame.layout().addWidget(self.layoutSelectorFrame2)

    self.layoutSelectorLabel2 = qt.QLabel("Layout Selector: ", self.layoutSelectorFrame2)
    self.layoutSelectorLabel2.setToolTip("Select the layout ...")
    self.layoutSelectorFrame2.layout().addWidget(self.layoutSelectorLabel2)

    self.layoutSelector2 = qt.QComboBox(self.layoutSelectorFrame2)
    self.layoutSelector2.addItem("FourViews")
    self.layoutSelector2.addItem("3D View")
    self.layoutSelector2.addItem("One view")
    self.layoutSelector2.addItem("Double 3D View")
    self.layoutSelectorFrame2.layout().addWidget(self.layoutSelector2)
    self.layoutSelector2.connect('activated(int)', self.onLayoutSelect)
    
    self.resetViewButton = qt.QPushButton("Reset")
    self.layoutSelectorFrame2.layout().addWidget(self.resetViewButton)
    self.resetViewButton.connect('clicked()', self.moduleLogic.onResetView)
    
    self.layoutWidget = slicer.qMRMLLayoutWidget()
    self.layoutWidget.setMRMLScene(slicer.mrmlScene)
    
    # self.layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUp3DView)
    # self.layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)   
    # self.layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutTabbedSliceView)
    #### Some of the possible layouts
    # SlicerLayout3DPlusLightboxView SlicerLayoutCompareGridView SlicerLayoutCompareWidescreenView SlicerLayoutConventionalQuantitativeView SlicerLayoutConventionalView SlicerLayoutConventionalWidescreenView
    # SlicerLayoutCustomView SlicerLayoutDefaultView SlicerLayoutOneUp3DView SlicerLayoutOneUpRedSliceView SlicerLayoutOneUpGreenSliceView SlicerLayoutOneUpYellowSliceView SlicerLayoutDual3DView 
    # SlicerLayoutFourOverFourView SlicerLayoutTabbedSliceView 
    self.layoutWidget.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalView)
    
    self.parent.layout().addWidget(self.layoutWidget, 2)
    

    self.toolsViewer = ToolsViewer()
    self.toolsViewer.setModuleLogic(self.moduleLogic)
    # self.toolsViewer.listenToScene()
    
    
    # item=qt.QListWidgetItem("unItem")
    # self.modelsViewer.addItem(item)
    self.leftFrame.layout().addWidget(self.toolsViewer.getToolsWidget(), 1)
    '''
    Create and start the USGuided workflow.
    '''
    self.workflow = ctk.ctkWorkflow()

    self.workflowWidget = ctk.ctkWorkflowStackedWidget()
    self.workflowWidget.setWorkflow(self.workflow)
    
    bw = self.workflowWidget.buttonBoxWidget()
    bw.hideInvalidButtons = True
    
    
    groupBox = self.workflowWidget.workflowGroupBox()
    groupBox.errorTextEnabled = False

    #bw.nextButtonDefaultText = ""
    #bw.backButtonDefaultText = ""
    
    nextButton=bw.nextButton()
    backButton=bw.backButton()
    nextButton.text=""
    backButton.text=""
  
    self.leftFrame.layout().addWidget(self.workflowWidget, 8)
    

    # create all wizard steps
    self.connectToTrackerStep = StylusBasedUSProbeCalibrationWizard.ConnectToTrackerStep('ConnectToTracker')
    self.connectToTrackerStep.setModuleLogic(self.moduleLogic)
    self.connectToTrackerStep.setButtonBoxWidget(bw)
    self.connectToTrackerStep.setToolsViewer(self.toolsViewer)
    self.placeStylusTipInTheImageStep = StylusBasedUSProbeCalibrationWizard.PlaceStylusTipInTheImageStep('PlaceStylusTipInTheImage')
    self.placeStylusTipInTheImageStep.setModuleLogic(self.moduleLogic)
    self.placeStylusTipInTheImageStep.setButtonBoxWidget(bw)
    self.captureSpatialPositionsStep = StylusBasedUSProbeCalibrationWizard.CaptureSpatialPositionsStep('CaptureSpatialPositions')
    self.captureSpatialPositionsStep.setModuleLogic(self.moduleLogic)
    self.captureSpatialPositionsStep.setButtonBoxWidget(bw)
    self.registrationStep = StylusBasedUSProbeCalibrationWizard.RegistrationStep('Registration')
    self.registrationStep.setModuleLogic(self.moduleLogic)
    self.registrationStep.setButtonBoxWidget(bw)


    # add the wizard steps to an array for convenience
    allSteps = []



    allSteps.append(self.connectToTrackerStep)
    allSteps.append(self.captureSpatialPositionsStep)
    allSteps.append(self.placeStylusTipInTheImageStep)
    allSteps.append(self.registrationStep)

    # Add transition for the first step which let's the user choose between simple and advanced mode
    self.workflow.addTransition(self.connectToTrackerStep, self.captureSpatialPositionsStep)
    self.workflow.addTransition(self.captureSpatialPositionsStep, self.placeStylusTipInTheImageStep)
    self.workflow.addTransition(self.placeStylusTipInTheImageStep, self.registrationStep)
 
    nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')

    self.parameterNode = None
    for n in xrange(nNodes):
      compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
      nodeid = None
      if compNode.GetModuleName() == 'StylusBasedUSProbeCalibration':
        self.parameterNode = compNode
        print 'Found existing StylusBasedUSProbeCalibration parameter node'
        break
    if self.parameterNode == None:
      self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
      self.parameterNode.SetModuleName('StylusBasedUSProbeCalibration')
      slicer.mrmlScene.AddNode(self.parameterNode)
 
    for s in allSteps:
        s.setParameterNode (self.parameterNode)

    # restore workflow step
    currentStep = self.parameterNode.GetParameter('currentStep')
    if currentStep != '':
      print 'Restoring workflow step to ', currentStep
      if currentStep == 'ConnectToTracker':
        self.workflow.setInitialStep(self.connectToTrackerStep)
      if currentStep == 'PlaceStylusInTheImage':
        self.workflow.setInitialStep(self.placeStylusInTheImageStep)
      if currentStep == 'CaptureSpatialPositions':
        self.workflow.setInitialStep(self.captureSpatialPositionsStep)
      if currentStep == 'Registration':
        self.workflow.setInitialStep(self.registrationStep)
    else:
      print 'currentStep in parameter node is empty!'
        
    # start the workflow and show the widget
    self.workflow.start()
    self.workflowWidget.visible = True
    
    
    if widgetClass:
      self.widget = widgetClass(self.parent)
    self.parent.show()
    def setup(self):
        '''
    Define a workflow with the necessary steps.
    '''

        self.workflow = ctk.ctkWorkflow()

        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(self.workflow)

        workflowWidget.buttonBoxWidget().nextButtonDefaultText = ""
        workflowWidget.buttonBoxWidget().backButtonDefaultText = ""

        # Create all wizard steps
        selectVolumesStep = MRIChangeDetectorWizard.SelectVolumesStep(
            'SelectVolumes')
        registrationStep = MRIChangeDetectorWizard.RegistrationStep(
            'Registration')
        #quantificationStep = MRIChangeDetectorWizard.QuantificationStep('Quantification')

        # add the wizard steps to an array for convenience
        allSteps = []

        allSteps.append(selectVolumesStep)
        allSteps.append(registrationStep)
        #allSteps.append(quantificationStep)

        # Add transition for the first step which let's the user choose between simple and advanced mode
        self.workflow.addTransition(selectVolumesStep, registrationStep)
        #self.workflow.addTransition( registrationStep, quantificationStep)

        nNodes = slicer.mrmlScene.GetNumberOfNodesByClass(
            'vtkMRMLScriptedModuleNode')

        self.parameterNode = None
        for n in xrange(nNodes):
            compNode = slicer.mrmlScene.GetNthNodeByClass(
                n, 'vtkMRMLScriptedModuleNode')
            nodeid = None
            if compNode.GetModuleName() == 'MRIChangeDetector':
                self.parameterNode = compNode
                print 'Found existing MRIChangeDetector parameter node'
                break
        if self.parameterNode == None:
            self.parameterNode = slicer.mrmlScene.CreateNodeByClass(
                'vtkMRMLScriptedModuleNode')
            self.parameterNode.SetModuleName('MRIChangeDetector')
            slicer.mrmlScene.AddNode(self.parameterNode)

        # Propagate the workflow, the logic and the MRML Manager to the steps
        for s in allSteps:
            s.setWorkflow(self.workflow)
            s.setParameterNode(self.parameterNode)

        # restore workflow step
        currentStep = self.parameterNode.GetParameter('currentStep')
        if currentStep != '':
            print 'Restoring workflow step to ', currentStep
            if currentStep == 'SelectVolumes':
                self.workflow.setInitialStep(selectVolumesStep)
            if currentStep == 'Registration':
                self.workflow.setInitialStep(registrationStep)
            #if currentStep == 'Quantification':
            #  self.workflow.setInitialStep(quantificationStep)
        else:
            print 'currentStep in parameter node is empty!'

        # start the workflow and show the widget
        self.workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget(workflowWidget)
示例#13
0
    def setup(self):
        '''
    Create and start the EMSegment workflow.
    '''

        # Use the logic associated with the module
        if not self.__logic:
            self.__logic = self.parent.module().logic()

        self.parent.connect('mrmlSceneChanged(vtkMRMLScene*)',
                            self.onMRMLSceneChanged)

        workflow = ctk.ctkWorkflow()

        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(workflow)

        workflowWidget.buttonBoxWidget().nextButtonDefaultText = ""
        workflowWidget.buttonBoxWidget().backButtonDefaultText = ""

        # create all wizard steps
        selectTaskStep = EMSegmentWizard.EMSegmentSelectTaskStep(
            Helper.GetNthStepId(1))
        defineInputChannelsSimpleStep = EMSegmentWizard.EMSegmentDefineInputChannelsStep(
            Helper.GetNthStepId(2) + 'Simple')  # simple branch
        defineInputChannelsAdvancedStep = EMSegmentWizard.EMSegmentDefineInputChannelsStep(
            Helper.GetNthStepId(2) + 'Advanced')  # advanced branch
        defineAnatomicalTreeStep = EMSegmentWizard.EMSegmentDefineAnatomicalTreeStep(
            Helper.GetNthStepId(3))
        defineAtlasStep = EMSegmentWizard.EMSegmentDefineAtlasStep(
            Helper.GetNthStepId(4))
        editRegistrationParametersStep = EMSegmentWizard.EMSegmentEditRegistrationParametersStep(
            Helper.GetNthStepId(5))
        definePreprocessingStep = EMSegmentWizard.EMSegmentDefinePreprocessingStep(
            Helper.GetNthStepId(6))
        specifyIntensityDistributionStep = EMSegmentWizard.EMSegmentSpecifyIntensityDistributionStep(
            Helper.GetNthStepId(7))
        editNodeBasedParametersStep = EMSegmentWizard.EMSegmentEditNodeBasedParametersStep(
            Helper.GetNthStepId(8))
        miscStep = EMSegmentWizard.EMSegmentDefineMiscParametersStep(
            Helper.GetNthStepId(9))
        segmentStep = EMSegmentWizard.EMSegmentStartSegmentationStep(
            Helper.GetNthStepId(10))
        statisticsStep = EMSegmentWizard.EMSegmentLabelStatisticsStep(
            Helper.GetNthStepId(11))

        # add the wizard steps to an array for convenience
        allSteps = []

        allSteps.append(selectTaskStep)
        allSteps.append(defineInputChannelsSimpleStep)
        allSteps.append(defineInputChannelsAdvancedStep)
        allSteps.append(defineAnatomicalTreeStep)
        allSteps.append(defineAtlasStep)
        allSteps.append(editRegistrationParametersStep)
        allSteps.append(definePreprocessingStep)
        allSteps.append(specifyIntensityDistributionStep)
        allSteps.append(editNodeBasedParametersStep)
        allSteps.append(miscStep)
        allSteps.append(statisticsStep)
        allSteps.append(segmentStep)

        # Add transition for the first step which let's the user choose between simple and advanced mode
        workflow.addTransition(selectTaskStep, defineInputChannelsSimpleStep,
                               'SimpleMode')
        workflow.addTransition(selectTaskStep, defineInputChannelsAdvancedStep,
                               'AdvancedMode')

        # Add transitions associated to the simple mode
        workflow.addTransition(defineInputChannelsSimpleStep,
                               defineAnatomicalTreeStep)

        # Add transitions associated to the advanced mode
        workflow.addTransition(defineInputChannelsAdvancedStep,
                               defineAnatomicalTreeStep)

        # .. add transitions for the rest of the advanced mode steps
        for i in range(3, len(allSteps) - 1):
            workflow.addTransition(allSteps[i], allSteps[i + 1])

        # Propagate the workflow, the logic and the MRML Manager to the steps
        for s in allSteps:
            s.setLogic(self.__logic)
            s.setMRMLManager(self.__logic.GetMRMLManager())

        # Disable the error text which showed up when jumping to the (invisible) segment step
        workflowWidget.workflowGroupBox().errorTextEnabled = False
        workflow.goBackToOriginStepUponSuccess = False

        # start the workflow and show the widget
        workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget(workflowWidget)

        # enable global access to the dynamicFrames on step 2 and step 6
        slicer.modules.emsegmentLogic = self.__logic
        slicer.modules.emsegmentSimpleDynamicFrame = defineInputChannelsSimpleStep.dynamicFrame(
        )
        slicer.modules.emsegmentPreprocessingStep = definePreprocessingStep

        # Keep track of workflow and workflowWidget references
        self.__workflow = workflow
        self.__workflowWidget = workflowWidget
  def setup(self):
    '''
    Define a workflow with the necessary steps.
    '''
    
    self.workflow = ctk.ctkWorkflow()
    
    workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget.setWorkflow(self.workflow)

    workflowWidget.buttonBoxWidget().nextButtonDefaultText = ""
    workflowWidget.buttonBoxWidget().backButtonDefaultText = ""
    
    # Create all wizard steps
    selectVolumesStep = TMRIChangeDetectorWizard.SelectVolumesStep('SelectVolumes')
    registrationStep = TMRIChangeDetectorWizard.RegistrationStep('Registration')
    quantificationStep = TMRIChangeDetectorWizard.QuantificationStep('Quantification')

    # add the wizard steps to an array for convenience
    allSteps = []

    allSteps.append(selectVolumesStep)
    allSteps.append(registrationStep)
    allSteps.append(quantificationStep)

    # Add transition for the first step which let's the user choose between simple and advanced mode
    self.workflow.addTransition( selectVolumesStep, registrationStep)
    self.workflow.addTransition( registrationStep, quantificationStep)

    nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')

    self.parameterNode = None
    for n in xrange(nNodes):
      compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
      nodeid = None
      if compNode.GetModuleName() == 'TMRIChangeDetector':
        self.parameterNode = compNode
        print 'Found existing TMRIChangeDetector parameter node'
        break
    if self.parameterNode == None:
      self.parameterNode = slicer.mrmlScene.CreateNodeByClass('vtkMRMLScriptedModuleNode')
      self.parameterNode.SetModuleName('TMRIChangeDetector')
      slicer.mrmlScene.AddNode(self.parameterNode)
 
    # Propagate the workflow, the logic and the MRML Manager to the steps
    for s in allSteps:
        s.setWorkflow(self.workflow)
        s.setParameterNode(self.parameterNode)

    # restore workflow step
    currentStep = self.parameterNode.GetParameter('currentStep')
    if currentStep != '':
      print 'Restoring workflow step to ', currentStep
      if currentStep == 'SelectVolumes':
        self.workflow.setInitialStep(selectVolumesStep)
      if currentStep == 'Registration':
        self.workflow.setInitialStep(registrationStep)
      if currentStep == 'Quantification':
        self.workflow.setInitialStep(quantificationStep)
    else:
      print 'currentStep in parameter node is empty!'
        
    # start the workflow and show the widget
    self.workflow.start()
    workflowWidget.visible = True
    self.layout.addWidget(workflowWidget)
    def setup( self ):

        """ Slicer seems to call all methods of these classes upon entry. setup creates
            a workflow from ctk, which simply means that it creates a series of UI
            steps one can traverse with "next" / "previous" buttons. The steps themselves
            are contained within SegmentationWizard_Lib.
        """

        # Currently unclear on the difference between ctkWorkflow and
        # ctkWorkflowStackedWidget, but presumably the latter creates a UI
        # for the former.
        self.workflow = ctk.ctkWorkflow()
        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow( self.workflow )

        # Create workflow steps.
        self.Step1 = SegmentationWizard_Lib.VolumeSelectStep('VolumeSelectStep')
        self.Step2 = SegmentationWizard_Lib.RegistrationStep('RegistrationStep')
        self.Step3 = SegmentationWizard_Lib.NormalizeSubtractStep('NormalizeSubtractStep')
        self.Step4 = SegmentationWizard_Lib.ROIStep('ROIStep')
        self.Step5 = SegmentationWizard_Lib.ThresholdStep('ThresholdStep')
        self.Step6 = SegmentationWizard_Lib.ReviewStep('ReviewStep')

        # Add the wizard steps to an array for convenience. Much of the following code
        # is copied wholesale from ChangeTracker.
        allSteps = []
        allSteps.append( self.Step1 )
        allSteps.append( self.Step2 )
        allSteps.append( self.Step3 )
        allSteps.append( self.Step4 )
        allSteps.append( self.Step5 )
        allSteps.append( self.Step6 )

        # Adds transition functionality between steps.
        self.workflow.addTransition(self.Step1, self.Step2)
        self.workflow.addTransition(self.Step2, self.Step3)
        self.workflow.addTransition(self.Step3, self.Step4)
        self.workflow.addTransition(self.Step4, self.Step5)
        self.workflow.addTransition(self.Step5, self.Step6)
        self.workflow.addTransition(self.Step6, self.Step1)

        """ The following code creates a 'parameter node' from the vtkMRMLScriptedModuleNode class. 
            A parameter node keeps track of module variables from step to step, in the case of
            ctkWorkflow, and when users leave the module to visit other modules. The code below
            searches to see if a parameter node already exists for SegmentationWizard among all
            available parameter nodes, and then creates one if it does not.
        """
        nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')
        self.parameterNode = None
        for n in xrange(nNodes):
            compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
            nodeid = None
            if compNode.GetModuleName() == 'SegmentationWizard':
                self.parameterNode = compNode
                # print 'Found existing SegmentationWizard parameter node'
                break
        if self.parameterNode == None:
            self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
            self.parameterNode.SetModuleName('SegmentationWizard')
            slicer.mrmlScene.AddNode(self.parameterNode)

        # Individual workflow steps need to remember the parameter node too.
        for s in allSteps:
            s.setParameterNode(self.parameterNode)

        # Restores you to the correct step if you leave and then return to the module.
        currentStep = self.parameterNode.GetParameter('currentStep')
        if currentStep != '':
            # print 'Restoring SegmentationWizard workflow step to ', currentStep
            if currentStep == 'VolumeSelectStep':
                self.workflow.setInitialStep(self.Step1)
            if currentStep == 'RegistrationStep':
                self.workflow.setInitialStep(self.Step2)
            if currentStep == 'NormalizeSubtractStep':
                self.workflow.setInitialStep(self.Step3)
            if currentStep == 'ROIStep':
                self.workflow.setInitialStep(self.Step4)
            if currentStep == 'ThresholdStep':
                self.workflow.setInitialStep(self.Step4)
            if currentStep == 'ReviewStep':
                self.workflow.setInitialStep(self.Step4)
        else:
            # print 'currentStep in parameter node is empty!'
            pass

        # Starts and show the workflow.
        self.workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget( workflowWidget )
    def setup(self):
        """ Slicer seems to call all methods of these classes upon entry. setup creates
			a workflow from ctk, which simply means that it creates a certies of UI
			steps one can traverse with "next" / "previous" buttons. The steps themselves
			are contained within ContrastSubtractionWizard.
		"""
        # Currently unclear on the difference between ctkWorkflow and
        # ctkWorkflowStackedWidget, but presumably the latter creates a UI
        # for the former
        self.workflow = ctk.ctkWorkflow()
        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(self.workflow)

        # Create workflow steps.
        self.Step1 = ContrastSubtractionWizard.VolumeSelectStep(
            'VolumeSelectStep')
        self.Step2 = ContrastSubtractionWizard.RegistrationStep(
            'RegistrationStep')
        self.Step3 = ContrastSubtractionWizard.NormalizeSubtractStep(
            'NormalizeSubtractStep')
        self.Step4 = ContrastSubtractionWizard.ROIStep('ROIStep')
        self.Step5 = ContrastSubtractionWizard.ThresholdStep('ThresholdStep')
        self.Step6 = ContrastSubtractionWizard.ReviewStep('ReviewStep')

        # Add the wizard steps to an array for convenience. Much of the following code
        # is copied wholesale from ChangeTracker.
        allSteps = []
        allSteps.append(self.Step1)
        allSteps.append(self.Step2)
        allSteps.append(self.Step3)
        allSteps.append(self.Step4)
        allSteps.append(self.Step5)
        allSteps.append(self.Step6)

        # Adds transition functionality between steps.
        self.workflow.addTransition(self.Step1, self.Step2)
        self.workflow.addTransition(self.Step2, self.Step3)
        self.workflow.addTransition(self.Step3, self.Step4)
        self.workflow.addTransition(self.Step4, self.Step5)
        self.workflow.addTransition(self.Step5, self.Step6)
        self.workflow.addTransition(self.Step6, self.Step1)

        # The following code creates a so-called parameter node referencing the
        # vtkMRMLScriptedModuleNode class, while checking to make sure one doesn't
        # already exist for some reason. This node keeps track of changse to MRML scene.
        nNodes = slicer.mrmlScene.GetNumberOfNodesByClass(
            'vtkMRMLScriptedModuleNode')
        self.parameterNode = None
        for n in xrange(nNodes):
            compNode = slicer.mrmlScene.GetNthNodeByClass(
                n, 'vtkMRMLScriptedModuleNode')
            nodeid = None
            if compNode.GetModuleName() == 'ContrastSubtraction':
                self.parameterNode = compNode
                print 'Found existing ContrastSubtraction parameter node'
                break
        if self.parameterNode == None:
            self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
            self.parameterNode.SetModuleName('ContrastSubtraction')
            slicer.mrmlScene.AddNode(self.parameterNode)

        # Individual steps get access to the parameter node too!
        for s in allSteps:
            s.setParameterNode(self.parameterNode)

        # Restores workflow step in case something goes wrong.
        currentStep = self.parameterNode.GetParameter('currentStep')
        if currentStep != '':
            print 'Restoring workflow step to ', currentStep
            if currentStep == 'VolumeSelectStep':
                self.workflow.setInitialStep(self.Step1)
            if currentStep == 'RegistrationStep':
                self.workflow.setInitialStep(self.Step2)
            if currentStep == 'NormalizeSubtractStep':
                self.workflow.setInitialStep(self.Step3)
            if currentStep == 'ROIStep':
                self.workflow.setInitialStep(self.Step4)
            if currentStep == 'ThresholdStep':
                self.workflow.setInitialStep(self.Step4)
            if currentStep == 'ReviewStep':
                self.workflow.setInitialStep(self.Step4)
        else:
            print 'currentStep in parameter node is empty!'

        # Starts and show the workflow.
        self.workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget(workflowWidget)
示例#17
0
  def __init__(self, widgetClass=None):
    self.parent = qt.QFrame()
    self.parent.setLayout( qt.QHBoxLayout() )
    
    self.moduleLogic = USGuidedProcedureLogic()
    

    # TODO: should have way to pop up python interactor
    self.leftFrame = qt.QFrame(self.parent)
    self.leftFrame.setLayout( qt.QVBoxLayout() )
    #self.leftFrame.setSizePolicy(qt.QSizePolicy.Maximum,qt.QSizePolicy.Maximum)
    #self.leftFrame.setSizePolicy(qt.QSizePolicy.MinimumExpanding,qt.QSizePolicy.MinimumExpanding)
    
    #self.parent.setStyleSheet(
    #"QFrame{background: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #eef, stop: 1 #ccf); background-color: qlineargradient(spread:pad, x1:0.989, y1:0.012, x2:0, y2:0, stop:0 rgba(223, 227, 255, 255), stop:0.494318 rgba(164, 157, 194, 255), stop:1 rgba(115, 115, 115, 255));}"
    #"QComboBox{color: white; background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #88d, stop: 0.1 #99e, stop: 0.49 #77c, stop: 0.5 #66b, stop: 1 #77c); border-width: 1px; border-color: #339; border-style: solid; border-radius: 7; padding: 3px; font-size: 12px; font-weight: bold; padding-left: 5px; padding-right: 5px; /*min-width: 50px;*/ max-width: 150px; /*min-height: 13px;*/ max-height: 150px; }"     "QPushButton{color: white; background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #88d, stop: 0.1 #99e, stop: 0.49 #77c, stop: 0.5 #66b, stop: 1 #77c); border-width: 1px; border-color: #339; border-style: solid; border-radius: 7; padding: 3px;  font-size: 12px; font-weight: bold; padding-left: 5px; padding-right: 5px; min-width: 20px; max-width: 150px; min-height: 20px; max-height: 40px;}"
    #"QLabel{color: white; background-color: rgba(255, 255, 255, 0);}"
    #    "QSlider::groove:horizontal{border: 1px solid #bbb;background: white;height: 10px;border-radius: 4px;}" 
    #    "QSlider::sub-page:horizontal {background: qlineargradient(x1: 0, y1: 0,    x2: 0, y2: 1,    stop: 0 #66e, stop: 1 #bbf);background:qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,    stop: 0 #bbf, stop: 1 #55f);border: 1px solid #777;height: 10px;border-radius:4px;}"
    #    "QSlider::add-page:horizontal {background: #fff;border: 1px solid #777;height: 10px;border-radius: 4px;}"
    #    "QSlider::handle:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:1,    stop:0 #eee, stop:1 #ccc);border: 1px solid #777;width: 13px;margin-top: -2px;margin-bottom: -2px;border-radius: 4px;}"
    #    "QSlider::handle:horizontal:hover {background: qlineargradient(x1:0, y1:0, x2:1, y2:1,    stop:0 #fff, stop:1 #ddd);border: 1px solid#444;border-radius: 4px;}"
    #    "QSlider::sub-page:horizontal:disabled {background: #bbb;border-color: #999;}"
    #    "QSlider::add-page:horizontal:disabled {background: #eee;border-color: #999;}"
    #    "QSlider::handle:horizontal:disabled {background: #eee;border: 1px solid #aaa;border-radius: 4px;}")
    
    self.parent.layout().addWidget(self.leftFrame,1)
    
    self.addDataButton = qt.QPushButton("Add Data")
    self.leftFrame.layout().addWidget(self.addDataButton)
    self.addDataButton.connect("clicked()",slicer.app.ioManager().openAddDataDialog)
    
    self.saveSceneButton = qt.QPushButton("Save Data")
    self.leftFrame.layout().addWidget(self.saveSceneButton)
    self.saveSceneButton.connect("clicked()",slicer.app.ioManager().openSaveDataDialog)
    #self.loadSceneButton = qt.QPushButton("Load Scene")
    #self.leftFrame.layout().addWidget(self.loadSceneButton)
    #self.loadSceneButton.connect("clicked()",slicer.app.ioManager().openLoadSceneDialog)
    
    
    self.layoutSelectorFrame2 = qt.QFrame(self.parent)
    self.layoutSelectorFrame2.setLayout(qt.QHBoxLayout())
    self.leftFrame.layout().addWidget(self.layoutSelectorFrame2)

    self.layoutSelectorLabel2 = qt.QLabel("Layout Selector: ", self.layoutSelectorFrame2)
    self.layoutSelectorLabel2.setToolTip( "Select the layout ...")
    self.layoutSelectorFrame2.layout().addWidget(self.layoutSelectorLabel2)

    self.layoutSelector2 = qt.QComboBox(self.layoutSelectorFrame2)
    self.layoutSelector2.addItem("FourViews")
    self.layoutSelector2.addItem("3D View")
    self.layoutSelector2.addItem("One view")
    self.layoutSelector2.addItem("Double 3D View")
    self.layoutSelectorFrame2.layout().addWidget(self.layoutSelector2)
    self.layoutSelector2.connect('activated(int)', self.onLayoutSelect)
    
    self.resetViewButton = qt.QPushButton("R")
    self.layoutSelectorFrame2.layout().addWidget(self.resetViewButton)
    self.resetViewButton.connect('clicked()', self.moduleLogic.onResetView)
    
    self.layoutWidget = slicer.qMRMLLayoutWidget()
    self.layoutWidget.setMRMLScene(slicer.mrmlScene)
    
    #self.layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUp3DView)
    #self.layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUpRedSliceView)   
    #self.layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutTabbedSliceView)
    #### Some of the possible layouts
    #SlicerLayout3DPlusLightboxView SlicerLayoutCompareGridView SlicerLayoutCompareWidescreenView SlicerLayoutConventionalQuantitativeView SlicerLayoutConventionalView SlicerLayoutConventionalWidescreenView
    #SlicerLayoutCustomView SlicerLayoutDefaultView SlicerLayoutOneUp3DView SlicerLayoutOneUpRedSliceView SlicerLayoutOneUpGreenSliceView SlicerLayoutOneUpYellowSliceView SlicerLayoutDual3DView 
    #SlicerLayoutFourOverFourView SlicerLayoutTabbedSliceView 
    self.layoutWidget.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutConventionalView)
    
    self.parent.layout().addWidget(self.layoutWidget,2)
    
    
    print("Previous line of the Constructor of ModelsViewer")
    self.modelsViewer = ModelsViewer()
    self.modelsViewer.setModuleLogic(self.moduleLogic)
    self.modelsViewer.listenToScene()
    self.volumeRenderingViewer = VolumeRenderingViewer()
    self.volumeRenderingViewer.setModuleLogic(self.moduleLogic)
    self.volumeRenderingViewer.listenToScene()
    #item=qt.QListWidgetItem("unItem")
    #self.modelsViewer.addItem(item)
    self.leftFrame.layout().addWidget(self.modelsViewer.getListWidget(),1)
    self.leftFrame.layout().addWidget(self.volumeRenderingViewer.getListWidget(),1)
    '''
    Create and start the USGuided workflow.
    '''
    self.workflow = ctk.ctkWorkflow()

    self.workflowWidget = ctk.ctkWorkflowStackedWidget()
    self.workflowWidget.setWorkflow( self.workflow )
    
    bw=self.workflowWidget.buttonBoxWidget()
    bw.hideInvalidButtons=True
    
    
    groupBox=self.workflowWidget.workflowGroupBox()
    groupBox.errorTextEnabled = False

    self.workflowWidget.buttonBoxWidget().nextButtonDefaultText = ""
    self.workflowWidget.buttonBoxWidget().backButtonDefaultText = ""
    self.leftFrame.layout().addWidget( self.workflowWidget,3 )
    

    # create all wizard steps
    self.loadSceneStep = USGuidedWizard.LoadSceneStep('LoadScene')
    self.loadSceneStep.setModuleLogic(self.moduleLogic)
    self.loadSceneStep.setButtonBoxWidget(bw)
    self.connectToTrackerStep =  USGuidedWizard.ConnectToTrackerStep('ConnectToTracker')
    self.connectToTrackerStep.setModuleLogic(self.moduleLogic)
    self.connectToTrackerStep.setButtonBoxWidget(bw)
    self.placeImageFiducialsStep =  USGuidedWizard.PlaceImageFiducialsStep( 'PlaceImageFiducials')
    self.placeImageFiducialsStep.setModuleLogic(self.moduleLogic)
    self.placeImageFiducialsStep.setButtonBoxWidget(bw)
    self.placeSpatialFiducialsStep =  USGuidedWizard.PlaceSpatialFiducialsStep( 'PlaceSpatialFiducials')
    self.placeSpatialFiducialsStep.setModuleLogic(self.moduleLogic)
    self.placeSpatialFiducialsStep.setButtonBoxWidget(bw)
    self.registrationStep =  USGuidedWizard.RegistrationStep( 'Registration')
    self.registrationStep.setModuleLogic(self.moduleLogic)
    self.registrationStep.setButtonBoxWidget(bw)
    self.navigationStep =  USGuidedWizard.NavigationStep( 'Navigation')
    self.navigationStep.setModuleLogic(self.moduleLogic)
    self.navigationStep.setButtonBoxWidget(bw)
    #self.selectScansStep = USGuidedWizard.ChangeTrackerSelectScansStep( 'SelectScans'  )
    #self.defineROIStep = USGuidedWizard.ChangeTrackerDefineROIStep( 'DefineROI'  )
    #self.segmentROIStep = USGuidedWizard.ChangeTrackerSegmentROIStep( 'SegmentROI'  )
    #self.analyzeROIStep = USGuidedWizard.ChangeTrackerAnalyzeROIStep( 'AnalyzeROI'  )
    #self.reportROIStep = USGuidedWizard.ChangeTrackerReportROIStep( 'ReportROI'  )
    

    # add the wizard steps to an array for convenience
    allSteps = []

    allSteps.append( self.loadSceneStep )
    allSteps.append( self.connectToTrackerStep )
    allSteps.append( self.placeImageFiducialsStep )
    allSteps.append( self.placeSpatialFiducialsStep )
    allSteps.append( self.registrationStep )
    allSteps.append( self.navigationStep )
    #allSteps.append( self.selectScansStep )
    #allSteps.append( self.defineROIStep )
    #allSteps.append( self.segmentROIStep )
    #allSteps.append( self.analyzeROIStep )
    #allSteps.append( self.reportROIStep )

    # Add transition for the first step which let's the user choose between simple and advanced mode
    self.workflow.addTransition( self.loadSceneStep, self.connectToTrackerStep )
    self.workflow.addTransition( self.connectToTrackerStep, self.placeImageFiducialsStep )
    self.workflow.addTransition( self.placeImageFiducialsStep, self.placeSpatialFiducialsStep )
    self.workflow.addTransition( self.placeSpatialFiducialsStep, self.registrationStep )
    self.workflow.addTransition( self.registrationStep, self.navigationStep )
    #self.workflow.addTransition( self.placeImageFiducials, self.selectScansStep )  
    #self.workflow.addTransition( self.selectScansStep, self.defineROIStep )
    #self.workflow.addTransition( self.defineROIStep, self.segmentROIStep )
    #self.workflow.addTransition( self.segmentROIStep, self.analyzeROIStep )
    #self.workflow.addTransition( self.analyzeROIStep, self.reportROIStep )

    nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')

    self.parameterNode = None
    for n in xrange(nNodes):
      compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
      nodeid = None
      if compNode.GetModuleName() == 'USGuidedProcedure':
        self.parameterNode = compNode
        print 'Found existing USGuidedProcedure parameter node'
        break
    if self.parameterNode == None:
      self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
      self.parameterNode.SetModuleName('USGuidedProcedure')
      slicer.mrmlScene.AddNode(self.parameterNode)
 
    for s in allSteps:
        s.setParameterNode (self.parameterNode)

    # restore workflow step
    currentStep = self.parameterNode.GetParameter('currentStep')
    if currentStep != '':
      print 'Restoring workflow step to ', currentStep
      if currentStep == 'LoadScene':
        self.workflow.setInitialStep(self.loadSceneStep)
      if currentStep == 'ConnectToTracker':
        self.workflow.setInitialStep(self.connectToTrackerStep)
      if currentStep == 'PlaceImageFiducials':
        self.workflow.setInitialStep(self.placeImageFiducialsStep)
      if currentStep == 'PlaceSpatialFiducials':
        self.workflow.setInitialStep(self.placeSpatialFiducialsStep)
      if currentStep == 'Registration':
        self.workflow.setInitialStep(self.registrationStep)
      if currentStep == 'Navigation':
        self.workflow.setInitialStep(self.navigationStep)
      #if currentStep == 'SelectScans':
      #  self.workflow.setInitialStep(self.selectScansStep)
      #if currentStep == 'DefineROI':
      #  self.workflow.setInitialStep(self.defineROIStep)
      #if currentStep == 'SegmentROI':
      #  self.workflow.setInitialStep(self.segmentROIStep)
      #if currentStep == 'AnalyzeROI':
      #  self.workflow.setInitialStep(self.analyzeROIStep)
      #if currentStep == 'ReportROI':
      #  self.workflow.setInitialStep(self.reportROIStep)
    else:
      print 'currentStep in parameter node is empty!'
        
    # start the workflow and show the widget
    self.workflow.start()
    self.workflowWidget.visible = True
    
    if widgetClass:
      self.widget = widgetClass(self.parent)
      self.widget.setup()
    self.parent.show()
示例#18
0
  def setup(self):

    self.level = 0
    self.workflow = ctk.ctkWorkflow(self.parent)

    #workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget = ctk.ctkWorkflowWidget()

    workflowWidget.setWorkflow( self.workflow )
    self.workflowWidget = workflowWidget
    self.Settings = None

    workflowWidget.buttonBoxWidget().hideInvalidButtons = True
    workflowWidget.buttonBoxWidget().hideGoToButtons = True
    workflowWidget.buttonBoxWidget().backButtonFormat = '[<-]{back:#}"/"{!#}") "{back:name}(back:description)'
    workflowWidget.buttonBoxWidget().nextButtonFormat = '{next:#}"/"{!#}") "{next:name}(next:description)[->]'
    workflowWidget.workflowGroupBox().titleFormat = '[current:icon]{#}"/"{!#}") "{current:name}'
    workflowWidget.workflowGroupBox().hideWidgetsOfNonCurrentSteps = True

    #Creating each step of the workflow
    self.steps = [Widgets.InitialStep(),
                  Widgets.LoadDataStep(),
                  Widgets.ResampleStep(),
                  Widgets.RegisterStep(),
                  Widgets.SegmentationStep(),
                  Widgets.VesselEnhancementStep(),
                  Widgets.VesselExtractionStep(),
                 ]
    i = 0
    for step in self.steps:
      # \todo: b) steps should be able to access the workflow widget automatically
      step.Workflow = self
      # \todo: f) have an option to setup all the gui at startup
      step.createUserInterface()

      #Connecting the created steps of the workflow
      if i != 0:
        self.workflow.addTransition(self.steps[i-1], self.steps[i])
      i += 1

    self.layout.addWidget(workflowWidget)

    # Settings
    self.Settings = self.loadUi('WorkflowSettingsPanel.ui')

    # Display settings
    opacitySlider = self.findWidget(self.Settings, 'OpacityRatioDoubleSlider')
    opacitySlider.connect('valueChanged(double)', self.setOpacityRatio)
    self.setOpacityRatio(opacitySlider.value)

    # Hide and disable until step 1 is validated
    self.setDisplaySettingsVisible(False)
    self.setDisplaySettingsEnabled(False)

    # Advanced settings
    levelComboBox = self.findWidget(self.Settings, 'WorkflowLevelComboBox')
    levelComboBox.connect('currentIndexChanged(int)', self.setWorkflowLevel)
    self.setWorkflowLevel(levelComboBox.currentIndex)

    self.reloadButton = self.findWidget(self.Settings, 'ReloadPushButton')
    self.reloadButton.connect('clicked()', self.reloadModule)

    # Add CLI progress bar
    self.CLIProgressBar = slicer.qSlicerCLIProgressBar()
    self.CLIProgressBar.setStatusVisibility(self.CLIProgressBar.VisibleAfterCompletion)
    self.CLIProgressBar.setProgressVisibility(self.CLIProgressBar.HiddenWhenIdle)
    self.Settings.layout().insertWidget(1, self.CLIProgressBar) # insert after spacer

    # Insert settings before workflow's buttons
    collapsibleGroupBox = self.findWidget(self.workflowWidget.workflowGroupBox(), 'CollapsibleButton')
    collapsibleGroupBox.layout().addWidget(self.Settings)

    # Init naming and jsons.
    self.step('Initial').onPresetSelected()

    # Starting and showing the module in layout
    self.workflow.start()
示例#19
0
    def setup(self):

        self.level = 0
        self.workflow = ctk.ctkWorkflow(self.parent)

        #workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget = ctk.ctkWorkflowWidget()

        workflowWidget.setWorkflow(self.workflow)
        self.workflowWidget = workflowWidget
        self.Settings = None

        workflowWidget.buttonBoxWidget().hideInvalidButtons = True
        workflowWidget.buttonBoxWidget().hideGoToButtons = True
        workflowWidget.buttonBoxWidget(
        ).backButtonFormat = '[<-]{back:#}"/"{!#}") "{back:name}(back:description)'
        workflowWidget.buttonBoxWidget(
        ).nextButtonFormat = '{next:#}"/"{!#}") "{next:name}(next:description)[->]'
        workflowWidget.workflowGroupBox(
        ).titleFormat = '[current:icon]{#}"/"{!#}") "{current:name}'
        workflowWidget.workflowGroupBox().hideWidgetsOfNonCurrentSteps = True

        #Creating each step of the workflow
        self.steps = [
            Widgets.InitialStep(),
            Widgets.LoadDataStep(),
            Widgets.ResampleStep(),
            Widgets.RegisterStep(),
            Widgets.SegmentationStep(),
            Widgets.VesselEnhancementStep(),
            Widgets.VesselExtractionStep(),
        ]
        i = 0
        for step in self.steps:
            # \todo: b) steps should be able to access the workflow widget automatically
            step.Workflow = self
            # \todo: f) have an option to setup all the gui at startup
            step.createUserInterface()

            #Connecting the created steps of the workflow
            if i != 0:
                self.workflow.addTransition(self.steps[i - 1], self.steps[i])
            i += 1

        self.layout.addWidget(workflowWidget)

        # Settings
        self.Settings = self.loadUi('WorkflowSettingsPanel.ui')

        # Display settings
        opacitySlider = self.findWidget(self.Settings,
                                        'OpacityRatioDoubleSlider')
        opacitySlider.connect('valueChanged(double)', self.setOpacityRatio)
        self.setOpacityRatio(opacitySlider.value)

        # Hide and disable until step 1 is validated
        self.setDisplaySettingsVisible(False)
        self.setDisplaySettingsEnabled(False)

        # Advanced settings
        levelComboBox = self.findWidget(self.Settings, 'WorkflowLevelComboBox')
        levelComboBox.connect('currentIndexChanged(int)',
                              self.setWorkflowLevel)
        self.setWorkflowLevel(levelComboBox.currentIndex)

        self.reloadButton = self.findWidget(self.Settings, 'ReloadPushButton')
        self.reloadButton.connect('clicked()', self.reloadModule)

        # Add CLI progress bar
        self.CLIProgressBar = slicer.qSlicerCLIProgressBar()
        self.CLIProgressBar.setStatusVisibility(
            self.CLIProgressBar.VisibleAfterCompletion)
        self.CLIProgressBar.setProgressVisibility(
            self.CLIProgressBar.HiddenWhenIdle)
        self.Settings.layout().insertWidget(
            1, self.CLIProgressBar)  # insert after spacer

        # Insert settings before workflow's buttons
        collapsibleGroupBox = self.findWidget(
            self.workflowWidget.workflowGroupBox(), 'CollapsibleButton')
        collapsibleGroupBox.layout().addWidget(self.Settings)

        # Init naming and jsons.
        self.step('Initial').onPresetSelected()

        # Starting and showing the module in layout
        self.workflow.start()
	def setup( self ):

		""" Slicer seems to call all methods of these classes upon entry. setup creates
			a workflow from ctk, which simply means that it creates a certies of UI
			steps one can traverse with "next" / "previous" buttons. The steps themselves
			are contained within ContrastSubtractionWizard.
		"""

		# Currently unclear on the difference between ctkWorkflow and
		# ctkWorkflowStackedWidget, but presumably the latter creates a UI
		# for the former
		self.workflow = ctk.ctkWorkflow()
		workflowWidget = ctk.ctkWorkflowStackedWidget()
		workflowWidget.setWorkflow( self.workflow )

		# Create workflow steps.
		self.Step1 = ContrastSubtractionWizard.VolumeSelectStep('VolumeSelectStep')
		self.Step2 = ContrastSubtractionWizard.RegistrationStep('RegistrationStep')
		self.Step3 = ContrastSubtractionWizard.NormalizeSubtractStep('NormalizeSubtractStep')
		self.Step4 = ContrastSubtractionWizard.ROIStep('ROIStep')
		self.Step5 = ContrastSubtractionWizard.ThresholdStep('ThresholdStep')
		self.Step6 = ContrastSubtractionWizard.ReviewStep('ReviewStep')

		# Add the wizard steps to an array for convenience. Much of the following code
		# is copied wholesale from ChangeTracker.
		allSteps = []
		allSteps.append( self.Step1 )
		allSteps.append( self.Step2 )
		allSteps.append( self.Step3 )
		allSteps.append( self.Step4 )
		allSteps.append( self.Step5 )
		allSteps.append( self.Step6 )

		# Adds transition functionality between steps.
		self.workflow.addTransition(self.Step1, self.Step2)
		self.workflow.addTransition(self.Step2, self.Step3)
		self.workflow.addTransition(self.Step3, self.Step4)
		self.workflow.addTransition(self.Step4, self.Step5)
		self.workflow.addTransition(self.Step5, self.Step6)

		# The following code creates a so-called parameter node referencing the
		# vtkMRMLScriptedModuleNode class, while checking to make sure one doesn't
		# already exist for some reason. This node keeps track of changse to MRML scene.
		nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')
		self.parameterNode = None
		for n in xrange(nNodes):
			compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
			nodeid = None
			if compNode.GetModuleName() == 'ContrastSubtraction':
				self.parameterNode = compNode
				print 'Found existing ContrastSubtraction parameter node'
				break
		if self.parameterNode == None:
			self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
			self.parameterNode.SetModuleName('ContrastSubtraction')
			slicer.mrmlScene.AddNode(self.parameterNode)

		# Individual steps get access to the parameter node too!
		for s in allSteps:
				s.setParameterNode (self.parameterNode)

		# Restores workflow step in case something goes wrong.
		currentStep = self.parameterNode.GetParameter('currentStep')
		if currentStep != '':
			print 'Restoring workflow step to ', currentStep
			if currentStep == 'VolumeSelectStep':
				self.workflow.setInitialStep(self.Step1)
			if currentStep == 'RegistrationStep':
				self.workflow.setInitialStep(self.Step2)
			if currentStep == 'NormalizeSubtractStep':
				self.workflow.setInitialStep(self.Step3)
			if currentStep == 'ROIStep':
				self.workflow.setInitialStep(self.Step4)
			if currentStep == 'ThresholdStep':
				self.workflow.setInitialStep(self.Step4)
			if currentStep == 'ReviewStep':
				self.workflow.setInitialStep(self.Step4)
		else:
			print 'currentStep in parameter node is empty!'

		# Starts and show the workflow.
		self.workflow.start()
		workflowWidget.visible = True
		self.layout.addWidget( workflowWidget )
示例#21
0
  def setup( self ):
    '''
    Create and start the EMSegment workflow.
    '''
    self.workflow = ctk.ctkWorkflow()

    workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget.setWorkflow( self.workflow )

    workflowWidget.buttonBoxWidget().nextButtonDefaultText = ""
    workflowWidget.buttonBoxWidget().backButtonDefaultText = ""

    # create all wizard steps
    selectTaskStep = EMSegmentWizard.EMSegmentSelectTaskStep( Helper.GetNthStepId( 1 ) )
    defineInputChannelsSimpleStep = EMSegmentWizard.EMSegmentDefineInputChannelsStep( Helper.GetNthStepId( 2 ) + 'Simple' ) # simple branch
    defineInputChannelsAdvancedStep = EMSegmentWizard.EMSegmentDefineInputChannelsStep( Helper.GetNthStepId( 2 ) + 'Advanced' ) # advanced branch
    defineAnatomicalTreeStep = EMSegmentWizard.EMSegmentDefineAnatomicalTreeStep( Helper.GetNthStepId( 3 ) )
    defineAtlasStep = EMSegmentWizard.EMSegmentDefineAtlasStep( Helper.GetNthStepId( 4 ) )
    editRegistrationParametersStep = EMSegmentWizard.EMSegmentEditRegistrationParametersStep( Helper.GetNthStepId( 5 ) )
    definePreprocessingStep = EMSegmentWizard.EMSegmentDefinePreprocessingStep( Helper.GetNthStepId( 6 ) )
    specifyIntensityDistributionStep = EMSegmentWizard.EMSegmentSpecifyIntensityDistributionStep( Helper.GetNthStepId( 7 ) )
    editNodeBasedParametersStep = EMSegmentWizard.EMSegmentEditNodeBasedParametersStep( Helper.GetNthStepId( 8 ) )
    miscStep = EMSegmentWizard.EMSegmentDefineMiscParametersStep( Helper.GetNthStepId( 9 ) )
    segmentStep = EMSegmentWizard.EMSegmentStartSegmentationStep( Helper.GetNthStepId( 10 ) )

    # add the wizard steps to an array for convenience
    allSteps = []

    allSteps.append( selectTaskStep )
    allSteps.append( defineInputChannelsSimpleStep )
    allSteps.append( defineInputChannelsAdvancedStep )
    allSteps.append( defineAnatomicalTreeStep )
    allSteps.append( defineAtlasStep )
    allSteps.append( editRegistrationParametersStep )
    allSteps.append( definePreprocessingStep )
    allSteps.append( specifyIntensityDistributionStep )
    allSteps.append( editNodeBasedParametersStep )
    allSteps.append( miscStep )
    allSteps.append( segmentStep )

    # Add transition for the first step which let's the user choose between simple and advanced mode
    self.workflow.addTransition( selectTaskStep, defineInputChannelsSimpleStep, 'SimpleMode' )
    self.workflow.addTransition( selectTaskStep, defineInputChannelsAdvancedStep, 'AdvancedMode' )

    # Add transitions associated to the simple mode
    self.workflow.addTransition( defineInputChannelsSimpleStep, defineAnatomicalTreeStep )

    # Add transitions associated to the advanced mode
    self.workflow.addTransition( defineInputChannelsAdvancedStep, defineAnatomicalTreeStep )

    # .. add transitions for the rest of the advanced mode steps
    for i in range( 3, len( allSteps ) - 1 ):
      self.workflow.addTransition( allSteps[i], allSteps[i + 1] )

    # Propagate the workflow, the logic and the MRML Manager to the steps
    for s in allSteps:
        s.setWorkflow( self.workflow )
        s.setLogic( self.logic() )
        s.setMRMLManager( self.mrmlManager() )

    # disable the error text which showed up when jumping to the (invisible) segment step
    workflowWidget.workflowGroupBox().errorTextEnabled = False

    # start the workflow and show the widget
    self.workflow.start()
    workflowWidget.visible = True
    self.layout.addWidget( workflowWidget )

    # enable global access to the dynamicFrames on step 2 and step 6
    slicer.modules.emsegmentSimpleDynamicFrame = defineInputChannelsSimpleStep.dynamicFrame()
    slicer.modules.emsegmentAdvancedDynamicFrame = definePreprocessingStep.dynamicFrame()
    slicer.modules.emsegmentPreprocessingStep = definePreprocessingStep
  def setup( self ):
    '''
    Create and start the workflow.
    '''
    self.workflow = ctk.ctkWorkflow()

    workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget.setWorkflow( self.workflow )

    # create all wizard steps
    self.loadDataStep = PedicleScrewSimulatorWizard_v3.LoadDataStep( 'LoadData'  )
    self.defineROIStep = PedicleScrewSimulatorWizard_v3.DefineROIStep( 'DefineROI'  )
    self.measurementsStep = PedicleScrewSimulatorWizard_v3.MeasurementsStep( 'Measurements'  )
    self.landmarksStep = PedicleScrewSimulatorWizard_v3.LandmarksStep( 'Landmarks' )
    self.screwStep = PedicleScrewSimulatorWizard_v3.ScrewStep( 'Screw' )
    self.gradeStep = PedicleScrewSimulatorWizard_v3.GradeStep( 'Grade' )
    self.endStep = PedicleScrewSimulatorWizard_v3.EndStep( 'Final'  )
    
    # add the wizard steps to an array for convenience
    allSteps = []

    allSteps.append( self.loadDataStep )
    allSteps.append( self.defineROIStep )
    allSteps.append( self.landmarksStep)
    allSteps.append( self.measurementsStep )
    allSteps.append( self.screwStep)
    allSteps.append( self.gradeStep)
    allSteps.append( self.endStep )
    
    
    # Add transition 
    # Check if volume is loaded
    self.workflow.addTransition( self.loadDataStep, self.defineROIStep )
    
    self.workflow.addTransition( self.defineROIStep, self.landmarksStep, 'pass', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition( self.defineROIStep, self.loadDataStep, 'fail', ctk.ctkWorkflow.Bidirectional  )
    
    self.workflow.addTransition( self.landmarksStep, self.measurementsStep, 'pass', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition( self.landmarksStep, self.measurementsStep, 'fail', ctk.ctkWorkflow.Bidirectional )
    
    self.workflow.addTransition( self.measurementsStep, self.screwStep, 'pass', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition( self.measurementsStep, self.screwStep, 'fail', ctk.ctkWorkflow.Bidirectional )
    
    self.workflow.addTransition( self.screwStep, self.gradeStep, 'pass', ctk.ctkWorkflow.Bidirectional )
    self.workflow.addTransition( self.screwStep, self.gradeStep, 'fail', ctk.ctkWorkflow.Bidirectional )
          
    self.workflow.addTransition( self.gradeStep, self.endStep )
           
    nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')

    self.parameterNode = None
    for n in xrange(nNodes):
      compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
      nodeid = None
      if compNode.GetModuleName() == 'PedicleScrewSimulator_v3':
        self.parameterNode = compNode
        print 'Found existing PedicleScrewSimulator_v3 parameter node'
        break
    if self.parameterNode == None:
      self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
      self.parameterNode.SetModuleName('PedicleScrewSimulator_v3')
      slicer.mrmlScene.AddNode(self.parameterNode)
 
    for s in allSteps:
        s.setParameterNode (self.parameterNode)
    
    
    # restore workflow step
    currentStep = self.parameterNode.GetParameter('currentStep')
    
    if currentStep != '':
      print 'Restoring workflow step to ', currentStep
      if currentStep == 'LoadData':
        self.workflow.setInitialStep(self.loadDataStep)
      if currentStep == 'DefineROI':
        self.workflow.setInitialStep(self.defineROIStep)
      if currentStep == 'Measurements':
        self.workflow.setInitialStep(self.measurementsStep)
      if currentStep == 'Landmarks':
        self.workflow.setInitialStep(self.landmarksStep)
      if currentStep == 'Screw':
        self.workflow.setInitialStep(self.screwStep) 
      if currentStep == 'Grade':
        self.workflow.setInitialStep(self.gradeStep)   
      if currentStep == 'Final':
        self.workflow.setInitialStep(self.endStep)
    else:
      print 'currentStep in parameter node is empty!'
    
    
    # start the workflow and show the widget
    self.workflow.start()
    workflowWidget.visible = True
    self.layout.addWidget( workflowWidget )
示例#23
0
  def setup( self ):
    '''
    Create and start the ChangeTracker workflow.
    '''
    self.workflow = ctk.ctkWorkflow()

    workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget.setWorkflow( self.workflow )

    workflowWidget.buttonBoxWidget().nextButtonDefaultText = ""
    workflowWidget.buttonBoxWidget().backButtonDefaultText = ""
    
    # create all wizard steps
    selectScansStep = ChangeTrackerWizard.ChangeTrackerSelectScansStep( 'SelectScans'  )
    defineROIStep = ChangeTrackerWizard.ChangeTrackerDefineROIStep( 'DefineROI'  )
    segmentROIStep = ChangeTrackerWizard.ChangeTrackerSegmentROIStep( 'SegmentROI'  )
    analyzeROIStep = ChangeTrackerWizard.ChangeTrackerAnalyzeROIStep( 'AnalyzeROI'  )
    reportROIStep = ChangeTrackerWizard.ChangeTrackerReportROIStep( 'ReportROI'  )

    # add the wizard steps to an array for convenience
    allSteps = []

    allSteps.append( selectScansStep )
    allSteps.append( defineROIStep )
    allSteps.append( segmentROIStep )
    allSteps.append( analyzeROIStep )
    allSteps.append( reportROIStep )

    # Add transition for the first step which let's the user choose between simple and advanced mode
    self.workflow.addTransition( selectScansStep, defineROIStep )
    self.workflow.addTransition( defineROIStep, segmentROIStep )
    self.workflow.addTransition( segmentROIStep, analyzeROIStep )
    self.workflow.addTransition( analyzeROIStep, reportROIStep )

    nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')

    self.parameterNode = None
    for n in xrange(nNodes):
      compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
      nodeid = None
      if compNode.GetModuleName() == 'ChangeTracker':
        self.parameterNode = compNode
        print 'Found existing ChangeTracker parameter node'
        break
    if self.parameterNode == None:
      self.parameterNode = slicer.mrmlScene.CreateNodeByClass('vtkMRMLScriptedModuleNode')
      self.parameterNode.SetModuleName('ChangeTracker')
      slicer.mrmlScene.AddNode(self.parameterNode)
 
    # Propagate the workflow, the logic and the MRML Manager to the steps
    for s in allSteps:
        s.setWorkflow( self.workflow )
        s.setParameterNode (self.parameterNode)
        #s.setLogic( self.logic() )
        #s.setMRMLManager( self.mrmlManager() )

    # restore workflow step
    currentStep = self.parameterNode.GetParameter('currentStep')
    if currentStep != '':
      print 'Restoring workflow step to ', currentStep
      if currentStep == 'SelectScans':
        self.workflow.setInitialStep(selectScansStep)
      if currentStep == 'DefineROI':
        self.workflow.setInitialStep(defineROIStep)
      if currentStep == 'SegmentROI':
        self.workflow.setInitialStep(segmentROIStep)
      if currentStep == 'AnalyzeROI':
        self.workflow.setInitialStep(analyzeROIStep)
      if currentStep == 'ReportROI':
        self.workflow.setInitialStep(reportROIStep)
    else:
      print 'currentStep in parameter node is empty!'
        
    # start the workflow and show the widget
    self.workflow.start()
    workflowWidget.visible = True
    self.layout.addWidget( workflowWidget )
示例#24
0
  def setup( self ):
    '''
    Create and start the iGyne workflow.
    '''
    self.workflow = ctk.ctkWorkflow()

    workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget.setWorkflow( self.workflow )
    
    # create all wizard steps
    selectProcedureStep = iGyneWizard.iGyneSelectProcedureStep( 'SelectProcedure'  )
    selectApplicatorStep = iGyneWizard.iGyneSelectApplicatorStep( 'SelectApplicator'  )
    loadModelStep = iGyneWizard.iGyneLoadModelStep( 'LoadModel'  )
    firstRegistrationStep = iGyneWizard.iGyneFirstRegistrationStep( 'FirstRegistration'  )
    secondRegistrationStep = iGyneWizard.iGyneSecondRegistrationStep( 'SecondRegistration'  )
    needlePlanningStep = iGyneWizard.iGyneNeedlePlanningStep( 'NeedlePlanning'  )
    needleSegmentationStep = iGyneWizard.iGyneNeedleSegmentationStep( 'NeedleSegmentation'  )


    # add the wizard steps to an array for convenience
    allSteps = []

    allSteps.append( selectProcedureStep )
    allSteps.append( selectApplicatorStep )
    allSteps.append( loadModelStep )
    allSteps.append( firstRegistrationStep )
    allSteps.append( secondRegistrationStep )
    allSteps.append( needlePlanningStep )
    allSteps.append( needleSegmentationStep )


    self.workflow.addTransition( selectProcedureStep, selectApplicatorStep )
    self.workflow.addTransition( selectApplicatorStep, loadModelStep )
    self.workflow.addTransition( loadModelStep, firstRegistrationStep )
    self.workflow.addTransition( firstRegistrationStep, secondRegistrationStep )
    self.workflow.addTransition( secondRegistrationStep, needlePlanningStep )
    self.workflow.addTransition( needlePlanningStep, needleSegmentationStep )
    self.workflow.addTransition(selectProcedureStep,needleSegmentationStep)


    nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')

    self.parameterNode = None
    for n in xrange(nNodes):
      compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
      nodeid = None
      if compNode.GetModuleName() == 'iGynePy':
        self.parameterNode = compNode
        print 'Found existing iGyne parameter node'
        break
    if self.parameterNode == None:
      self.parameterNode = slicer.mrmlScene.CreateNodeByClass('vtkMRMLScriptedModuleNode')
      self.parameterNode.SetModuleName('iGynePy')
      slicer.mrmlScene.AddNode(self.parameterNode)
 
    # Propagate the workflow, the logic and the MRML Manager to the steps
    for s in allSteps:
        s.setWorkflow( self.workflow )
        s.setParameterNode (self.parameterNode)

    # restore workflow step
    currentStep = self.parameterNode.GetParameter('currentStep')
    if currentStep != '':
      print 'Restoring workflow step to ', currentStep
      if currentStep == 'SelectProcedure':
        self.workflow.setInitialStep(selectProcedureStep)
      if currentStep == 'SelectApplicator':
        self.workflow.setInitialStep(selectApplicatorStep)
      if currentStep == 'LoadModel':
        self.workflow.setInitialStep(loadModelStep)
      if currentStep == 'FirstRegistration':
        self.workflow.setInitialStep(firstRegistrationStep)
      if currentStep == 'SecondRegistration':
        self.workflow.setInitialStep(secondRegistrationStep)
      if currentStep == 'NeedlePlanning':
        self.workflow.setInitialStep(needlePlanningStep)
      if currentStep == 'NeedleSegmentation':
        self.workflow.setInitialStep(needleSegmentationStep)
    else:
      print 'currentStep in parameter node is empty!'
        
    # start the workflow and show the widget
    self.workflow.start()
    workflowWidget.visible = True
    self.layout.addWidget( workflowWidget )     
    def setup(self):
        self.workflow = ctk.ctkWorkflow()

        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(self.workflow)

        # create all 4 wizard steps
        self.selectDataStep = LASegmentationResources.LASegmentationWorkflowSelectDataStep(
            'SelectData')
        self.registrationStep = LASegmentationResources.LASegmentationWorkflowImageRegistrationStep(
            'ImageRegistration')
        self.endoSegStep = LASegmentationResources.LASegmentationWorkflowEndoSegmentationStep(
            'LAEndoSegmentation')

        # add the wizard steps to an array for convenience
        allSteps = []

        allSteps.append(self.selectDataStep)
        allSteps.append(self.registrationStep)
        allSteps.append(self.endoSegStep)

        self.workflow.addTransition(self.selectDataStep, self.registrationStep)
        self.workflow.addTransition(self.registrationStep, self.endoSegStep)

        nNodes = slicer.mrmlScene.GetNumberOfNodesByClass(
            'vtkMRMLScriptedModuleNode')

        self.parameterNode = None

        for n in xrange(nNodes):
            compNode = slicer.mrmlScene.GetNthNodeByClass(
                n, 'vtkMRMLScriptedModuleNode')
            nodeid = None
            if compNode.GetModuleName() == 'LASegmentationWorkflow':
                self.parameterNode = compNode
                print 'Found existing LASegmentationWorkflow parameter node'
                break

        if self.parameterNode == None:
            self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
            self.parameterNode.SetModuleName('LASegmentationWorkflow')
            slicer.mrmlScene.AddNode(self.parameterNode)

        for s in allSteps:
            s.setParameterNode(self.parameterNode)

        # restore workflow step
        currentStep = self.parameterNode.GetParameter('currentStep')
        if currentStep != '':
            print 'Restoring workflow step to ', currentStep
            if currentStep == 'SelectData':
                self.workflow.setInitialStep(self.selectDataStep)
            if currentStep == 'ImageRegistration':
                self.workflow.setInitialStep(self.registrationStep)
            if currentStep == 'LAEndoSegmentation':
                self.workflow.setInitialStep(self.endoSegStep)
        else:
            print 'currentStep in parameter node is empty!'

        # Start the workflow and show the widget
        self.workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget(workflowWidget)
示例#26
0
    def setup(self):
        '''
    Create and start the workflow.
    '''
        self.workflow = ctk.ctkWorkflow()

        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(self.workflow)

        # create all wizard steps
        self.loadDataStep = PedicleScrewSimulatorWizard_v3.LoadDataStep(
            'LoadData')
        self.defineROIStep = PedicleScrewSimulatorWizard_v3.DefineROIStep(
            'DefineROI')
        self.measurementsStep = PedicleScrewSimulatorWizard_v3.MeasurementsStep(
            'Measurements')
        self.landmarksStep = PedicleScrewSimulatorWizard_v3.LandmarksStep(
            'Landmarks')
        self.screwStep = PedicleScrewSimulatorWizard_v3.ScrewStep('Screw')
        self.gradeStep = PedicleScrewSimulatorWizard_v3.GradeStep('Grade')
        self.endStep = PedicleScrewSimulatorWizard_v3.EndStep('Final')

        # add the wizard steps to an array for convenience
        allSteps = []

        allSteps.append(self.loadDataStep)
        allSteps.append(self.defineROIStep)
        allSteps.append(self.landmarksStep)
        allSteps.append(self.measurementsStep)
        allSteps.append(self.screwStep)
        allSteps.append(self.gradeStep)
        allSteps.append(self.endStep)

        # Add transition
        # Check if volume is loaded
        self.workflow.addTransition(self.loadDataStep, self.defineROIStep)

        self.workflow.addTransition(self.defineROIStep, self.landmarksStep,
                                    'pass', ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.defineROIStep, self.loadDataStep,
                                    'fail', ctk.ctkWorkflow.Bidirectional)

        self.workflow.addTransition(self.landmarksStep, self.measurementsStep,
                                    'pass', ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.landmarksStep, self.measurementsStep,
                                    'fail', ctk.ctkWorkflow.Bidirectional)

        self.workflow.addTransition(self.measurementsStep, self.screwStep,
                                    'pass', ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.measurementsStep, self.screwStep,
                                    'fail', ctk.ctkWorkflow.Bidirectional)

        self.workflow.addTransition(self.screwStep, self.gradeStep, 'pass',
                                    ctk.ctkWorkflow.Bidirectional)
        self.workflow.addTransition(self.screwStep, self.gradeStep, 'fail',
                                    ctk.ctkWorkflow.Bidirectional)

        self.workflow.addTransition(self.gradeStep, self.endStep)

        nNodes = slicer.mrmlScene.GetNumberOfNodesByClass(
            'vtkMRMLScriptedModuleNode')

        self.parameterNode = None
        for n in xrange(nNodes):
            compNode = slicer.mrmlScene.GetNthNodeByClass(
                n, 'vtkMRMLScriptedModuleNode')
            nodeid = None
            if compNode.GetModuleName() == 'PedicleScrewSimulator_v3':
                self.parameterNode = compNode
                print 'Found existing PedicleScrewSimulator_v3 parameter node'
                break
        if self.parameterNode == None:
            self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
            self.parameterNode.SetModuleName('PedicleScrewSimulator_v3')
            slicer.mrmlScene.AddNode(self.parameterNode)

        for s in allSteps:
            s.setParameterNode(self.parameterNode)

        # restore workflow step
        currentStep = self.parameterNode.GetParameter('currentStep')

        if currentStep != '':
            print 'Restoring workflow step to ', currentStep
            if currentStep == 'LoadData':
                self.workflow.setInitialStep(self.loadDataStep)
            if currentStep == 'DefineROI':
                self.workflow.setInitialStep(self.defineROIStep)
            if currentStep == 'Measurements':
                self.workflow.setInitialStep(self.measurementsStep)
            if currentStep == 'Landmarks':
                self.workflow.setInitialStep(self.landmarksStep)
            if currentStep == 'Screw':
                self.workflow.setInitialStep(self.screwStep)
            if currentStep == 'Grade':
                self.workflow.setInitialStep(self.gradeStep)
            if currentStep == 'Final':
                self.workflow.setInitialStep(self.endStep)
        else:
            print 'currentStep in parameter node is empty!'

        # start the workflow and show the widget
        self.workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget(workflowWidget)
    def setup(self):
        """
    Create and start the EMSegment workflow.
    """

        # Use the logic associated with the module
        if not self.__logic:
            self.__logic = self.parent.module().logic()

        self.parent.connect("mrmlSceneChanged(vtkMRMLScene*)", self.onMRMLSceneChanged)

        workflow = ctk.ctkWorkflow()

        workflowWidget = ctk.ctkWorkflowStackedWidget()
        workflowWidget.setWorkflow(workflow)

        # create all wizard steps
        selectTaskStep = EMSegmentWizard.EMSegmentSelectTaskStep(Helper.GetNthStepId(1))
        defineInputChannelsSimpleStep = EMSegmentWizard.EMSegmentDefineInputChannelsStep(
            Helper.GetNthStepId(2) + "Simple"
        )  # simple branch
        defineInputChannelsAdvancedStep = EMSegmentWizard.EMSegmentDefineInputChannelsStep(
            Helper.GetNthStepId(2) + "Advanced"
        )  # advanced branch
        defineAnatomicalTreeStep = EMSegmentWizard.EMSegmentDefineAnatomicalTreeStep(Helper.GetNthStepId(3))
        defineAtlasStep = EMSegmentWizard.EMSegmentDefineAtlasStep(Helper.GetNthStepId(4))
        editRegistrationParametersStep = EMSegmentWizard.EMSegmentEditRegistrationParametersStep(Helper.GetNthStepId(5))
        definePreprocessingStep = EMSegmentWizard.EMSegmentDefinePreprocessingStep(Helper.GetNthStepId(6))
        specifyIntensityDistributionStep = EMSegmentWizard.EMSegmentSpecifyIntensityDistributionStep(
            Helper.GetNthStepId(7)
        )
        editNodeBasedParametersStep = EMSegmentWizard.EMSegmentEditNodeBasedParametersStep(Helper.GetNthStepId(8))
        miscStep = EMSegmentWizard.EMSegmentDefineMiscParametersStep(Helper.GetNthStepId(9))
        segmentStep = EMSegmentWizard.EMSegmentStartSegmentationStep(Helper.GetNthStepId(10))
        statisticsStep = EMSegmentWizard.EMSegmentLabelStatisticsStep(Helper.GetNthStepId(11))

        # add the wizard steps to an array for convenience
        allSteps = []

        allSteps.append(selectTaskStep)
        allSteps.append(defineInputChannelsSimpleStep)
        allSteps.append(defineInputChannelsAdvancedStep)
        allSteps.append(defineAnatomicalTreeStep)
        allSteps.append(defineAtlasStep)
        allSteps.append(editRegistrationParametersStep)
        allSteps.append(definePreprocessingStep)
        allSteps.append(specifyIntensityDistributionStep)
        allSteps.append(editNodeBasedParametersStep)
        allSteps.append(miscStep)
        allSteps.append(statisticsStep)
        allSteps.append(segmentStep)

        # Add transition for the first step which let's the user choose between simple and advanced mode
        workflow.addTransition(selectTaskStep, defineInputChannelsSimpleStep, "SimpleMode")
        workflow.addTransition(selectTaskStep, defineInputChannelsAdvancedStep, "AdvancedMode")

        # Add transitions associated to the simple mode
        workflow.addTransition(defineInputChannelsSimpleStep, defineAnatomicalTreeStep)

        # Add transitions associated to the advanced mode
        workflow.addTransition(defineInputChannelsAdvancedStep, defineAnatomicalTreeStep)

        # .. add transitions for the rest of the advanced mode steps
        for i in range(3, len(allSteps) - 1):
            workflow.addTransition(allSteps[i], allSteps[i + 1])

        # Propagate the workflow, the logic and the MRML Manager to the steps
        for s in allSteps:
            s.setLogic(self.__logic)
            s.setMRMLManager(self.__logic.GetMRMLManager())

        # Disable the error text which showed up when jumping to the (invisible) segment step
        workflowWidget.workflowGroupBox().errorTextEnabled = False
        workflow.goBackToOriginStepUponSuccess = False

        # start the workflow and show the widget
        workflow.start()
        workflowWidget.visible = True
        self.layout.addWidget(workflowWidget)

        # enable global access to the dynamicFrames on step 2 and step 6
        slicer.modules.emsegmentLogic = self.__logic
        slicer.modules.emsegmentSimpleDynamicFrame = defineInputChannelsSimpleStep.dynamicFrame()
        slicer.modules.emsegmentPreprocessingStep = definePreprocessingStep

        # Keep track of workflow and workflowWidget references
        self.__workflow = workflow
        self.__workflowWidget = workflowWidget
  def setup( self ):    
    self.workflow = ctk.ctkWorkflow()

    workflowWidget = ctk.ctkWorkflowStackedWidget()
    workflowWidget.setWorkflow( self.workflow )

    #workflowWidget.buttonBoxWidget().nextButtonDefaultText = ""
    #workflowWidget.buttonBoxWidget().backButtonDefaultText = ""
    
    # create all 9 wizard steps
    self.selectMRIDataStep = Resources.CMRToolkitWizardSelectDataStep( 'SelectMRIData' )
    self.endoSegStep = Resources.CMRToolkitWizardEndoSegmentationStep( 'LAEndoSegmentation' )
    self.axialDilateStep = Resources.CMRToolkitWizardAxialDilateStep( 'AxialDilate' )
    self.booleanRemoveStep = Resources.CMRToolkitWizardBooleanRemoveStep( 'BooleanRemove' )
    self.wallCleanupStep = Resources.CMRToolkitWizardWallCleanupStep( 'LAWallCleanup' )
    self.antrumCutStep = Resources.CMRToolkitWizardAntrumCutStep( 'PVAntrumCut' )
    self.endoNVIsoStep = Resources.CMRToolkitWizardEndoNVIsosurfaceStep( 'EndoNVIsosurface' )
    self.autoScarStep = Resources.CMRToolkitWizardAutoScarStep( 'AutomaticLeftAtrialScar' )
    #self.scarIsoStep = Resources.CMRToolkitWizardScarIsosurfaceStep( 'ScarIsosurface' )
    
    # add the wizard steps to an array for convenience
    allSteps = []

    allSteps.append( self.selectMRIDataStep )
    allSteps.append( self.endoSegStep )
    allSteps.append( self.axialDilateStep )
    allSteps.append( self.booleanRemoveStep )
    allSteps.append( self.wallCleanupStep )
    allSteps.append( self.antrumCutStep )
    allSteps.append( self.endoNVIsoStep )
    allSteps.append( self.autoScarStep )
    #allSteps.append( self.scarIsoStep )
    
    self.workflow.addTransition( self.selectMRIDataStep, self.endoSegStep )
    self.workflow.addTransition( self.endoSegStep, self.axialDilateStep )
    self.workflow.addTransition( self.axialDilateStep, self.booleanRemoveStep )
    self.workflow.addTransition( self.booleanRemoveStep, self.wallCleanupStep )
    self.workflow.addTransition( self.wallCleanupStep, self.antrumCutStep )
    self.workflow.addTransition( self.antrumCutStep, self.endoNVIsoStep )
    self.workflow.addTransition( self.endoNVIsoStep, self.autoScarStep )
    
    nNodes = slicer.mrmlScene.GetNumberOfNodesByClass('vtkMRMLScriptedModuleNode')

    self.parameterNode = None
    
    for n in xrange(nNodes):
      compNode = slicer.mrmlScene.GetNthNodeByClass(n, 'vtkMRMLScriptedModuleNode')
      nodeid = None
      if compNode.GetModuleName() == 'CMRToolkitWizard':
        self.parameterNode = compNode
        print 'Found existing CMRToolkitWizard parameter node'
        break
        
    if self.parameterNode == None:
      self.parameterNode = slicer.vtkMRMLScriptedModuleNode()
      self.parameterNode.SetModuleName('CMRToolkitWizard')
      slicer.mrmlScene.AddNode(self.parameterNode)
 
    for s in allSteps:
        s.setParameterNode (self.parameterNode)
    
     # restore workflow step
    currentStep = self.parameterNode.GetParameter('currentStep')
    if currentStep != '':
      print 'Restoring workflow step to ', currentStep
      if currentStep == 'SelectMRIData':
        self.workflow.setInitialStep(self.selectMRIDataStep)
      if currentStep == 'LAEndoSegmentation':
        self.workflow.setInitialStep(self.endoSegStep)
      if currentStep == 'AxialDilate':
        self.workflow.setInitialStep(self.axialDilateStep)
      if currentStep == 'BooleanRemove':
        self.workflow.setInitialStep(self.booleanRemoveStep)
      if currentStep == 'LAWallSegmentation':
        self.workflow.setInitialStep(self.wallCleanupStep)
      if currentStep == 'PVAntrumCut':
        self.workflow.setInitialStep(self.antrumCutStep)
      if currentStep == 'EndoNVIsosurface':
        self.workflow.setInitialStep(self.endoNVIsoStep)
      if currentStep == 'AutomaticLeftAtrialScar':
        self.workflow.setInitialStep(self.autoScarStep)
      #if currentStep == 'ScarIsosurface':
      #  self.workflow.setInitialStep(self.scarIsoStep)
    else:
      print 'currentStep in parameter node is empty!'
    
    # Start the workflow and show the widget
    self.workflow.start()
    workflowWidget.visible = True
    self.layout.addWidget( workflowWidget )