Example #1
0
    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('skip_finished', 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('Output', 'hdf5_create_file', False)
        settings.set('General', 'rendering', {})
        settings.set('General', 'rendering_class', {})

        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()
            self.render_browser(res)
        except Exception, e:
            import traceback
            traceback.print_exc()
            QMessageBox.critical(self, "Error", str(e))
            raise
Example #2
0
    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('skip_finished', 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('Output', 'hdf5_create_file', False)
        settings.set('General', 'rendering', {})
        settings.set('General', 'rendering_class', {})

        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()
            self.render_browser(res)
        except Exception, e:
            import traceback
            traceback.print_exc()
            QMessageBox.critical(self, "Error", str(e))
            raise
Example #3
0
    def get_export_settings(self, settings, has_timelapse=True):
        settings = BaseProcessorFrame.get_special_settings(
            settings, has_timelapse)
        settings.set('General', 'version', version)

        settings.set('General', 'rendering', {})
        settings.set('General', 'rendering_class', {})

        # set properties of merged channel to the same as for Primary
        for prefix in CH_PRIMARY + CH_OTHER:
            if prefix == CH_PRIMARY[0] \
                    or settings.get('General', 'process_%s' %prefix):

                d = {}  # render settings for contours
                for x in self.plugin_mgr.region_info.names[prefix]:
                    d = {
                        '%s_contours_%s' % (prefix, x): {
                            prefix.capitalize(): {
                                'raw': ('#FFFFFF', 1.0),
                                'contours':
                                [(x, self.plugin_mgr.region_info.colors[x], 1,
                                  False)]
                            }
                        }
                    }
                settings.get('General', 'rendering').update(d)

            # render settings for classifications
            d = {}
            if  (settings.get('General', 'process_%s' %prefix) and \
                 settings.get('Processing', '%s_classification' % prefix)):
                for x in self.plugin_mgr.region_info.names[prefix]:
                    if x == settings.get('Classification', '%s_classification_regionname' % prefix) or \
                            prefix == CH_VIRTUAL[0]:
                        d = {
                            '%s_classification_%s' % (prefix, x): {
                                prefix.capitalize(): {
                                    'raw': ('#FFFFFF', 1.0),
                                    'contours': [(x, 'class_label', 1, False),
                                                 (x, '#000000', 1, False)]
                                }
                            }
                        }
                if settings('EventSelection', 'supervised_event_selection'):
                    settings.get('General', 'rendering_class').update(d)

        # setup rendering properties for merged channel
        # want the same rendering properties as for the primary channel!
        if settings.get('General', 'process_merged'):

            # color are defined for regions (not for channels)
            # therefore, we first retrieve the regions for the primary channel
            # and (in the case there are some) we assign the color of the first
            # ROI of the primary channel to the merged contour.
            regions_primary = self.plugin_mgr.region_info.names[CH_PRIMARY[0]]
            if len(regions_primary) == 0:
                default_color = '#FF00FF'
            else:
                default_color = self.plugin_mgr.region_info.colors[
                    regions_primary[0]]

            regions = self._merged_regions(settings)
            d = {
                'merged_contours_%s' % str(regions): {
                    "Merged": {
                        'raw': ('#FFFFFF', 1.0),
                        'contours': [(regions, default_color, 1, False)]
                    }
                }
            }
            settings.get("General", "rendering").update(d)
            if settings.get('Processing', 'merged_classification'):
                d = {
                    'merged_classification_%s' % str(regions): {
                        "Merged": {
                            'raw': ('#FFFFFF', 1.0),
                            'contours': [(regions, 'class_label', 1, False),
                                         (regions, '#000000', 1, False)]
                        }
                    }
                }
                settings.get("General", "rendering_class").update(d)

        return settings
Example #4
0
    def get_export_settings(self, settings, has_timelapse=True):
        settings = BaseProcessorFrame.get_special_settings(settings, has_timelapse)
        settings.set('General', 'version', version)

        settings.set('General', 'rendering', {})
        settings.set('General', 'rendering_class', {})

        show_ids = settings.get('Output', 'rendering_contours_showids')
        show_ids_class = settings.get('Output', 'rendering_class_showids')

        # set properties of merged channel to the same as for Primary
        for prefix in CH_PRIMARY+CH_OTHER:
            if prefix == CH_PRIMARY[0] \
                    or settings.get('General', 'process_%s' %prefix):

                d = {} # render settings for contours
                for x in self.plugin_mgr.region_info.names[prefix]:
                    d = {'%s_contours_%s' % (prefix, x):
                             {prefix.capitalize(): {'raw': ('#FFFFFF', 1.0),
                                                    'contours': [(x, self.plugin_mgr.region_info.colors[x], 1, show_ids)]
                                                    }
                              }
                         }
                settings.get('General', 'rendering').update(d)

            # render settings for classifications
            d = {}
            if  (settings.get('General', 'process_%s' %prefix) and \
                 settings.get('Processing', '%s_classification' % prefix)):
                for x in self.plugin_mgr.region_info.names[prefix]:
                    if x == settings.get('Classification', '%s_classification_regionname' % prefix) or \
                            prefix == CH_VIRTUAL[0]:
                        d = {'%s_classification_%s' % (prefix, x):
                                 {prefix.capitalize(): {'raw': ('#FFFFFF', 1.0),
                                                        'contours': [(x, 'class_label', 1, False),
                                                                     (x, '#000000' , 1, show_ids_class)]
                                                        }
                                  }
                             }
                if settings('EventSelection', 'supervised_event_selection'):
                    settings.get('General', 'rendering_class').update(d)

        # setup rendering properties for merged channel
        # want the same rendering properties as for the primary channel!
        if settings.get('General', 'process_merged'):

            # color are defined for regions (not for channels)
            # therefore, we first retrieve the regions for the primary channel
            # and (in the case there are some) we assign the color of the first
            # ROI of the primary channel to the merged contour.
            regions_primary = self.plugin_mgr.region_info.names[CH_PRIMARY[0]]
            if len(regions_primary) == 0:
                default_color = '#FF00FF'
            else:
                default_color = self.plugin_mgr.region_info.colors[regions_primary[0]]

            regions = self._merged_regions(settings)
            d = {'merged_contours_%s' %str(regions):
                     {"Merged": {'raw': ('#FFFFFF', 1.0),
                                 'contours': [(regions, default_color, 1, show_ids)]}}}
            settings.get("General", "rendering").update(d)
            if settings.get('Processing', 'merged_classification'):
                d = {'merged_classification_%s' %str(regions):
                         {"Merged": {'raw': ('#FFFFFF', 1.0),
                                     'contours': [(regions, 'class_label', 1, False),
                                                  (regions, '#000000' , 1, show_ids_class)]}}}
                settings.get("General", "rendering_class").update(d)

        if has_timelapse:
            # generate raw images of selected channels (later used for gallery images)
            if settings.get('Output', 'events_export_gallery_images'):
                for prefix in CHANNEL_PREFIX:
                    if prefix == 'primary' or settings.get('General', 'process_%s' % prefix):
                        settings.get('General', 'rendering').update({prefix : {prefix.capitalize() :
                                                                                   {'raw': ('#FFFFFF', 1.0)}}})
        return settings
Example #5
0
    def get_export_settings(cls, settings, has_timelapse=True):
        settings = BaseProcessorFrame.get_special_settings(
            settings, has_timelapse)

        settings.set('General', 'version', VERSION)
        settings.set('General', 'rendering', {})
        settings.set('General', 'rendering_class', {})

        show_ids = settings.get('Output', 'rendering_contours_showids')
        show_ids_class = settings.get('Output', 'rendering_class_showids')

        # set propertys of merged channel to the same as for Primary
        # unfortunately REGION_INFO is like a global variable

        d = {}
        for prefix in CH_PRIMARY + CH_OTHER:
            if prefix == CH_PRIMARY[0] \
                    or settings.get('Processing', '%s_processchannel' % prefix):
                for x in reginfo.names[prefix]:
                    d = {
                        '%s_contours_%s' % (prefix, x): {
                            prefix.capitalize(): {
                                'raw': ('#FFFFFF', 1.0),
                                'contours':
                                [(x, reginfo.colors[x], 1, show_ids)]
                            }
                        }
                    }

                settings.get('General', 'rendering').update(d)
                if settings.get('Processing', '%s_classification' % prefix):
                    for x in reginfo.names[prefix]:
                        if x == settings.get('Classification', '%s_classification_regionname' % prefix) or \
                                prefix == CH_VIRTUAL[0]:
                            d = {
                                '%s_classification_%s' % (prefix, x): {
                                    prefix.capitalize(): {
                                        'raw': ('#FFFFFF', 1.0),
                                        'contours':
                                        [(x, 'class_label', 1, False),
                                         (x, '#000000', 1, show_ids_class)]
                                    }
                                }
                            }
                    settings.get('General', 'rendering_class').update(d)

        # setup rendering properties for merged channel
        # want the same rendering properties as for the primary channel!
        if settings.get('Processing', 'merged_processchannel'):
            regions = cls._merged_regions(settings)
            d = {
                'merged_contours_%s' % '-'.join(regions): {
                    "Merged": {
                        'raw': ('#FFFFFF', 1.0),
                        'contours':
                        [(regions, reginfo.colors["primary"], 1, show_ids)]
                    }
                }
            }
            settings.get("General", "rendering").update(d)
            if settings.get('Processing', 'merged_classification'):
                d = {
                    'merged_classification_%s' % '-'.join(regions): {
                        "Merged": {
                            'raw': ('#FFFFFF', 1.0),
                            'contours':
                            [(regions, 'class_label', 1, False),
                             (regions, '#000000', 1, show_ids_class)]
                        }
                    }
                }
                settings.get("General", "rendering_class").update(d)

        if has_timelapse:
            # generate raw images of selected channels (later used for gallery images)
            if settings.get('Output', 'events_export_gallery_images'):
                for prefix in CHANNEL_PREFIX:
                    if prefix == 'primary' or settings.get(
                            'Processing', '%s_processchannel' % prefix):
                        settings.get('General', 'rendering').update({
                            prefix: {
                                prefix.capitalize(): {
                                    'raw': ('#FFFFFF', 1.0)
                                }
                            }
                        })
        return settings
Example #6
0
File: browser.py Project: 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
Example #7
0
    def get_export_settings(cls, settings, has_timelapse=True):
        settings = BaseProcessorFrame.get_special_settings(settings, has_timelapse)

        settings.set('General', 'version', VERSION)
        settings.set('General', 'rendering', {})
        settings.set('General', 'rendering_class', {})

        show_ids = settings.get('Output', 'rendering_contours_showids')
        show_ids_class = settings.get('Output', 'rendering_class_showids')

        # set propertys of merged channel to the same as for Primary
        # unfortunately REGION_INFO is like a global variable

        d = {}
        for prefix in CH_PRIMARY+CH_OTHER:
            if prefix == CH_PRIMARY[0] \
                    or settings.get('Processing', '%s_processchannel' % prefix):
                for x in reginfo.names[prefix]:
                    d = {'%s_contours_%s' % (prefix, x):
                             {prefix.capitalize(): {'raw': ('#FFFFFF', 1.0),
                                                    'contours': [(x, reginfo.colors[x], 1, show_ids)]
                                                    }
                              }
                         }

                settings.get('General', 'rendering').update(d)
                if settings.get('Processing', '%s_classification' % prefix):
                    for x in reginfo.names[prefix]:
                        if x == settings.get('Classification', '%s_classification_regionname' % prefix) or \
                                prefix == CH_VIRTUAL[0]:
                            d = {'%s_classification_%s' % (prefix, x):
                                     {prefix.capitalize(): {'raw': ('#FFFFFF', 1.0),
                                                            'contours': [(x, 'class_label', 1, False),
                                                                         (x, '#000000' , 1, show_ids_class)]
                                                            }
                                      }
                                 }
                    settings.get('General', 'rendering_class').update(d)

        # setup rendering properties for merged channel
        # want the same rendering properties as for the primary channel!
        if settings.get('Processing', 'merged_processchannel'):
            regions = cls._merged_regions(settings)
            d = {'merged_contours_%s' %'-'.join(regions):
                     {"Merged": {'raw': ('#FFFFFF', 1.0),
                                 'contours': [(regions, reginfo.colors["primary"], 1, show_ids)]}}}
            settings.get("General", "rendering").update(d)
            if settings.get('Processing', 'merged_classification'):
                d = {'merged_classification_%s' %'-'.join(regions):
                         {"Merged": {'raw': ('#FFFFFF', 1.0),
                                     'contours': [(regions, 'class_label', 1, False),
                                                  (regions, '#000000' , 1, show_ids_class)]}}}
                settings.get("General", "rendering_class").update(d)

        if has_timelapse:
            # generate raw images of selected channels (later used for gallery images)
            if settings.get('Output', 'events_export_gallery_images'):
                for prefix in CHANNEL_PREFIX:
                    if prefix == 'primary' or settings.get('Processing', '%s_processchannel' % prefix):
                        settings.get('General', 'rendering').update({prefix : {prefix.capitalize() :
                                                                                   {'raw': ('#FFFFFF', 1.0)}}})
        return settings
Example #8
0
    def get_export_settings(cls, settings, has_timelapse=True):
        settings = BaseProcessorFrame.get_special_settings(settings, has_timelapse)

        settings.set('General', 'rendering', {})
        settings.set('General', 'rendering_class', {})

        additional_prefixes = [SecondaryChannel.PREFIX, TertiaryChannel.PREFIX]

        settings.set_section('Classification')
        sec_class_regions = dict([(prefix,
                                  settings.get2('%s_classification_regionname' % prefix))
                                  for prefix in additional_prefixes])

        settings.set_section('ObjectDetection')
        prim_id = PrimaryChannel.NAME
        sec_ids = dict([(x.PREFIX, x.NAME) for x in [SecondaryChannel, TertiaryChannel]])
        sec_regions = dict([(prefix, [v for k,v in regions.iteritems() if settings.get2(k)])
                            for prefix, regions in [(SecondaryChannel.PREFIX, SECONDARY_REGIONS),
                                                    (TertiaryChannel.PREFIX, TERTIARY_REGIONS),
                                                    ]
                            ])


        show_ids = settings.get('Output', 'rendering_contours_showids')
        show_ids_class = settings.get('Output', 'rendering_class_showids')

        settings.get('General', 'rendering').update({'primary_contours': {prim_id: {'raw': ('#FFFFFF', 1.0),
                                                                                    'contours': {'primary': ('#FF0000', 1, show_ids)}}}})

        settings.set_section('Processing')
        if settings.get2('primary_classification'):
            settings.get('General', 'rendering_class').update({'primary_classification': {prim_id: {'raw': ('#FFFFFF', 1.0),
                                                                                          'contours': [('primary', 'class_label', 1, False),
                                                                                                       ('primary', '#000000', 1, show_ids_class),
                                                                                                       ]}}})

        for prefix in additional_prefixes:
            if settings.get2('%s_processchannel' % prefix):
                sec_id = sec_ids[prefix]
                settings.get('General', 'rendering').update(dict([('%s_contours_%s' % (prefix, x), {sec_id: {'raw': ('#FFFFFF', 1.0),
                                                                                                             'contours': [(x, SECONDARY_COLORS[x] , 1, show_ids)]
                                                                                                 }})
                                                                  for x in sec_regions[prefix]]))

                if settings.get2('%s_classification' % prefix):
                    sec_id = sec_ids[prefix]
                    sec_region = sec_class_regions[prefix]
                    settings.get('General', 'rendering_class').update({'%s_classification_%s' % (prefix, sec_region):
                                                                       {sec_id: {'raw': ('#FFFFFF', 1.0),
                                                                                 'contours': [(sec_region, 'class_label', 1, False),
                                                                                              (sec_region, '#000000', 1, show_ids_class),
                                                                                              ]}}})
        if has_timelapse:
            # generate raw images of selected channels (later used for gallery images)
            if settings.get('Output', 'events_export_gallery_images'):
                settings.get('General', 'rendering').update({'primary' : {prim_id : {'raw': ('#FFFFFF', 1.0)}}})
                for prefix in additional_prefixes:
                    if settings.get2('%s_processchannel' % prefix):
                        sec_id = sec_ids[prefix]
                        settings.get('General', 'rendering').update({prefix : {sec_id : {'raw': ('#FFFFFF', 1.0)}}})

        return settings
Example #9
0
    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