Example #1
0
    def init_ui(self):

        self.ui = ui_main_window.Ui_MainWindow()
        self.ui.setup_ui(self)

        self.ren = vtk.vtkRenderer()

        self.ren_win = self.ui.vtk_widget.GetRenderWindow()
        self.ren_win.AddRenderer(self.ren)

        self.iren = self.ren_win.GetInteractor()
        self.iren.Initialize()

        self.ui.open_folder_radio.clicked[bool].connect(self.on_open_folder)
        self.ui.open_file_radio.clicked[bool].connect(self.on_open_file)
        self.ui.test_btn.clicked.connect(self.on_test_btn)
        self.ui.vol_cbox.stateChanged.connect(self.on_volume_cbox)
        self.ui.iso_cbox.stateChanged.connect(self.on_iso_cbox)
        self.ui.plane_cbox.stateChanged.connect(self.on_plane_cbox)
        self.ui.reset_camera_btn.clicked.connect(self.on_reset_camera_btn)

        self.marker = Marker(self.iren)  # Annotation Cube
        self.marker.show()
        # self.ui.annotationChk.toggle()

        self.ui.vol_cbox.setCheckable(False)
        self.ui.iso_cbox.setCheckable(False)
        self.ui.plane_cbox.setCheckable(False)

        # TEST
        # self.ui.test_spin.value = 500
        self.ui.test_spin.valueChanged.connect(self.on_test_spin)

        self.move(100, 100)
        self.setWindowTitle('Prototype')
        self.show()
Example #2
0
    def init_ui(self):

        self.ui = ui_main_window.Ui_MainWindow()
        self.ui.setup_ui(self)

        self.ren = vtk.vtkRenderer()

        self.ren_win = self.ui.vtk_widget.GetRenderWindow()
        self.ren_win.AddRenderer(self.ren)

        self.iren = self.ren_win.GetInteractor()
        self.iren.Initialize()

        self.ui.open_folder_radio.clicked[bool].connect(self.on_open_folder)
        self.ui.open_file_radio.clicked[bool].connect(self.on_open_file)
        self.ui.test_btn.clicked.connect(self.on_test_btn)
        self.ui.vol_cbox.stateChanged.connect(self.on_volume_cbox)
        self.ui.iso_cbox.stateChanged.connect(self.on_iso_cbox)
        self.ui.plane_cbox.stateChanged.connect(self.on_plane_cbox)
        self.ui.reset_camera_btn.clicked.connect(self.on_reset_camera_btn)

        self.marker = Marker(self.iren)  # Annotation Cube
        self.marker.show()
        # self.ui.annotationChk.toggle()

        self.ui.vol_cbox.setCheckable(False)
        self.ui.iso_cbox.setCheckable(False)
        self.ui.plane_cbox.setCheckable(False)

        # TEST
        # self.ui.test_spin.value = 500
        self.ui.test_spin.valueChanged.connect(self.on_test_spin)

        self.move(100, 100)
        self.setWindowTitle('Prototype')
        self.show()
Example #3
0
class Basic(QtGui.QMainWindow):

    """Summary of class here.

    Longer class information....
    Longer class information....

    Attributes:
        likes_spam: A boolean indicating if we like SPAM or not.
        eggs: An integer count of the eggs we have laid.
    """

    def __init__(self):
        """
        In practial application, a rendering scene should have only ONE volume actor,
        ONE or TWO isosurface actors, FOUR to FIVE image planes.
        """

        super(Basic, self).__init__()

        self.reader = None
        self.path_name = None

        self.actor_iso = None
        self.actor_iso_2 = None  # Not used now
        self.actor_vol = None

        self.plane_x = None
        self.plane_y = None
        self.plane_z = None

        self.plane = None  # For single vtkImagePlaneWidget

        self.info = None

        self.init_ui()

    def init_ui(self):

        self.ui = ui_main_window.Ui_MainWindow()
        self.ui.setup_ui(self)

        self.ren = vtk.vtkRenderer()

        self.ren_win = self.ui.vtk_widget.GetRenderWindow()
        self.ren_win.AddRenderer(self.ren)

        self.iren = self.ren_win.GetInteractor()
        self.iren.Initialize()

        self.ui.open_folder_radio.clicked[bool].connect(self.on_open_folder)
        self.ui.open_file_radio.clicked[bool].connect(self.on_open_file)
        self.ui.test_btn.clicked.connect(self.on_test_btn)
        self.ui.vol_cbox.stateChanged.connect(self.on_volume_cbox)
        self.ui.iso_cbox.stateChanged.connect(self.on_iso_cbox)
        self.ui.plane_cbox.stateChanged.connect(self.on_plane_cbox)
        self.ui.reset_camera_btn.clicked.connect(self.on_reset_camera_btn)

        self.marker = Marker(self.iren)  # Annotation Cube
        self.marker.show()
        # self.ui.annotationChk.toggle()

        self.ui.vol_cbox.setCheckable(False)
        self.ui.iso_cbox.setCheckable(False)
        self.ui.plane_cbox.setCheckable(False)

        # TEST
        # self.ui.test_spin.value = 500
        self.ui.test_spin.valueChanged.connect(self.on_test_spin)

        self.move(100, 100)
        self.setWindowTitle('Prototype')
        self.show()

    # Event Response Function
    def on_open_folder(self):

        path = QtGui.QFileDialog.getExistingDirectory(
            self, 'Open DICOM Folder', QtCore.QDir.currentPath(),
            QtGui.QFileDialog.ShowDirsOnly)

        self._read(path)

        # Test
        # min, max = self.reader.get_value_range()
        # self.ui.test_spin.setMinimum(min)
        # self.ui.test_spin.setMaximum(max)
        # self.ui.test_spin.setSingleStep(50)
        # self.ui.test_spin.setValue(int(max - (max - min) * 0.618))

        # self.better_camera()
        # self.ren_win.Render()

    def on_open_file(self):

        path = QtGui.QFileDialog.getOpenFileName(
            self, 'Open Meta Image', QtCore.QDir.currentPath(),
            'Meta Image (*.mha *.mhd)')

        self._read(path)

    def _read(self, path):
        """
        Common thing of reading image(s)
        """
        path = str(path)
        # assert path, 'No file selected.'  # Debug
        logging.info('No file or folder selected.')

        try:
            not path
        except IOError, e:
            print IOError, e

        # For the first time file reading
        if not self.path_name and path:
            self.path_name = path

        # After the first file reading
        elif self.is_path_changed(path) and path:

            if self.actor_vol:
                self.reader.remove_actor(self.ren, self.actor_vol)
                self.actor_vol = None  # Don't forget this!

            if self.actor_iso:
                self.reader.remove_actor(self.ren, self.actor_iso)
                self.actor_iso = None

            if self.plane_x:
                self.plane_x.Off()
                self.plane_x = None

            if self.plane_y:
                self.plane_y.Off()
                self.plane_y = None

            if self.plane_z:
                self.plane_z.Off()
                self.plane_z = None

            if self.reader:  # If there was a reader, delete it
                del self.reader

        self.path_name = path

        self.reader = MedicalObject()
        self.reader.read(self.path_name)

        self.info = self.reader.get_info()

        self.ui.vol_cbox.setCheckable(True)
        self.ui.iso_cbox.setCheckable(True)
        self.ui.plane_cbox.setCheckable(True)

        self.ui.vol_cbox.setChecked(False)
        self.ui.iso_cbox.setChecked(False)
        self.ui.plane_cbox.setChecked(False)
Example #4
0
class Basic(QtGui.QMainWindow):
    """Summary of class here.

    Longer class information....
    Longer class information....

    Attributes:
        likes_spam: A boolean indicating if we like SPAM or not.
        eggs: An integer count of the eggs we have laid.
    """
    def __init__(self):
        """
        In practial application, a rendering scene should have only ONE volume actor,
        ONE or TWO isosurface actors, FOUR to FIVE image planes.
        """

        super(Basic, self).__init__()

        self.reader = None
        self.path_name = None

        self.actor_iso = None
        self.actor_iso_2 = None  # Not used now
        self.actor_vol = None

        self.plane_x = None
        self.plane_y = None
        self.plane_z = None

        self.plane = None  # For single vtkImagePlaneWidget

        self.info = None

        self.init_ui()

    def init_ui(self):

        self.ui = ui_main_window.Ui_MainWindow()
        self.ui.setup_ui(self)

        self.ren = vtk.vtkRenderer()

        self.ren_win = self.ui.vtk_widget.GetRenderWindow()
        self.ren_win.AddRenderer(self.ren)

        self.iren = self.ren_win.GetInteractor()
        self.iren.Initialize()

        self.ui.open_folder_radio.clicked[bool].connect(self.on_open_folder)
        self.ui.open_file_radio.clicked[bool].connect(self.on_open_file)
        self.ui.test_btn.clicked.connect(self.on_test_btn)
        self.ui.vol_cbox.stateChanged.connect(self.on_volume_cbox)
        self.ui.iso_cbox.stateChanged.connect(self.on_iso_cbox)
        self.ui.plane_cbox.stateChanged.connect(self.on_plane_cbox)
        self.ui.reset_camera_btn.clicked.connect(self.on_reset_camera_btn)

        self.marker = Marker(self.iren)  # Annotation Cube
        self.marker.show()
        # self.ui.annotationChk.toggle()

        self.ui.vol_cbox.setCheckable(False)
        self.ui.iso_cbox.setCheckable(False)
        self.ui.plane_cbox.setCheckable(False)

        # TEST
        # self.ui.test_spin.value = 500
        self.ui.test_spin.valueChanged.connect(self.on_test_spin)

        self.move(100, 100)
        self.setWindowTitle('Prototype')
        self.show()

    # Event Response Function
    def on_open_folder(self):

        path = QtGui.QFileDialog.getExistingDirectory(
            self, 'Open DICOM Folder', QtCore.QDir.currentPath(),
            QtGui.QFileDialog.ShowDirsOnly)

        self._read(path)

        # Test
        # min, max = self.reader.get_value_range()
        # self.ui.test_spin.setMinimum(min)
        # self.ui.test_spin.setMaximum(max)
        # self.ui.test_spin.setSingleStep(50)
        # self.ui.test_spin.setValue(int(max - (max - min) * 0.618))

        # self.better_camera()
        # self.ren_win.Render()

    def on_open_file(self):

        path = QtGui.QFileDialog.getOpenFileName(self, 'Open Meta Image',
                                                 QtCore.QDir.currentPath(),
                                                 'Meta Image (*.mha *.mhd)')

        self._read(path)

    def _read(self, path):
        """
        Common thing of reading image(s)
        """
        path = str(path)
        # assert path, 'No file selected.'  # Debug
        logging.info('No file or folder selected.')

        try:
            not path
        except IOError, e:
            print IOError, e

        # For the first time file reading
        if not self.path_name and path:
            self.path_name = path

        # After the first file reading
        elif self.is_path_changed(path) and path:

            if self.actor_vol:
                self.reader.remove_actor(self.ren, self.actor_vol)
                self.actor_vol = None  # Don't forget this!

            if self.actor_iso:
                self.reader.remove_actor(self.ren, self.actor_iso)
                self.actor_iso = None

            if self.plane_x:
                self.plane_x.Off()
                self.plane_x = None

            if self.plane_y:
                self.plane_y.Off()
                self.plane_y = None

            if self.plane_z:
                self.plane_z.Off()
                self.plane_z = None

            if self.reader:  # If there was a reader, delete it
                del self.reader

        self.path_name = path

        self.reader = MedicalObject()
        self.reader.read(self.path_name)

        self.info = self.reader.get_info()

        self.ui.vol_cbox.setCheckable(True)
        self.ui.iso_cbox.setCheckable(True)
        self.ui.plane_cbox.setCheckable(True)

        self.ui.vol_cbox.setChecked(False)
        self.ui.iso_cbox.setChecked(False)
        self.ui.plane_cbox.setChecked(False)