Exemple #1
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
Exemple #2
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