Пример #1
0
    def export_voxelplan_dialog(self, event):
        """
        Choose path for CTX + associated VDX file Export.
        """
        model = self.model

        from pytripgui.view.dialogs import MyDialogs

        if not model.ctx:
            MyDialogs.show_error("No CTX data available for export.")
            return None

        import os
        model.wdir = os.path.dirname(model.voxelplan_path)
        path_guess = os.path.join(model.wdir, model.ctx.basename + ".hed")

        # Start a file dialog for selecting input files
        path = MyDialogs.saveFileNameDialog(self.app,
                                            "Open Voxelplan file",
                                            path_guess,
                                            'hed')

        if path:
            self.export_voxelplan(path)
            model.voxelplan_path = path
            self.settings.save()
Пример #2
0
    def _setup_projectile_combobox(ui, model, plan):
        """
        This populates the Projectile combobox
        """
        uic = ui.combobox_5
        kernels = model.kernels

        if not kernels:
            from pytripgui.view.dialogs import MyDialogs
            MyDialogs.show_error("Setup dose kernels first in Settings.")
            return

        uic.clear()

        for kernel in kernels:
            uic.addItem(kernel.projectile_name, kernel)
Пример #3
0
 def import_exec_dialog(self, event):
     """
     """
     logger.debug("Import .exec")
     # Start a file dialog for selecting input files
     from pytripgui.view.dialogs import MyDialogs
     exec_path = MyDialogs.openFileNameDialog(self.app)
     self.import_exec(exec_path)
Пример #4
0
    def open_dicom(self, ddir):
        """
        Open a DICOM directory. Images must be present. RTSS is optional.
        """
        model = self.model    # local object of plot_model
        pm = self.model.plot  # local object of plot_model

        logger.debug("open dicom '{}'".format(ddir))
        dcm = pt.dicomhelper.read_dicom_dir(ddir)

        ctx = None
        vdx = None

        if 'images' in dcm:
            logger.debug("Found images in DICOM")
            ctx = pt.CtxCube()
            ctx.read_dicom(dcm)

            model.ctx = ctx
            pm.ctx = ctx
        else:
            from pytripgui.view.dialogs import MyDialogs
            MyDialogs.show_error("No images found in selected DICOM directory.")
            return

        if 'rtss' in dcm:
            logger.debug("Found rtss in DICOM")
            vdx = pt.VdxCube(cube=ctx)
            vdx.read_dicom(dcm)
            for voi in vdx.vois:
                pm.vois.append(voi)

            # This is a workaround for pytrip issue #455 https://github.com/pytrip/pytrip/issues/455
            vdx.basename = "basename"

            model.vdx = vdx
            pm.vdx = vdx

        # TODO: RTplan data

        # add cube to the treeviews
        # self.tree.update_tree() # It causes error during loading files. https://github.com/pytrip/pytripgui/issues/183

        # update the canvas
        self.plot.update_viewcanvas()
Пример #5
0
    def export_dicom(self, ddir):
        """
        Export model.ctx data to directory "ddir" as DICOM.
        If model.ctx is absent, throw an error dialog.
        if model.vdx is present, export these as well.
        """
        logger.warning("export_dicom() ddir={}".format(ddir))
        ctx = self.model.ctx
        vdx = self.model.vdx

        if ctx:
            logger.debug("export CTX to DICOM")
            ctx.write_dicom(ddir)
        else:
            from pytripgui.view.dialogs import MyDialogs
            MyDialogs.show_error("No CT Data available for export.")

        if vdx:
            logger.debug("export VDX to DICOM")
            vdx.write_dicom(ddir)
Пример #6
0
    def open_dicom_dialog(self, event):
        """
        Opens a DICOM set and sets it to the model.
        """
        logger.debug("Open DICOM triggered")
        model = self.model

        ddir = os.path.dirname(model.dicom_path)

        # Start a file dialog for selecting input files
        from pytripgui.view.dialogs import MyDialogs
        ddir = MyDialogs.openDirectoryDialog(self.app,
                                             "Open Directory with DICOM Files",
                                             ddir)
        if not ddir:
            return
        self.open_dicom(ddir)
        model.dicom_path = ddir
        self.settings.save()
Пример #7
0
    def import_dos_dialog(self, event):
        """
        Open the import dose cube dialog.
        """
        model = self.model

        # offer to look for .dos in the same path as where CTX/VDX was found.
        # however, contrary to CTX/VDX this is not saved to settings.
        import os
        model.wdir = os.path.dirname(model.voxelplan_path)

        from pytripgui.view.dialogs import MyDialogs
        path = MyDialogs.openFileNameDialog(self.app,
                                            "Import DoseCube",
                                            model.wdir,
                                            'dos')
        if not path:
            return
        self.import_dos(path)
Пример #8
0
    def export_dicom_dialog(self, event):
        """
        Choose dir for DICOM Export.
        """
        logger.warning("export_dicom_dialog()")

        model = self.model

        ddir = os.path.dirname(model.dicom_path)

        from pytripgui.view.dialogs import MyDialogs
        ddir = MyDialogs.saveDirectoryDialog(self.app, "Export DICOM to Directory", ddir)

        if not ddir:
            return

        self.export_dicom(ddir)
        model.dicom_path = ddir
        self.settings.save()
        return None
Пример #9
0
    def import_let_dialog(self, event):
        """
        Open the import LET cube dialog.
        """
        model = self.model

        # offer to look for .dos in the same path as where CTX/VDX was found.
        # however, contrary to CTX/VDX this is not saved to settings.
        import os
        model.wdir = os.path.dirname(model.voxelplan_path)

        from pytripgui.view.dialogs import MyDialogs
        path = MyDialogs.openFileNameDialog(self.app,
                                            "Import LETCube",
                                            model.wdir,
                                            'let')
        if not path:
            return

        self.import_let(path)
Пример #10
0
    def export_dicom_dialog(self, event):
        """
        Choose dir for DICOM Export.
        """
        logger.warning("export_dicom_dialog()")

        model = self.model

        ddir = os.path.dirname(model.dicom_path)

        from pytripgui.view.dialogs import MyDialogs
        ddir = MyDialogs.saveDirectoryDialog(self.app, "Export DICOM to Directory", ddir)

        if not ddir:
            return

        self.export_dicom(ddir)
        model.dicom_path = ddir
        self.settings.save()
        return None
Пример #11
0
    def open_voxelplan_dialog(self, event):
        """
        Opens a CTX + associated VDX file, and sets it to the model.
        Path will be saved to settings.
        """
        model = self.model

        model.wdir = os.path.dirname(model.voxelplan_path)

        # Start a file dialog for selecting input files
        from pytripgui.view.dialogs import MyDialogs
        path = MyDialogs.openFileNameDialog(self.app,
                                            "Open Voxelplan file",
                                            model.wdir,
                                            'hed')
        if not path:
            return
        self.open_voxelplan(path)
        model.voxelplan_path = path

        self.settings.save()
Пример #12
0
    def open_voxelplan_dialog(self, event):
        """
        Opens a CTX + associated VDX file, and sets it to the model.
        Path will be saved to settings.
        """
        model = self.model

        model.wdir = os.path.dirname(model.voxelplan_path)

        # Start a file dialog for selecting input files
        from pytripgui.view.dialogs import MyDialogs
        path = MyDialogs.openFileNameDialog(self.app,
                                            "Open Voxelplan file",
                                            model.wdir,
                                            'hed')
        if not path:
            return
        self.open_voxelplan(path)
        model.voxelplan_path = path

        self.settings.save()