示例#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
示例#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 = 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
示例#3
0
文件: cluster.py 项目: imcf/cecog
    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
示例#4
0
    def _on_saveas_classifier(self, path=None):
        learner = self._learner
        if path is None:
            path = os.path.expanduser("~")
            result = QFileDialog.getExistingDirectory(
                self, 'Save to classifier directory', os.path.abspath(path))
        else:
            result = path

        if result:
            if self._save_classifier(result):
                try:
                    path2 = learner.annotations_dir
                    filenames = os.listdir(path2)
                    filenames = [os.path.join(path2, f) for f in filenames
                                 if os.path.isfile(os.path.join(path2, f)) and
                                 os.path.splitext(f)[1].lower() == '.xml']
                    fmt = time.strftime('_backup__%Y%m%d_%H%M%S')
                    path_backup = os.path.join(path2, fmt)
                    safe_mkdirs(path_backup)
                    for filename in filenames:
                        shutil.copy2(filename, path_backup)
                        os.remove(filename)
                    self._annotations.export_to_xml(path2,
                                                    learner.class_labels,
                                                    self._imagecontainer)
                except:
                    exception(self, "Problems saving annotation data...")
                else:
                    information(self, "Classifier successfully saved",
                                "Class definitions and annotations "
                                "successfully saved to '%s'." % result)
                finally:
                    coord = self.browser.get_coordinate()
                    self._imagecontainer.set_plate(coord.plate)
示例#5
0
    def _on_open_classifier(self):
        path = self._learner.clf_dir
        result = QFileDialog.getExistingDirectory(self, 'Open classifier directory', os.path.abspath(path))
        if result:
            learner = self._load_classifier(result)
            if not learner is None:
                self._learner = learner
                self._update_class_definition_table()

                self._activate_objects_for_image(False, clear=True)
                path2 = learner.annotations_dir
                try:
                    has_invalid = self._annotations.import_from_xml(path2,
                                                                    learner.class_names,
                                                                    self._imagecontainer)
                except:
                    exception(self, "Problems loading annotation data...")
                    self._learner = self._init_new_classifier()
                else:
                    self._activate_objects_for_image(True)
                    self._update_class_table()
                    if self._class_table.rowCount() > 0:
                        self._class_table.setCurrentCell(0, self.COLUMN_CLASS_NAME)
                    else:
                        self._current_class = None

                    information(self, "Classifier successfully loaded",
                                "Class definitions and annotations "
                                "successfully loaded from '%s'." % result)
                finally:
                    coord = self.browser.get_coordinate()
                    self._imagecontainer.set_plate(coord.plate)
示例#6
0
文件: cluster.py 项目: imcf/cecog
    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
示例#7
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


        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)
示例#8
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

        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)
示例#9
0
 def _save_classifier(self, path):
     learner = self._learner
     success = True
     try:
         learner.clf_dir = path
         learner.saveDefinition()
     except:
         exception(self, 'Error on saving classifier')
         success = False
     return success
示例#10
0
 def _update_job_status(self):
     try:
         self.dlg = ProgressDialog("updating job status...", None, 0, 0, self)
         func = lambda: self._service.get_job_status(self._jobid)
         self.dlg.exec_(func)
         txt = self.dlg.getTargetResult()
     except Exception as e:
         exception(self, 'Error on retrieve job status (%s)' %str(e))
     else:
         self._label_jobstatus.setText(txt)
     return txt
示例#11
0
文件: annotation.py 项目: cmci/cecog
 def _save_classifier(self, path):
     learner = self._learner
     success = True
     try:
         learner.set_env_path(path)
         learner.initEnv()
         learner.saveDefinition()
     except:
         exception(self, 'Error on saving classifier')
         success = False
     return success
示例#12
0
文件: cluster.py 项目: cmci/cecog
 def _update_job_status(self):
     try:
         self.dlg = waitingProgressDialog('Please wait for the cluster update...', self)
         self.dlg.setTarget(self._service.get_job_status, self._jobid)
         self.dlg.exec_()
         txt = self.dlg.getTargetResult()
     except:
         exception(self, 'Error on retrieve job status')
     else:
         self._label_jobstatus.setText(txt)
     return txt
示例#13
0
 def _load_classifier(self, path):
     learner = None
     try:
         learner = BaseLearner(path, None, None)
     except:
         exception(self, 'Error on loading classifier')
     else:
         state = learner.state
         if state['has_definition']:
             learner.loadDefinition()
     return learner
示例#14
0
 def _load_classifier(self, path):
     learner = None
     try:
         learner = BaseLearner(path, None, None)
     except:
         exception(self, 'Error on loading classifier')
     else:
         state = learner.state
         if state['has_definition']:
             learner.loadDefinition()
     return learner
示例#15
0
    def load_classifier(self, check=True):

        _resolve = lambda x,y: self._settings.get(x, '%s_%s' % (self._channel, y))
        env_path = convert_package_path(_resolve('Classification',
                                                 'classification_envpath'))
        classifier_infos = {'strEnvPath' : env_path,
                            #'strModelPrefix' : _resolve('Classification', 'classification_prefix'),
                            'strChannelId' : _resolve('ObjectDetection', 'channelid'),
                            'strRegionId' : _resolve('Classification', 'classification_regionname'),
                            }
        try:
            self._learner = CommonClassPredictor(dctCollectSamples=classifier_infos)
        except:
            exception(self, 'Error on loading classifier.')
        else:
            result = self._learner.check()
            if check:
                b = lambda x: 'Yes' if x else 'No'
                msg =  'Classifier path: %s\n' % result['path_env']
                msg += 'Found class definition: %s\n' % b(result['has_definition'])
                msg += 'Found annotations: %s\n' % b(result['has_path_annotations'])
                msg += 'Can you pick new samples? %s\n\n' % b(self.is_pick_samples())
                msg += 'Found ARFF file: %s\n' % b(result['has_arff'])
                msg += 'Can you train a classifier? %s\n\n' % b(self.is_train_classifier())
                msg += 'Found SVM model: %s\n' % b(result['has_model'])
                msg += 'Found SVM range: %s\n' % b(result['has_range'])
                msg += 'Can you apply the classifier to images? %s\n\n' % b(self.is_apply_classifier())
                msg += 'Found samples: %s\n' % b(result['has_path_samples'])
                msg += 'Sample images are only used for visualization and annotation control at the moment.'

                txt = '%s classifier inspection results' % self._channel
                information(self, txt, info=msg)

            if result['has_arff']:
                self._learner.importFromArff()
                nr_features_prev = len(self._learner.lstFeatureNames)
                removed_features = self._learner.filterData(apply=False)
                nr_features = nr_features_prev - len(removed_features)
                self._label_features.setText(self.LABEL_FEATURES % (nr_features, nr_features_prev))
                self._label_features.setToolTip("removed %d features containing NA values:\n%s" %
                                                (len(removed_features), "\n".join(removed_features)))

            if result['has_definition']:
                self._learner.loadDefinition()

            if result['has_conf']:
                c, g, conf = self._learner.importConfusion()
                self._set_info(c, g, conf)
                self._init_conf_table(conf)
                self._update_conf_table(conf)
            else:
                conf = None
                self._init_conf_table(conf)
            self._set_info_table(conf)
示例#16
0
 def _on_terminate_job(self):
     try:
         self.dlg = ProgressDialog("terminating jobs...", None, 0, 0, self)
         func = lambda: self._service.control_job(self._jobid, JOB_CONTROL_TERMINATE)
         self.dlg.exec_(func)
     except Exception as e:
         exception(self, 'Error on job termination (%s)' %str(e))
     else:
         self._btn_toogle.setChecked(False)
         self._toggle_state = JOB_CONTROL_SUSPEND
         self._btn_toogle.setText(self._toggle_state)
         self._update_job_status()
示例#17
0
文件: cluster.py 项目: imcf/cecog
 def _update_job_status(self):
     try:
         self.dlg = waitingProgressDialog(
             'Please wait for the cluster update...', self)
         self.dlg.setTarget(self._service.get_job_status, self._jobid)
         self.dlg.exec_()
         txt = self.dlg.getTargetResult()
     except:
         exception(self, 'Error on retrieve job status')
     else:
         self._label_jobstatus.setText(txt)
     return txt
示例#18
0
文件: cluster.py 项目: cmci/cecog
 def _on_terminate_job(self):
     try:
         self.dlg = waitingProgressDialog("Please wait until the job has been terminated...", self)
         self.dlg.setTarget(self._service.control_job, self._jobid, JOB_CONTROL_TERMINATE)
         self.dlg.exec_()
     except:
         exception(self, 'Error on job termination')
     else:
         self._btn_toogle.setChecked(False)
         self._toggle_state = JOB_CONTROL_SUSPEND
         self._btn_toogle.setText(self._toggle_state)
         self._update_job_status()
示例#19
0
 def _on_terminate_job(self):
     try:
         self.dlg = ProgressDialog("terminating jobs...", None, 0, 0, self)
         func = lambda: self._service.control_job(self._jobid, JOB_CONTROL_TERMINATE)
         self.dlg.exec_(func)
     except Exception as e:
         exception(self, 'Error on job termination (%s)' %str(e))
     else:
         self._btn_toogle.setChecked(False)
         self._toggle_state = JOB_CONTROL_SUSPEND
         self._btn_toogle.setText(self._toggle_state)
         self._update_job_status()
示例#20
0
    def _update_job_status(self):

        try:
            self.dlg = ProgressDialog("updating job status...", None, 0, 0, self)

            func = lambda: self._service.get_job_status(self._jobid)
            self.dlg.exec_(func)
            txt = self.dlg.getTargetResult()
        except Exception as e:
            exception(self, 'Error on retrieve job status (%s)' %str(e))
        else:
            self._label_jobstatus.setText(txt)
        return txt
示例#21
0
    def _load_classifier(self, path):
        learner = None
        try:
            learner = BaseLearner(path, None, None)
        except:
            exception(self, 'Error on loading classifier')
        else:
            result = learner.check()
            #if result['has_arff']:
            #    self._learner.importFromArff()

            if result['has_definition']:
                learner.loadDefinition()
        return learner
示例#22
0
文件: cluster.py 项目: imcf/cecog
 def _on_terminate_job(self):
     try:
         self.dlg = waitingProgressDialog(
             "Please wait until the job has been terminated...", self)
         self.dlg.setTarget(self._service.control_job, self._jobid,
                            JOB_CONTROL_TERMINATE)
         self.dlg.exec_()
     except:
         exception(self, 'Error on job termination')
     else:
         self._btn_toogle.setChecked(False)
         self._toggle_state = JOB_CONTROL_SUSPEND
         self._btn_toogle.setText(self._toggle_state)
         self._update_job_status()
示例#23
0
 def _check_host_url(self):
     url = urlparse.urlparse(self._host_url)
     try:
         test_sock = socket.create_connection((url.hostname, url.port), timeout=1)
         test_sock.shutdown(2)
         test_sock.close()
     except:
         try:
             url = urlparse.urlparse(self._host_url_fallback)
             test_sock = socket.create_connection((url.hostname, url.port), timeout=1)
             test_sock.shutdown(2)
             test_sock.close()
             self._host_url = self._host_url_fallback
         except:
             exception(self, 'Error on connecting to cluster control service. Please check your config.ini')
示例#24
0
 def _check_host_url(self):
     url = urlparse.urlparse(self._host_url)
     try:
         test_sock = socket.create_connection((url.hostname, url.port), timeout=1)
         test_sock.shutdown(2)
         test_sock.close()
     except:
         try:
             url = urlparse.urlparse(self._host_url_fallback)
             test_sock = socket.create_connection((url.hostname, url.port), timeout=1)
             test_sock.shutdown(2)
             test_sock.close()
             self._host_url = self._host_url_fallback
         except:
             exception(self, 'Error on connecting to cluster control service. Please check your config.ini')
示例#25
0
 def _on_toggle_job(self):
     try:
         self.dlg = ProgressDialog("suspending jobs...", None, 0, 0, self)
         func = lambda: self._service.control_job(self._jobid, self._toggle_state)
         self.dlg.exec_(func)
     except Exception as e:
         self._toggle_state = JOB_CONTROL_SUSPEND
         self._btn_toogle.setChecked(False)
         exception(self, 'Error on toggle job status (%s)' %str(e))
     else:
         if self._toggle_state == JOB_CONTROL_SUSPEND:
             self._toggle_state = JOB_CONTROL_RESUME
         else:
             self._toggle_state = JOB_CONTROL_SUSPEND
         self._update_job_status()
     self._btn_toogle.setText(self._toggle_state)
示例#26
0
 def _on_toggle_job(self):
     try:
         self.dlg = ProgressDialog("suspending jobs...", None, 0, 0, self)
         func = lambda: self._service.control_job(self._jobid, self._toggle_state)
         self.dlg.exec_(func)
     except Exception as e:
         self._toggle_state = JOB_CONTROL_SUSPEND
         self._btn_toogle.setChecked(False)
         exception(self, 'Error on toggle job status (%s)' %str(e))
     else:
         if self._toggle_state == JOB_CONTROL_SUSPEND:
             self._toggle_state = JOB_CONTROL_RESUME
         else:
             self._toggle_state = JOB_CONTROL_SUSPEND
         self._update_job_status()
     self._btn_toogle.setText(self._toggle_state)
示例#27
0
文件: cluster.py 项目: cmci/cecog
 def _on_toggle_job(self):
     try:
         self.dlg = waitingProgressDialog("Please wait until the job has been suspended/resumed...", self)
         self.dlg.setTarget(self._service.control_job, self._jobid, self._toggle_state)
         self.dlg.exec_()
     except:
         self._toggle_state = JOB_CONTROL_SUSPEND
         self._btn_toogle.setChecked(False)
         exception(self, 'Error on toggle job status')
     else:
         if self._toggle_state == JOB_CONTROL_SUSPEND:
             self._toggle_state = JOB_CONTROL_RESUME
         else:
             self._toggle_state = JOB_CONTROL_SUSPEND
         self._update_job_status()
     self._btn_toogle.setText(self._toggle_state)
示例#28
0
文件: cluster.py 项目: imcf/cecog
    def _on_submit_job(self):
        self._submit_settings.set_section(SECTION_NAME_GENERAL)
        if not self._submit_settings.get2('constrain_positions'):
            positions = []
            for plate_id in self.imagecontainer.plates:
                self.imagecontainer.set_plate(plate_id)
                meta_data = self.imagecontainer.get_meta_data()
                positions += [
                    '%s___%s' % (plate_id, p) for p in meta_data.positions
                ]
            self._submit_settings.set2('positions', ','.join(positions))
            nr_items = len(positions)
        else:
            positions = self._submit_settings.get2('positions')
            nr_items = len(positions.split(','))

        # FIXME: we need to get the current value for 'position_granularity'
        settings_dummy = ProcessingFrame.get_special_settings(self._settings)
        position_granularity = settings_dummy.get(SECTION_NAME_CLUSTER,
                                                  'position_granularity')

        path_out = self._submit_settings.get2('pathout')
        emails = str(self._txt_mail.text()).split(',')
        try:
            self.dlg = waitingProgressDialog(
                'Please wait until the job has been submitted...', self)
            self.dlg.setTarget(self._service.submit_job, 'cecog_batch',
                               self._submit_settings.to_string(), path_out,
                               emails, nr_items, position_granularity, VERSION)
            self.dlg.exec_()
            jobid = self.dlg.getTargetResult()
        except:
            exception(self, 'Error on job submission')
        else:
            # FIXME: no idea how DRMAA 1.0 compatible this is
            if type(jobid) == types.ListType:
                self._jobid = ','.join(jobid)
                main_jobid = jobid[0].split('.')[0]
            else:
                self._jobid = str(jobid)
                main_jobid = jobid
            self._txt_jobid.setText(self._jobid)
            self._update_job_status()
            information(
                self, 'Job submitted successfully',
                "Job successfully submitted to the cluster.\nJob ID: %s, items: %d"
                % (main_jobid, nr_items))
示例#29
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_()
示例#30
0
    def _on_submit_job(self):
        self._submit_settings.set_section(SECTION_NAME_GENERAL)
        if not self._submit_settings.get2('constrain_positions'):
            positions = []

            for plate_id in self.imagecontainer.plates:
                self.imagecontainer.set_plate(plate_id)
                meta_data = self.imagecontainer.get_meta_data()
                positions += ['%s___%s' % (plate_id, p) for p in meta_data.positions]
            self._submit_settings.set2('positions', ','.join(positions))
            nr_items = len(positions)
        else:
            positions = self._submit_settings.get2('positions')
            nr_items = len(positions.split(','))

        # FIXME: we need to get the current value for 'position_granularity'
        settings_dummy = self._clusterframe.get_special_settings(self._settings)
        position_granularity = settings_dummy.get('Cluster', 'position_granularity')

        path_out = self._submit_settings.get2('pathout')
        emails = str(self._txt_mail.text()).split(',')
        try:
            self.dlg = ProgressDialog("submitting jobs...", None, 0, 0, self)
            settings_str = self._submit_settings.to_string()
            func = lambda: self._service.submit_job('cecog_batch', settings_str,
                                                    path_out, emails, nr_items,
                                                    position_granularity, VERSION)
            self.dlg.exec_(func)
            jobid = self.dlg.getTargetResult()
        except Exception as e:
            exception(self, 'Error on job submission (%s)' %str(e))
        else:
            # FIXME: no idea how DRMAA 1.0 compatible this is
            if type(jobid) == types.ListType:
                self._jobid = ','.join(jobid)
                main_jobid = jobid[0].split('.')[0]
            else:
                self._jobid = str(jobid)
                main_jobid = jobid
            self._txt_jobid.setText(self._jobid)
            self._update_job_status()
            information(self, 'Job submitted successfully',
                        "Job successfully submitted to the cluster.\nJob ID: %s, items: %d" % (main_jobid, nr_items))
示例#31
0
文件: cluster.py 项目: imcf/cecog
 def _on_toggle_job(self):
     try:
         self.dlg = waitingProgressDialog(
             "Please wait until the job has been suspended/resumed...",
             self)
         self.dlg.setTarget(self._service.control_job, self._jobid,
                            self._toggle_state)
         self.dlg.exec_()
     except:
         self._toggle_state = JOB_CONTROL_SUSPEND
         self._btn_toogle.setChecked(False)
         exception(self, 'Error on toggle job status')
     else:
         if self._toggle_state == JOB_CONTROL_SUSPEND:
             self._toggle_state = JOB_CONTROL_RESUME
         else:
             self._toggle_state = JOB_CONTROL_SUSPEND
         self._update_job_status()
     self._btn_toogle.setText(self._toggle_state)
示例#32
0
文件: cluster.py 项目: cmci/cecog
    def _on_submit_job(self):
        self._submit_settings.set_section(SECTION_NAME_GENERAL)
        if not self._submit_settings.get2('constrain_positions'):
            # FIXME:
            imagecontainer = qApp._main_window._imagecontainer
            positions = []
            for plate_id in imagecontainer.plates:
                imagecontainer.set_plate(plate_id)
                meta_data = imagecontainer.get_meta_data()
                positions += ['%s___%s' % (plate_id, p) for p in meta_data.positions]
            self._submit_settings.set2('positions', ','.join(positions))
            nr_items = len(positions)
        else:
            positions = self._submit_settings.get2('positions')
            nr_items = len(positions.split(','))

        # FIXME: we need to get the current value for 'position_granularity'
        settings_dummy = ProcessingFrame.get_special_settings(self._settings)
        position_granularity = settings_dummy.get(SECTION_NAME_CLUSTER, 'position_granularity')

        path_out = self._submit_settings.get2('pathout')
        emails = str(self._txt_mail.text()).split(',')
        try:
            self.dlg = waitingProgressDialog('Please wait until the job has been submitted...', self)
            self.dlg.setTarget(self._service.submit_job,
                          'cecog_batch', self._submit_settings.to_string(), path_out, emails, nr_items,
                          position_granularity, VERSION)
            self.dlg.exec_()
            jobid = self.dlg.getTargetResult()
        except:
            exception(self, 'Error on job submission')
        else:
            # FIXME: no idea how DRMAA 1.0 compatible this is
            if type(jobid) == types.ListType:
                self._jobid = ','.join(jobid)
                main_jobid = jobid[0].split('.')[0]
            else:
                self._jobid = str(jobid)
                main_jobid = jobid
            self._txt_jobid.setText(self._jobid)
            self._update_job_status()
            information(self, 'Job submitted successfully',
                        "Job successfully submitted to the cluster.\nJob ID: %s, items: %d" % (main_jobid, nr_items))
示例#33
0
 def _on_anntable_changed(self, current, previous):
     if not current is None:
         if self._imagecontainer.has_multiple_plates:
             offset = 0
             plate = self._ann_table.item(current.row(),
                                          self.COLUMN_ANN_PLATE).text()
         else:
             offset = 1
             plate = self._imagecontainer.plates[0]
         col = self.COLUMN_ANN_POSITION - offset
         position = self._ann_table.item(current.row(), col).text()
         col = self.COLUMN_ANN_TIME - offset
         time = int(self._ann_table.item(current.row(), col).text())
         coordinate = Coordinate(plate=plate, position=position, time=time)
         try:
             self.browser.set_coordinate(coordinate)
         except:
             exception(self, "Selected coordinate was not found. "
                             "Make sure the data and annotation match and "
                             "that the data was scanned/imported correctly.")
示例#34
0
    def _on_load_input(self):
        txt = "Error scanning image structure"
        path_in = self._settings.get(SECTION_NAME_GENERAL, 'pathin')
        if path_in == '':
            critical(self, txt, "Image path must be defined.")
        elif not os.path.isdir(path_in) and \
             not os.path.isdir(os.path.join(self.environ.package_dir, path_in)):
            critical(self, txt, "Image path '%s' not found." % path_in)
        else:
            try:
                infos = list(ImageContainer.iter_check_plates(self._settings))
            except:
                exception(self, txt)
            else:
                found_any = numpy.any([not info[3] is None for info in infos])
                cancel = False
                if found_any:
                    found_plates = [info[0] for info in infos
                                    if not info[3] is None]
                    missing_plates = [info[0] for info in infos
                                      if info[3] is None]
                    has_missing = len(missing_plates) > 0
                    txt = '%s plates were already scanned.\nDo you want ' \
                          'to rescan the file structure(s)? ' \
                          'This can take several minutes.' % \
                          ('Some' if has_missing else 'All')
                    title = 'Rescan input structure?'

                    box = QMessageBox(QMessageBox.Question, title, title,
                                      QMessageBox.Cancel, self, Qt.Sheet)
                    box.setWindowModality(Qt.WindowModal)
                    box.setInformativeText(txt)
                    box.setDetailedText('Plates with scanned structure: \n%s\n'
                                        '\nPlates without scanned structure: '
                                        '\n%s' %
                                        ('\n'.join(found_plates),
                                         '\n'.join(missing_plates)))
                    if not has_missing:
                        btn1 = QtGui.QPushButton('No', box)
                        box.addButton(btn1, QMessageBox.NoRole)
                        box.setDefaultButton(btn1)
                    elif len(found_plates) > 0:
                        btn1 = QtGui.QPushButton('Rescan missing', box)
                        box.addButton(btn1, QMessageBox.YesRole)
                        box.setDefaultButton(btn1)
                    else:
                        btn1 = None

                    btn2 = QtGui.QPushButton('Rescan all', box)
                    box.addButton(btn2, QMessageBox.YesRole)

                    if box.exec_() == QMessageBox.Cancel:
                        cancel = True
                    else:
                        btn = box.clickedButton()
                        if btn == btn1:
                            if has_missing:
                                scan_plates = dict([(info[0], info[0] in missing_plates) for info in infos])
                            else:
                                scan_plates = dict((info[0], False) for info in infos)
                        else:
                            scan_plates = dict((info[0], True) for info in infos)
                else:
                    has_multiple = self._settings.get(SECTION_NAME_GENERAL,
                                                      "has_multiple_plates")
                    if not question(self, "No structure data found",
                                    "Are you sure to scan %s?\n\nThis can take "
                                    "several minutes depending on the number of"
                                    " images." %
                                    ("%d plates" % len(infos) if has_multiple
                                     else "one plate")):
                        cancel = True
                    scan_plates = dict((info[0], True) for info in infos)
                if not cancel:
                    self._load_image_container(infos, scan_plates)
示例#35
0
    def _process_image(self, ):
        self.image_viewer.remove_objects()
        settings = _ProcessorMixin.get_special_settings(self._settings)
        settings.set_section('General')
        settings.set2('constrain_positions', True)
        settings.set2('positions', self.coordinate.position)
        settings.set2('redofailedonly', False)
        settings.set2('framerange', True)
        settings.set2('framerange_begin', self.coordinate.time)
        settings.set2('framerange_end', self.coordinate.time)

        settings.set_section('Processing')
        _classify_objects = self._show_objects_by == 'classification'

        settings.set2('primary_classification', _classify_objects)
        settings.set2('secondary_classification', _classify_objects)
        settings.set2('tertiary_classification', _classify_objects)
        settings.set2('merged_classification', _classify_objects)
        settings.set2('primary_featureextraction', _classify_objects)
        settings.set2('secondary_featureextraction', _classify_objects)

        settings.set2('objectdetection', self._detect_objects)
        settings.set2('tracking', False)
        settings.set_section('Output')
        settings.set2('rendering_contours_discwrite', False)
        settings.set2('rendering_class_discwrite', False)
        settings.set2('export_object_counts', False)
        settings.set2('export_object_details', False)
        settings.set2('export_track_data', False)
        settings.set2('hdf5_create_file', False)
        settings.set_section('Classification')
        settings.set2('collectsamples', False)
        settings.set('General', 'rendering', {})
        settings.set('General', 'rendering_class', {})
        settings.set('Output', 'events_export_gallery_images', False)

        # turn of output:
        settings.set('Output', 'export_object_counts', False)
        settings.set('Output', 'export_object_details', False)
        settings.set('Output', 'export_file_names', False)
        settings.set('Output', 'events_export_gallery_images', False)
        settings.set('Output', 'export_track_data', False)
        settings.set('Output', 'export_tracking_as_dot', False)

        nchannels = len(self._imagecontainer.channels)
        # XXX channel mapping unclear
        # processing channel <--> color channel
        # i.e problems if 2 processing channels have the same color
        if nchannels == 2:
            settings.set('General', 'process_secondary', True)
        elif nchannels >= 3:
            settings.set('General', 'process_secondary', True)
            settings.set('General', 'process_tertiary', True)

        settings.set('General', 'rendering', {})
        analyzer = AnalyzerBrowser(self.coordinate.plate, settings,
                                   self._imagecontainer)

        res = None
        try:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            res = analyzer.processPositions()
            self.render_browser(res)
        except Exception, e:
            import traceback
            from cecog.gui.util import exception
            traceback.print_exc()
            exception(self, str(e))
            raise
示例#36
0
文件: browser.py 项目: jni/cecog
    def _process_image(self, ):
        self.image_viewer.remove_objects()
        settings = BaseProcessorFrame.get_special_settings(self._settings)
        settings.set_section('General')
        settings.set2('constrain_positions', True)
        settings.set2('positions', self.coordinate.position)
        settings.set2('redofailedonly', False)
        settings.set2('framerange', True)
        settings.set2('framerange_begin', self.coordinate.time)
        settings.set2('framerange_end', self.coordinate.time)

        settings.set_section('Processing')
        _classify_objects = self._show_objects_by == 'classification'

        settings.set2('primary_classification', _classify_objects )
        settings.set2('secondary_classification', _classify_objects)
        settings.set2('tertiary_classification', _classify_objects)
        settings.set2('merged_classification', _classify_objects)
        settings.set2('primary_featureextraction', _classify_objects)
        settings.set2('secondary_featureextraction', _classify_objects)

        settings.set2('objectdetection', self._detect_objects)
        settings.set2('tracking', False)
        settings.set_section('Output')
        settings.set2('rendering_contours_discwrite', False)
        settings.set2('rendering_class_discwrite', False)
        settings.set2('export_object_counts', False)
        settings.set2('export_object_details', False)
        settings.set2('export_track_data', False)
        settings.set2('hdf5_create_file', False)
        settings.set_section('Classification')
        settings.set2('collectsamples', False)
        settings.set('General', 'rendering', {})
        settings.set('General', 'rendering_class', {})
        settings.set('Output', 'events_export_gallery_images', False)

        # turn of output:
        settings.set('Output', 'export_object_counts', False)
        settings.set('Output', 'export_object_details', False)
        settings.set('Output', 'export_file_names', False)
        settings.set('Output', 'events_export_gallery_images', False)
        settings.set('Output', 'export_track_data', False)
        settings.set('Output', 'export_tracking_as_dot', False)

        nchannels = len(self._imagecontainer.channels)
        # XXX channel mapping unclear
        # processing channel <--> color channel
        # i.e problems if 2 processing channels have the same color
        if nchannels == 2:
            settings.set('General', 'process_secondary', True)
        elif nchannels >= 3:
            settings.set('General', 'process_secondary', True)
            settings.set('General', 'process_tertiary', True)

        settings.set('General', 'rendering', {})
        analyzer = AnalyzerBrowser(self.coordinate.plate,
                                   settings,
                                   self._imagecontainer)

        res = None
        try:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            res = analyzer.processPositions()
            self.render_browser(res)
        except Exception, e:
            import traceback
            from cecog.gui.util import exception
            traceback.print_exc()
            exception(self, str(e))
            raise