Exemplo n.º 1
0
    def _connect(self):
        self._check_host_url()

        success = False
        msg = 'Error on connecting to cluster control service on %s' % self._host_url
        try:
            client = RemotingService(self._host_url)
            self.dlg = ProgressDialog("connecting to cluster...", None, 0, 0, self)
            func = lambda: client.getService('clustercontrol')
            self.dlg.exec_(func)
            self._service = self.dlg.getTargetResult()
        except:
            exception(self, msg)
        else:
            try:
                self.dlg.exec_(self._service.get_cecog_versions)
                cluster_versions = self.dlg.getTargetResult()
            except Exception as e:
                exception(self, msg + '(%s)' %str(e))
            else:
                if not VERSION in set(cluster_versions):
                    warning(self, 'Cecog version %s not supported by the cluster' %
                            VERSION, 'Valid versions are: %s' \
                                % ', '.join(cluster_versions))
                else:
                    success = True
        return success
Exemplo n.º 2
0
    def _connect(self):
        self._check_host_url()

        success = False
        msg = 'Error on connecting to cluster control service on %s' % self._host_url
        try:
            client = RemotingService(self._host_url)
            self.dlg = waitingProgressDialog('Please wait for the cluster...', self)
            self.dlg.setTarget(client.getService, 'clustercontrol')
            self.dlg.exec_()
            self._service = self.dlg.getTargetResult()
        except:
            exception(self, msg)
        else:
            try:
                self.dlg.setTarget(self._service.get_cecog_versions)
                self.dlg.exec_()
                cluster_versions = self.dlg.getTargetResult()
            except:
                exception(self, msg)
            else:
                if not VERSION in set(cluster_versions):
                    warning(self, 'Cecog version %s not supported by the cluster' %
                            VERSION, 'Valid versions are: %s' \
                                % ', '.join(cluster_versions))
                else:
                    success = True
        return success
Exemplo n.º 3
0
    def _connect(self):
        self._check_host_url()

        success = False
        msg = 'Error on connecting to cluster control service on %s' % self._host_url
        try:
            client = RemotingService(self._host_url)
            self.dlg = waitingProgressDialog('Please wait for the cluster...',
                                             self)
            self.dlg.setTarget(client.getService, 'clustercontrol')
            self.dlg.exec_()
            self._service = self.dlg.getTargetResult()
        except:
            exception(self, msg)
        else:
            try:
                self.dlg.setTarget(self._service.get_cecog_versions)
                self.dlg.exec_()
                cluster_versions = self.dlg.getTargetResult()
            except:
                exception(self, msg)
            else:
                if not VERSION in set(cluster_versions):
                    warning(self, 'Cecog version %s not supported by the cluster' %
                            VERSION, 'Valid versions are: %s' \
                                % ', '.join(cluster_versions))
                else:
                    success = True
        return success
Exemplo n.º 4
0
    def _connect(self):
        self._check_host_url()

        success = False
        msg = 'Error on connecting to cluster control service on %s' % self._host_url
        try:
            client = RemotingService(self._host_url)
            self.dlg = ProgressDialog("connecting to cluster...", None, 0, 0, self)
            func = lambda: client.getService('clustercontrol')
            self.dlg.exec_(func)
            self._service = self.dlg.getTargetResult()
        except:
            exception(self, msg)
        else:
            try:
                self.dlg.exec_(self._service.get_cecog_versions)
                cluster_versions = self.dlg.getTargetResult()
            except Exception as e:
                exception(self, msg + '(%s)' %str(e))
            else:
                if not version in set(cluster_versions):
                    warning(self, 'Cecog version %s not supported by the cluster' %
                            version, 'Valid versions are: %s' \
                                % ', '.join(cluster_versions))
                else:
                    success = True
        return success
Exemplo n.º 5
0
    def _on_class_apply(self):
        '''
        Apply class changes
        '''
        learner = self._learner

        class_name_new = str(self._class_text.text())
        class_label_new = self._class_sbox.value()
        class_name = self._current_class

        if not class_name is None:
            class_label = learner.class_labels[class_name]

            class_labels = learner.class_labels.values()
            class_labels.remove(class_label)
            class_names = learner.class_names.values()
            class_names.remove(class_name)

            if len(class_name_new) == 0:
                warning(self,
                        "Invalid class name",
                        info="The class name must not be empty!")
            elif (not class_name_new in class_names
                  and not class_label_new in class_labels):

                del learner.class_names[class_label]
                del learner.class_labels[class_name]
                del learner.hexcolors[class_name]

                item = self._find_items_in_class_table(
                    class_name, self.COLUMN_CLASS_NAME)[0]

                learner.class_names[class_label_new] = class_name_new
                learner.class_labels[class_name_new] = class_label_new
                class_color = self._class_color_btn.current_color
                learner.hexcolors[class_name_new] = \
                    qcolor_to_hex(class_color)

                item.setText(class_name_new)
                item2 = self._class_table.item(item.row(),
                                               self.COLUMN_CLASS_LABEL)
                item2.setText(str(class_label_new))
                item2 = self._class_table.item(item.row(),
                                               self.COLUMN_CLASS_COLOR)
                item2.setBackground(QBrush(class_color))

                col = get_qcolor_hicontrast(class_color)
                self._class_table.resizeRowsToContents()
                self._class_table.resizeColumnsToContents()
                self._class_table.scrollToItem(item)

                self._annotations.rename_class(class_name, class_name_new)
                self._current_class = class_name_new
                self._activate_objects_for_image(False)
                self._activate_objects_for_image(True)
            else:
                warning(self, "Class names and labels must be unique!",
                        info="Class name '%s' or label '%s' already used." %\
                             (class_name_new, class_label_new))
Exemplo n.º 6
0
    def _on_class_apply(self):
        '''
        Apply class changes
        '''
        learner = self._learner

        class_name_new = str(self._class_text.text())
        class_label_new = self._class_sbox.value()
        class_name = self._current_class

        if not class_name is None:
            class_label = learner.class_labels[class_name]

            class_labels = learner.class_labels.values()
            class_labels.remove(class_label)
            class_names = learner.class_names.values()
            class_names.remove(class_name)

            if len(class_name_new) == 0:
                warning(self, "Invalid class name",
                        info="The class name must not be empty!")
            elif (not class_name_new in class_names and
                  not class_label_new in class_labels):

                del learner.class_names[class_label]
                del learner.class_labels[class_name]
                del learner.hexcolors[class_name]

                item = self._find_items_in_class_table(class_name,
                                                       self.COLUMN_CLASS_NAME)[0]

                learner.class_names[class_label_new] = class_name_new
                learner.class_labels[class_name_new] = class_label_new
                class_color = self._class_color_btn.current_color
                learner.hexcolors[class_name_new] = \
                    qcolor_to_hex(class_color)

                item.setText(class_name_new)
                item2 = self._class_table.item(item.row(),
                                               self.COLUMN_CLASS_LABEL)
                item2.setText(str(class_label_new))
                item2 = self._class_table.item(item.row(),
                                               self.COLUMN_CLASS_COLOR)
                item2.setBackground(QBrush(class_color))

                col = get_qcolor_hicontrast(class_color)
                self._class_table.resizeRowsToContents()
                self._class_table.resizeColumnsToContents()
                self._class_table.scrollToItem(item)

                self._annotations.rename_class(class_name, class_name_new)
                self._current_class = class_name_new
                self._activate_objects_for_image(False)
                self._activate_objects_for_image(True)
            else:
                warning(self, "Class names and labels must be unique!",
                        info="Class name '%s' or label '%s' already used." %\
                             (class_name_new, class_label_new))
Exemplo n.º 7
0
    def _on_class_add(self):
        """Add a new class to definition"""

        learner = self._learner
        class_name_new = str(self._class_text.text())
        class_label_new = self._class_sbox.value()

        class_labels = learner.class_labels.values()
        class_names = learner.class_names.values()

        if len(class_name_new) == 0:
            warning(self,
                    "Invalid class name",
                    info="The class name must not be empty!")
        elif (not class_name_new in class_names
              and not class_label_new in class_labels):
            self._current_class = class_name_new

            learner.class_names[class_label_new] = class_name_new
            learner.class_labels[class_name_new] = class_label_new
            class_color = self._class_color_btn.current_color
            learner.hexcolors[class_name_new] = \
                qcolor_to_hex(class_color)

            row = self._class_table.rowCount()
            self._class_table.insertRow(row)
            self._class_table.setItem(row, self.COLUMN_CLASS_NAME,
                                      QTableWidgetItem(class_name_new))
            self._class_table.setItem(row, self.COLUMN_CLASS_LABEL,
                                      QTableWidgetItem(str(class_label_new)))
            self._class_table.setItem(row, self.COLUMN_CLASS_COUNT,
                                      QTableWidgetItem('0'))
            item = QTableWidgetItem()
            item.setBackground(QBrush(class_color))
            self._class_table.setItem(row, self.COLUMN_CLASS_COLOR, item)
            self._class_table.resizeRowsToContents()
            self._class_table.resizeColumnsToContents()
            self._class_table.setCurrentItem(item)

            ncl = len(learner.class_names) + 1
            self._class_text.setText('class%d' % ncl)
            self._class_sbox.setValue(ncl)

            self._class_color_btn.set_color(
                QColor(AnnotationModule.DEFAULT_CLASS_COLS[(ncl - 1) % len(
                    AnnotationModule.DEFAULT_CLASS_COLS)]))
        else:
            warning(self, "Class names and labels must be unique!",
                    info="Class name '%s' or label '%s' already used." %\
                         (class_name_new, class_label_new))
Exemplo n.º 8
0
    def _on_class_add(self):
        """Add a new class to definition"""

        learner = self._learner
        class_name_new = str(self._class_text.text())
        class_label_new = self._class_sbox.value()

        class_labels = learner.class_labels.values()
        class_names = learner.class_names.values()

        if len(class_name_new) == 0:
            warning(self, "Invalid class name",
                    info="The class name must not be empty!")
        elif (not class_name_new in class_names and
              not class_label_new in class_labels):
            self._current_class = class_name_new

            learner.class_names[class_label_new] = class_name_new
            learner.class_labels[class_name_new] = class_label_new
            class_color = self._class_color_btn.current_color
            learner.hexcolors[class_name_new] = \
                qcolor_to_hex(class_color)

            row = self._class_table.rowCount()
            self._class_table.insertRow(row)
            self._class_table.setItem(row, self.COLUMN_CLASS_NAME,
                                      QTableWidgetItem(class_name_new))
            self._class_table.setItem(row, self.COLUMN_CLASS_LABEL,
                                      QTableWidgetItem(str(class_label_new)))
            self._class_table.setItem(row, self.COLUMN_CLASS_COUNT,
                                      QTableWidgetItem('0'))
            item = QTableWidgetItem()
            item.setBackground(QBrush(class_color))
            self._class_table.setItem(row, self.COLUMN_CLASS_COLOR, item)
            self._class_table.resizeRowsToContents()
            self._class_table.resizeColumnsToContents()
            self._class_table.setCurrentItem(item)

            ncl = len(learner.class_names)+1
            self._class_text.setText('class%d' % ncl)
            self._class_sbox.setValue(ncl)

            self._class_color_btn.set_color(
                QColor(AnnotationModule.DEFAULT_CLASS_COLS[(ncl -1) \
                   % len(AnnotationModule.DEFAULT_CLASS_COLS)]))
        else:
            warning(self, "Class names and labels must be unique!",
                    info="Class name '%s' or label '%s' already used." %\
                         (class_name_new, class_label_new))
Exemplo n.º 9
0
 def _on_browser_open(self):
     if self._imagecontainer is None:
         warning(self, 'Data structure not loaded',
                 'The input data structure was not loaded.\n'
                 'Please click "Load image data" in General.')
     elif self._browser is None:
         try:
             browser = Browser(self._settings, self._imagecontainer)
             browser.show()
             browser.raise_()
             browser.setFocus()
             self._browser = browser
         except:
             exception(self, 'Problem opening the browser')
     else:
         self._browser.show()
         self._browser.raise_()
Exemplo n.º 10
0
    def _on_class_add(self):
        '''
        Add a new class
        '''
        learner = self._learner
        class_name_new = str(self._class_text.text())
        class_label_new = self._class_sbox.value()

        class_labels = set(learner.lstClassLabels)
        class_names = set(learner.lstClassNames)
        if len(class_name_new) == 0:
            warning(self, "Invalid class name",
                    info="The class name must not be empty!")
        elif (not class_name_new in class_names and
              not class_label_new in class_labels):
            self._current_class = class_name_new

            learner.dctClassNames[class_label_new] = class_name_new
            learner.dctClassLabels[class_name_new] = class_label_new
            class_color = self._class_color_btn.current_color
            learner.dctHexColors[class_name_new] = \
                qcolor_to_hex(class_color)

            row = self._class_table.rowCount()
            self._class_table.insertRow(row)
            self._class_table.setItem(row, self.COLUMN_CLASS_NAME,
                                      QTableWidgetItem(class_name_new))
            self._class_table.setItem(row, self.COLUMN_CLASS_LABEL,
                                      QTableWidgetItem(str(class_label_new)))
            self._class_table.setItem(row, self.COLUMN_CLASS_COUNT,
                                      QTableWidgetItem('0'))
            item = QTableWidgetItem()
            item.setBackground(QBrush(class_color))
            self._class_table.setItem(row, self.COLUMN_CLASS_COLOR, item)
            self._class_table.resizeRowsToContents()
            self._class_table.resizeColumnsToContents()
            self._class_table.setCurrentItem(item)
        else:
            warning(self, "Class names and labels must be unique!",
                    info="Class name '%s' or label '%s' already used." %\
                         (class_name_new, class_label_new))
Exemplo n.º 11
0
    def load_settings(self, filename):
        try:
            self._settings.read(filename)
        except Exception as e:
            critical(self,
                     "Error loading settings file",
                     info="Could not load settings file '%s'." % filename,
                     detail_tb=True)
            self.statusBar().showMessage('Settings not successfully loaded.')
        else:
            self._settings_filename = filename
            title = self.windowTitle().split(' - ')[0]
            self.setWindowTitle('%s - %s[*]' % (title, filename))
            try:
                # reset naming scheme to load config file completely
                nst = self._settings.get_trait("General",  "namingscheme")
                namingscheme_file = self._settings("General", "namingscheme")
                if not namingscheme_file in nst.list_data:
                    self._settings.set("General", "namingscheme", nst.default_value)
                    warning(self, "Unkown naming scheme",
                            ("Your current installation can not use the "
                             "naming scheme '%s'. Resetting to default '%s'"
                             %(namingscheme_file, nst.default_value)))

                for widget in self._tabs:
                    widget.update_input()
            except Exception as e:
                critical(self, "Problem loading settings file.",
                         info="Fix the problem in file '%s' and load the "\
                                "settings file again." % filename,
                         detail_tb=True)
            else:
                # set settings to not-changed (assume no changed since loaded from file)
                self.settings_changed(False)
                # notify tabs about new settings loaded
                for tab in self._tabs:
                    tab.settings_loaded()
                self.statusBar().showMessage('Settings successfully loaded.')
Exemplo n.º 12
0
Arquivo: browser.py Projeto: jni/cecog
    def __init__(self, settings, imagecontainer, parent=None):
        super(Browser, self).__init__(parent)
        self.setWindowTitle('Annotation Browser')

        frame = QFrame(self)
        self.setCentralWidget(frame)

        self._settings = settings
        self._imagecontainer = imagecontainer

        # These params are used by process_image and contour visualization
        self._detect_objects = False
        self._show_objects_by = 'color'
        self._object_region = None
        self._contour_color = '#000000'
        self._show_objects = True

        self.coordinate = Coordinate()

        self.grabGesture(Qt.SwipeGesture)

        self.setStyleSheet("QStatusBar { border-top: 1px solid gray; }")


        layout = QVBoxLayout(frame)
        layout.setContentsMargins(0, 0, 0, 0)

        splitter = QSplitter(Qt.Horizontal, frame)
        layout.addWidget(splitter)

        frame = QFrame(self)
        frame_side = QStackedWidget(splitter)
        splitter.addWidget(frame)
        splitter.addWidget(frame_side)
        splitter.setStretchFactor(0, 1)
        splitter.setStretchFactor(1, 0)
        splitter.setSizes([-1, 80])

        self.coordinate.plate = self._imagecontainer.plates[0]
        self._imagecontainer.set_plate(self.coordinate.plate)

        self.coordinate.channel = self._imagecontainer.channels[0]

        meta_data = self._imagecontainer.get_meta_data()
        self.max_time = meta_data.times[-1]
        self.min_time = meta_data.times[0]
        self.max_frame = meta_data.dim_t-1

        layout = QGridLayout(frame)
        layout.setContentsMargins(0, 0, 0, 0)
        self.image_viewers = {
                             'image'   : ImageViewer(frame, auto_resize=True),
                             'gallery' : GalleryViewer(frame)
                             }

        self.image_viewer = self.image_viewers['image']
        layout.addWidget(self.image_viewer , 0, 0)

        self.image_viewer.zoom_info_updated.connect(self.on_zoom_info_updated)

        self._t_slider = TSlider(Qt.Horizontal, frame)

        self._t_slider.setMinimum(self.min_time)
        self._t_slider.setMaximum(self.max_time)

        self._t_slider.setTickPosition(QSlider.NoTicks)
        self._t_slider.newValue.connect(self.on_time_changed_by_slider,
                                        Qt.DirectConnection)
        self._t_slider.valueChanged.connect(self.timeToolTip)
        self._imagecontainer.check_dimensions()

        if self._imagecontainer.has_timelapse:
            self._t_slider.show()
        else:
            self._t_slider.hide()
        layout.addWidget(self._t_slider, 1, 0)

        self.coordinate.position = meta_data.positions[0]
        self.coordinate.time = self._t_slider.minimum()

        # menus
        act_close = self.create_action('Close',
                                        shortcut=QKeySequence('CTRL+C'),
                                        slot=self.close)

        act_next_t = self.create_action('Next Time-point',
                                        shortcut=QKeySequence('Right'),
                                        slot=self.on_act_next_t)
        act_prev_t = self.create_action('Previous Time-point',
                                        shortcut=QKeySequence('Left'),
                                        slot=self.on_act_prev_t)
        act_next_pos = self.create_action('Next Position',
                                          shortcut=QKeySequence('Shift+Down'),
                                          slot=self.on_act_next_pos)
        act_prev_pos = self.create_action('Previous Position',
                                          shortcut=QKeySequence('Shift+Up'),
                                          slot=self.on_act_prev_pos)
        act_next_plate = self.create_action(
            'Next Plate', shortcut=QKeySequence('Shift+Alt+Down'),
                                            slot=self.on_act_next_plate)
        act_prev_plate = self.create_action(
            'Previous Plate', shortcut=QKeySequence('Shift+Alt+Up'),
                                            slot=self.on_act_prev_plate)
        act_resize = self.create_action('Automatically Resize',
                                         shortcut=QKeySequence('SHIFT+CTRL+R'),
                                         slot=self.on_act_autoresize,
                                         signal='triggered(bool)',
                                         checkable=True,
                                         checked=True)
        self._act_resize = act_resize
        act_zoomfit = self.create_action('Zoom to Fit',
                                         shortcut=QKeySequence('CTRL+0'),
                                         slot=self.on_act_zoomfit)
        act_zoom100 = self.create_action('Actual Size',
                                         shortcut=QKeySequence('CTRL+1'),
                                         slot=self.on_act_zoom100)
        act_zoomin = self.create_action('Zoom In',
                                        shortcut=QKeySequence('CTRL++'),
                                        slot=self.on_act_zoomin)
        act_zoomout = self.create_action('Zoom Out',
                                         shortcut=QKeySequence('CTRL+-'),
                                         slot=self.on_act_zoomout)
        act_refresh = self.create_action('Refresh',
                                         shortcut=QKeySequence('F5'),
                                         slot=self.on_refresh)

        act_fullscreen = self.create_action(
            'Full Screen',
            shortcut=QKeySequence('CTRL+F'),
            slot=self.on_act_fullscreen,
            signal='triggered(bool)',
            checkable=True,
            checked=False
            )
        self._act_fullscreen = act_fullscreen

        act_show_contours = self.create_action(
            'Show Object Contours',
            shortcut=QKeySequence('ALT+C'),
            slot=self.on_act_show_contours,
            signal='triggered(bool)',
            checkable=True,
            checked=self.image_viewer.show_contours
            )
        self._act_show_contours = act_show_contours

        act_anti = self.create_action('Antialiasing',
                                      shortcut=QKeySequence('CTRL+ALT+A'),
                                      slot=self.on_act_antialiasing,
                                      signal='triggered(bool)',
                                      checkable=True,
                                      checked=True)
        act_smooth = self.create_action('Smooth Transform',
                                        shortcut=QKeySequence('CTRL+ALT+S'),
                                        slot=self.on_act_smoothtransform,
                                        signal='triggered(bool)',
                                        checkable=True,
                                        checked=True)
        view_menu = self.menuBar().addMenu('&View')

        self.add_actions(view_menu, (act_resize, None,
                                     act_zoom100, act_zoomfit,
                                     act_zoomin, act_zoomout,
                                     None,
                                     act_prev_t, act_next_t,
                                     act_prev_pos, act_next_pos,
                                     act_prev_plate, act_next_plate,
                                     None,
                                     act_refresh,
                                     act_fullscreen, None,
                                     act_show_contours, None,
                                     act_anti, act_smooth,
                                     None, act_close))

        self._statusbar = QStatusBar(self)
        self.setStatusBar(self._statusbar)

        toolbar = self.addToolBar('Toolbar')
        toolbar.setObjectName('Toolbar')
        toolbar.setMovable(False)
        toolbar.setFloatable(False)

        # fallback if no Segmentation plugins have been specified
        rdict = self._region_names()
        if len(rdict) > 0:
            self._object_region = rdict.keys()[0].split(' - ')
        else:
            self._object_region = ('Primary', 'primary')

        # create a new ModuleManager with a QToolbar and QStackedFrame
        self._module_manager = ModuleManager(toolbar, frame_side)

        NavigationModule(self._module_manager, self, self._imagecontainer)
        defautl_display_module = DisplayModule(
            self._module_manager, self, self._imagecontainer, rdict)

        self.set_display_module(defautl_display_module)
        AnnotationModule(self._module_manager, self, self._settings,
                         self._imagecontainer)

        try:
            CellH5EventModule(self._module_manager,
                              self, self._settings, self._imagecontainer)
        except Exception as e:
            warning(self, str(e))

        # set the Navigation module activated
        self._module_manager.activate_tab(NavigationModule.NAME)

        self.layout = layout
        # process and display the first image
        self._restore_geometry()
        self._process_image()
Exemplo n.º 13
0
    def __init__(self, settings, imagecontainer, parent=None):
        super(Browser, self).__init__(parent)
        self.setWindowTitle('Annotation Browser')

        frame = QFrame(self)
        self.setCentralWidget(frame)

        self._settings = settings
        self._imagecontainer = imagecontainer

        # These params are used by process_image and contour visualization
        self._detect_objects = False
        self._show_objects_by = 'color'
        self._object_region = None
        self._contour_color = '#000000'
        self._show_objects = True

        self.coordinate = Coordinate()

        self.grabGesture(Qt.SwipeGesture)

        self.setStyleSheet("QStatusBar { border-top: 1px solid gray; }")

        layout = QVBoxLayout(frame)
        layout.setContentsMargins(0, 0, 0, 0)

        splitter = QSplitter(Qt.Horizontal, frame)
        layout.addWidget(splitter)

        frame = QFrame(self)
        frame_side = QStackedWidget(splitter)
        splitter.addWidget(frame)
        splitter.addWidget(frame_side)
        splitter.setStretchFactor(0, 1)
        splitter.setStretchFactor(1, 0)
        splitter.setSizes([-1, 80])

        self.coordinate.plate = self._imagecontainer.plates[0]
        self._imagecontainer.set_plate(self.coordinate.plate)

        self.coordinate.channel = self._imagecontainer.channels[0]

        meta_data = self._imagecontainer.get_meta_data()
        self.max_time = meta_data.times[-1]
        self.min_time = meta_data.times[0]
        self.max_frame = meta_data.dim_t - 1

        layout = QGridLayout(frame)
        layout.setContentsMargins(0, 0, 0, 0)
        self.image_viewers = {
            'image': ImageViewer(frame, auto_resize=True),
            'gallery': GalleryViewer(frame)
        }

        self.image_viewer = self.image_viewers['image']
        layout.addWidget(self.image_viewer, 0, 0)

        self.image_viewer.zoom_info_updated.connect(self.on_zoom_info_updated)

        self._t_slider = TSlider(Qt.Horizontal, frame)

        self._t_slider.setMinimum(self.min_time)
        self._t_slider.setMaximum(self.max_time)

        self._t_slider.setTickPosition(QSlider.NoTicks)
        self._t_slider.newValue.connect(self.on_time_changed_by_slider,
                                        Qt.DirectConnection)
        self._t_slider.valueChanged.connect(self.timeToolTip)
        self._imagecontainer.check_dimensions()

        if self._imagecontainer.has_timelapse:
            self._t_slider.show()
        else:
            self._t_slider.hide()
        layout.addWidget(self._t_slider, 1, 0)

        self.coordinate.position = meta_data.positions[0]
        self.coordinate.time = self._t_slider.minimum()

        # menus
        act_close = self.create_action('Close',
                                       shortcut=QKeySequence('CTRL+C'),
                                       slot=self.close)

        act_next_t = self.create_action('Next Time-point',
                                        shortcut=QKeySequence('Right'),
                                        slot=self.on_act_next_t)
        act_prev_t = self.create_action('Previous Time-point',
                                        shortcut=QKeySequence('Left'),
                                        slot=self.on_act_prev_t)
        act_next_pos = self.create_action('Next Position',
                                          shortcut=QKeySequence('Shift+Down'),
                                          slot=self.on_act_next_pos)
        act_prev_pos = self.create_action('Previous Position',
                                          shortcut=QKeySequence('Shift+Up'),
                                          slot=self.on_act_prev_pos)
        act_next_plate = self.create_action(
            'Next Plate',
            shortcut=QKeySequence('Shift+Alt+Down'),
            slot=self.on_act_next_plate)
        act_prev_plate = self.create_action(
            'Previous Plate',
            shortcut=QKeySequence('Shift+Alt+Up'),
            slot=self.on_act_prev_plate)
        act_resize = self.create_action('Automatically Resize',
                                        shortcut=QKeySequence('SHIFT+CTRL+R'),
                                        slot=self.on_act_autoresize,
                                        signal='triggered(bool)',
                                        checkable=True,
                                        checked=True)
        self._act_resize = act_resize
        act_zoomfit = self.create_action('Zoom to Fit',
                                         shortcut=QKeySequence('CTRL+0'),
                                         slot=self.on_act_zoomfit)
        act_zoom100 = self.create_action('Actual Size',
                                         shortcut=QKeySequence('CTRL+1'),
                                         slot=self.on_act_zoom100)
        act_zoomin = self.create_action('Zoom In',
                                        shortcut=QKeySequence('CTRL++'),
                                        slot=self.on_act_zoomin)
        act_zoomout = self.create_action('Zoom Out',
                                         shortcut=QKeySequence('CTRL+-'),
                                         slot=self.on_act_zoomout)
        act_refresh = self.create_action('Refresh',
                                         shortcut=QKeySequence('F5'),
                                         slot=self.on_refresh)

        act_fullscreen = self.create_action('Full Screen',
                                            shortcut=QKeySequence('CTRL+F'),
                                            slot=self.on_act_fullscreen,
                                            signal='triggered(bool)',
                                            checkable=True,
                                            checked=False)
        self._act_fullscreen = act_fullscreen

        act_show_contours = self.create_action(
            'Show Object Contours',
            shortcut=QKeySequence('ALT+C'),
            slot=self.on_act_show_contours,
            signal='triggered(bool)',
            checkable=True,
            checked=self.image_viewer.show_contours)
        self._act_show_contours = act_show_contours

        act_anti = self.create_action('Antialiasing',
                                      shortcut=QKeySequence('CTRL+ALT+A'),
                                      slot=self.on_act_antialiasing,
                                      signal='triggered(bool)',
                                      checkable=True,
                                      checked=True)
        act_smooth = self.create_action('Smooth Transform',
                                        shortcut=QKeySequence('CTRL+ALT+S'),
                                        slot=self.on_act_smoothtransform,
                                        signal='triggered(bool)',
                                        checkable=True,
                                        checked=True)
        view_menu = self.menuBar().addMenu('&View')

        self.add_actions(
            view_menu,
            (act_resize, None, act_zoom100, act_zoomfit, act_zoomin,
             act_zoomout, None, act_prev_t, act_next_t, act_prev_pos,
             act_next_pos, act_prev_plate, act_next_plate, None, act_refresh,
             act_fullscreen, None, act_show_contours, None, act_anti,
             act_smooth, None, act_close))

        self._statusbar = QStatusBar(self)
        self.setStatusBar(self._statusbar)

        toolbar = self.addToolBar('Toolbar')
        toolbar.setObjectName('Toolbar')
        toolbar.setMovable(False)
        toolbar.setFloatable(False)

        # fallback if no Segmentation plugins have been specified
        rdict = self._region_names()
        if len(rdict) > 0:
            self._object_region = rdict.keys()[0].split(' - ')
        else:
            self._object_region = ('Primary', 'primary')

        # create a new ModuleManager with a QToolbar and QStackedFrame
        self._module_manager = ModuleManager(toolbar, frame_side)

        NavigationModule(self._module_manager, self, self._imagecontainer)
        defautl_display_module = DisplayModule(self._module_manager, self,
                                               self._imagecontainer, rdict)

        self.set_display_module(defautl_display_module)
        AnnotationModule(self._module_manager, self, self._settings,
                         self._imagecontainer)

        try:
            CellH5EventModule(self._module_manager, self, self._settings,
                              self._imagecontainer)
        except Exception as e:
            warning(self, str(e))

        # set the Navigation module activated
        self._module_manager.activate_tab(NavigationModule.NAME)

        self.layout = layout
        # process and display the first image
        self._restore_geometry()
        self._process_image()
Exemplo n.º 14
0
    def update_event_table(self, coord):

        pos = self.ch5file.get_position_from_coord(coord)

        try:
            events = pos.get_event_items()
        except KeyError as ke:
            exception(self, "No event data found in CellH5. Make sure tracking and event selection has been enabled! ('%s)'"% str(ke))
            return
        except Exception as e:
            exception(self, "An error has occured ('%s)'"% str(e))
            return
        
        if len(events) == 0:
            warning(self, "No event data found...")
            return

        self.event_table.setRowCount(0)

        selected_track = []
        start_ids = map(lambda x: x[1][0], events)
        time_idxs = pos.get_time_indecies(start_ids)

        self.tracks = []
        cnt = 0
        for (e_id, e), time_idx in zip(events, time_idxs):
            QApplication.processEvents()
            if self._cb_track.checkState():
                track = e[:-1] + pos.track_first(e[-1])
            else:
                track = e


            selected_track.append(e)
            self.event_table.insertRow(cnt)

            event_id_item = QTableWidgetItem()
            event_id_item.setData(Qt.DisplayRole, e_id)

            self.event_table.setItem(cnt, 0, event_id_item)
            tmp_i = QTableWidgetItem()
            tmp_j = QTableWidgetItem()

            # to make sorting according to numbers
            tmp_i.setData(Qt.DisplayRole, len(track))
            tmp_j.setData(Qt.DisplayRole, int(time_idx))

            self.event_table.setItem(cnt, 1, tmp_i)
            self.event_table.setItem(cnt, 2, tmp_j)

            if cnt == 0:
                self.event_table.resizeRowsToContents()
                self.event_table.resizeColumnsToContents()

            cnt+=1
            self.tracks.append(track)


        self.event_table.resizeRowsToContents()
        self.event_table.resizeColumnsToContents()
        self.event_table.setSortingEnabled(True)
Exemplo n.º 15
0
    def update_event_table(self, coord):

        pos = self.ch5file.get_position_from_coord(coord)

        try:
            events = pos.get_event_items()
        except KeyError as ke:
            exception(
                self,
                "No event data found in CellH5. Make sure tracking and event selection has been enabled! ('%s)'"
                % str(ke))
            return
        except Exception as e:
            exception(self, "An error has occured ('%s)'" % str(e))
            return

        if len(events) == 0:
            warning(self, "No event data found...")
            return

        self.event_table.setRowCount(0)

        selected_track = []
        start_ids = map(lambda x: x[1][0], events)
        time_idxs = pos.get_time_indecies(start_ids)

        self.tracks = []
        cnt = 0
        for (e_id, e), time_idx in zip(events, time_idxs):
            QApplication.processEvents()
            if self._cb_track.checkState():
                track = e[:-1] + pos.track_first(e[-1])
            else:
                track = e

            selected_track.append(e)
            self.event_table.insertRow(cnt)

            event_id_item = QTableWidgetItem()
            event_id_item.setData(Qt.DisplayRole, e_id)

            self.event_table.setItem(cnt, 0, event_id_item)
            tmp_i = QTableWidgetItem()
            tmp_j = QTableWidgetItem()

            # to make sorting according to numbers
            tmp_i.setData(Qt.DisplayRole, len(track))
            tmp_j.setData(Qt.DisplayRole, int(time_idx))

            self.event_table.setItem(cnt, 1, tmp_i)
            self.event_table.setItem(cnt, 2, tmp_j)

            if cnt == 0:
                self.event_table.resizeRowsToContents()
                self.event_table.resizeColumnsToContents()

            cnt += 1
            self.tracks.append(track)

        self.event_table.resizeRowsToContents()
        self.event_table.resizeColumnsToContents()
        self.event_table.setSortingEnabled(True)