def setup(self):
        """
        Called when the user opens the module the first time and the widget is initialized.
        """
        ScriptedLoadableModuleWidget.setup(self)

        # Load widget from .ui file (created by Qt Designer).
        uiWidget = slicer.util.loadUI(self.resourcePath("UI/EISegMed3D.ui"))
        self.layout.addWidget(uiWidget)
        self.ui = slicer.util.childWidgetVariables(uiWidget)
        uiWidget.setMRMLScene(slicer.mrmlScene)

        # Create logic class. Logic implements all computations that should be possible to run
        # in batch mode, without a graphical user interface.
        # TODO: we may not need logic. user have to interact
        self.logic = EISegMed3DLogic()

        # Connections
        # These connections ensure that we update parameter node when scene is closed
        self.addObserver(slicer.mrmlScene, slicer.mrmlScene.StartCloseEvent,
                         self.onSceneStartClose)
        self.addObserver(slicer.mrmlScene, slicer.mrmlScene.EndCloseEvent,
                         self.onSceneEndClose)
        self.addObserver(slicer.mrmlScene, slicer.mrmlScene.NodeAddedEvent,
                         self.onSceneEndImport)

        # TODO: is syncing settings between node and gui on show/scenestart/... necessary

        # button, slider
        self.ui.loadModelButton.connect("clicked(bool)", self.loadModelClicked)
        self.ui.nextScanButton.connect("clicked(bool)",
                                       lambda p: self.nextScan())
        self.ui.prevScanButton.connect("clicked(bool)",
                                       lambda p: self.prevScan())
        self.ui.finishScanButton.connect("clicked(bool)", self.finishScan)
        self.ui.finishSegmentButton.connect("clicked(bool)",
                                            self.exitInteractiveMode)
        self.ui.opacitySlider.connect("valueChanged(double)",
                                      self.opacityUi2Display)
        self.ui.dataFolderButton.connect("directoryChanged(QString)",
                                         self.loadScans)
        self.ui.skipFinished.connect("clicked(bool)", self.skipFinishedToggled)

        iconPath = HERE / "Resources" / "Icons"
        self.ui.nextScanButton.setIcon(qt.QIcon(iconPath / "next.png"))
        self.ui.prevScanButton.setIcon(qt.QIcon(iconPath / "prev.png"))
        self.ui.finishSegmentButton.setIcon(qt.QIcon(iconPath / "done.png"))
        self.ui.finishScanButton.setIcon(qt.QIcon(iconPath / "save.png"))

        # positive/negative control point
        self.ui.dgPositiveControlPointPlacementWidget.setMRMLScene(
            slicer.mrmlScene)
        self.ui.dgPositiveControlPointPlacementWidget.placeButton(
        ).toolTip = "Add positive points"
        self.ui.dgPositiveControlPointPlacementWidget.placeButton().show()
        self.ui.dgPositiveControlPointPlacementWidget.deleteButton(
        ).setFixedHeight(0)  # diable delete point button
        self.ui.dgPositiveControlPointPlacementWidget.deleteButton(
        ).setFixedWidth(0)
        self.ui.dgPositiveControlPointPlacementWidget.placeButton().connect(
            "clicked(bool)", self.enterInteractiveMode)

        self.ui.dgNegativeControlPointPlacementWidget.setMRMLScene(
            slicer.mrmlScene)
        self.ui.dgNegativeControlPointPlacementWidget.placeButton(
        ).toolTip = "Add negative points"
        self.ui.dgNegativeControlPointPlacementWidget.placeButton().show()
        self.ui.dgNegativeControlPointPlacementWidget.deleteButton(
        ).setFixedHeight(0)
        self.ui.dgNegativeControlPointPlacementWidget.deleteButton(
        ).setFixedWidth(0)
        self.ui.dgNegativeControlPointPlacementWidget.placeButton().connect(
            "clicked(bool)", self.enterInteractiveMode)

        # segment editor
        self.ui.embeddedSegmentEditorWidget.setMRMLScene(slicer.mrmlScene)
        self.ui.embeddedSegmentEditorWidget.setMRMLSegmentEditorNode(
            self.logic.get_segment_editor_node())

        self.initializeFromNode()

        # Set place point widget colors
        self.ui.dgPositiveControlPointPlacementWidget.setNodeColor(
            qt.QColor(0, 255, 0))
        self.ui.dgNegativeControlPointPlacementWidget.setNodeColor(
            qt.QColor(255, 0, 0))

        Called when the user opens the module the first time and the widget is initialized.
        
EISeg/med3d/EISegMed3D/EISegMed3D.py