Esempio n. 1
0
    def __init__(
            self,
            strChannelId,
            # either number of zsclice or projection type
            oZSliceOrProjection=1,
            channelRegistration=None,
            registration_start=None,
            new_image_size=None,
            strImageOutCompression="80",
            strPathOutDebug=None,
            lstFeatureCategories=None,
            dctFeatureParameters=None,
            lstFeatureNames=None,
            bFlatfieldCorrection=False,
            strBackgroundImagePath="",
            fBackgroundCorrection="",
            fNormalizeMin="",
            fNormalizeMax="",
            fNormalizeRatio="",
            fNormalizeOffset="",
            check_for_plugins=True):
        super(ChannelCore, self).__init__()

        # remove all the hungarian bullshit as soon as possible!
        self.strChannelId = strChannelId
        # either number of zsclice or projection type
        self.oZSliceOrProjection = oZSliceOrProjection
        self.channelRegistration = channelRegistration
        self.registration_start = registration_start
        self.new_image_size = new_image_size
        self.strImageOutCompression = strImageOutCompression
        self.strPathOutDebug = strPathOutDebug
        self.lstFeatureCategories = lstFeatureCategories
        self.dctFeatureParameters = dctFeatureParameters
        self.lstFeatureNames = lstFeatureNames
        self.bFlatfieldCorrection = bFlatfieldCorrection
        self.strBackgroundImagePath = strBackgroundImagePath
        self.fBackgroundCorrection = fBackgroundCorrection
        self.fNormalizeMin = fNormalizeMin
        self.fNormalizeMax = fNormalizeMax
        self.fNormalizeRatio = fNormalizeRatio
        self.fNormalizeOffset = fNormalizeOffset

        self._zslices = []
        self.containers = {}
        self._regions = {}
        self.meta_image = None
        self._features_calculated = False

        try:
            self.plugin_mgr = MetaPluginManager()[self.NAME.lower()]
            if self.plugin_mgr.number_loaded_plugins() < 1:
                if check_for_plugins:
                    raise RuntimeError(
                        ("You need to load at least one segmentation"
                         " plugin for channel '%s'" % self.NAME))
        except KeyError:
            self.plugin_mgr = None
Esempio n. 2
0
    def readfp(self, fp):

        for plugin_manager in MetaPluginManager():
            plugin_manager.clear()
        for section in self.sections():
            self.remove_section(section)

        result = RawConfigParser.readfp(self, fp)
        self._old_file_format = False
        if not self.has_option('General', 'version') or \
                self.get('General', 'version') < version:
            self._old_file_format = True

        for section_name in self.sections():
            if section_name in self._section_registry.section_names():
                section = self._section_registry.get_section(section_name)
                for option_name in self.options(section_name):
                    if option_name in section.get_trait_names():
                        # convert values according to traits
                        value = self.get_value(section_name, option_name)
                        self.set(section_name, option_name, value)

                    elif option_name.startswith('plugin'):
                        # plugins are okay, because they do not
                        # obey the old trait concept
                        pass
                    else:
                        try:
                            self._update_option_to_version(
                                section_name, option_name)
                        except NoOptionError as e:
                            pass
                        print("Warning: option '%s' in section '%s' is not "
                              "defined and will be deleted" %\
                                  (option_name, section_name))
                        self.remove_option(section_name, option_name)
            else:
                print(
                    "Warning: section '%s' is not defined and will be "
                    "deleted" % section_name)
                self.remove_section(section_name)

        self._merge_registry()

        for plugin_manager in MetaPluginManager():
            plugin_manager.init_from_settings(self)

        return result
Esempio n. 3
0
    def merge_regions(self, regions):
        """Set channels and regions to concatenate."""

        reginfo = MetaPluginManager().region_info
        reginfo.names[self.NAME.lower()] = [regions.values()]

        self._merge_regions.update(regions)
Esempio n. 4
0
    def __init__(self, settings, parent, name):
        super(BaseFrame, self).__init__(settings, parent, name)
        self.plugin_mgr = MetaPluginManager()
        self.name = name
        self._is_active = False
        self._intervals = list()

        self._tab_name = None
        self.process_control = ProcessControl(self)
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        self._tab = TabControl(self)

        tabs = [self._tab_name] if self.TABS is None else self.TABS
        for name in tabs:
            frame = QFrame(self._tab)
            frame._input_cnt = 0
            layout2 = QGridLayout(frame)
            layout2.setContentsMargins(20, 20, 20, 20)
            self._tab.add_tab(name, frame)

        self._tab.set_active_index(0)
        self._tab.currentChanged.connect(self.on_tab_changed)

        layout.addWidget(self._tab)
        layout.addWidget(self.process_control)
Esempio n. 5
0
    def define_exp_features(self):
        features = {}
        for name in self.processing_channels:
            region_features = {}

            for region in MetaPluginManager().region_info.names[name.lower()]:
                if name is self.MERGED_CHANNEL:
                    continue
                # export all features extracted per regions
                if self.settings.get('Output', 'events_export_all_features') or \
                        self.settings.get('Output', 'export_track_data'):
                    # None means all features
                    region_features[region] = None
                # export selected features from settings
                else:
                    region_features[region] = \
                        self.settings.get('General',
                                          '%s_featureextraction_exportfeaturenames'
                                          % name.lower())

                features[name] = region_features

            # special case for merged channel
            if name is self.MERGED_CHANNEL:
                mftrs = list()
                for channel, region in self._channel_regions(name).iteritems():
                    if features[channel][region] is None:
                        mftrs = None
                    else:
                        for feature in features[channel][region]:
                            mftrs.append("_".join((channel, region, feature)))
                region_features[self._all_channel_regions[name].values()] = mftrs
                features[name] = region_features

        return features
Esempio n. 6
0
    def __init__(self,
                 strChannelId,
                 # either number of zsclice or projection type
                 oZSliceOrProjection=1,
                 channelRegistration=None,
                 registration_start=None,
                 new_image_size=None,
                 strImageOutCompression="80",
                 strPathOutDebug=None,
                 lstFeatureCategories=None,
                 dctFeatureParameters=None,
                 lstFeatureNames=None,
                 bFlatfieldCorrection=False,
                 strBackgroundImagePath="",
                 fBackgroundCorrection="",
                 fNormalizeMin="",
                 fNormalizeMax="",
                 fNormalizeRatio="",
                 fNormalizeOffset="",
                 check_for_plugins=True):
        super(ChannelCore, self).__init__()

        # remove all the hungarian bullshit as soon as possible!
        self.strChannelId = strChannelId
        # either number of zsclice or projection type
        self.oZSliceOrProjection = oZSliceOrProjection
        self.channelRegistration = channelRegistration
        self.registration_start = registration_start
        self.new_image_size = new_image_size
        self.strImageOutCompression = strImageOutCompression
        self.strPathOutDebug = strPathOutDebug
        self.lstFeatureCategories = lstFeatureCategories
        self.dctFeatureParameters = dctFeatureParameters
        self.lstFeatureNames = lstFeatureNames
        self.bFlatfieldCorrection = bFlatfieldCorrection
        self.strBackgroundImagePath = strBackgroundImagePath
        self.fBackgroundCorrection = fBackgroundCorrection
        self.fNormalizeMin = fNormalizeMin
        self.fNormalizeMax = fNormalizeMax
        self.fNormalizeRatio = fNormalizeRatio
        self.fNormalizeOffset = fNormalizeOffset

        self._zslices = []
        self.containers = {}
        self._regions = {}
        self.meta_image = None
        self._features_calculated = False

        try:
            self.plugin_mgr = MetaPluginManager()[self.NAME.lower()]
            if self.plugin_mgr.number_loaded_plugins() < 1:
                if check_for_plugins:
                    raise RuntimeError(
                        ("You need to load at least one segmentation"
                         " plugin for channel '%s'" %self.NAME))
        except KeyError:
            self.plugin_mgr = None
Esempio n. 7
0
    def _region_names(self):

        rdict = OrderedDict()
        reginfo = MetaPluginManager().region_info
        for channel, regions in reginfo.names.iteritems():
            for region in regions:
                rdict['%s - %s' % (channel.capitalize(), region)] = \
                    (channel.capitalize(), region)
        return rdict
Esempio n. 8
0
    def from_dict(self, settings):
        for section, group in settings.iteritems():
            for option, value in group.iteritems():
                RawConfigParser.set(self, section, option, value)

        # # update the plugins
        for plugin_manager in MetaPluginManager():
            plugin_manager.clear()
            plugin_manager.init_from_settings(self)
Esempio n. 9
0
class ChannelCore(LoggerObject):

    NAME = None
    _rank = None
    _is_virtual = False

    def __init__(self,
                 strChannelId,
                 # either number of zsclice or projection type
                 oZSliceOrProjection=1,
                 channelRegistration=None,
                 registration_start=None,
                 new_image_size=None,
                 strImageOutCompression="80",
                 strPathOutDebug=None,
                 lstFeatureCategories=None,
                 dctFeatureParameters=None,
                 lstFeatureNames=None,
                 bFlatfieldCorrection=False,
                 strBackgroundImagePath="",
                 fBackgroundCorrection="",
                 fNormalizeMin="",
                 fNormalizeMax="",
                 fNormalizeRatio="",
                 fNormalizeOffset="",
                 check_for_plugins=True):
        super(ChannelCore, self).__init__()

        # remove all the hungarian bullshit as soon as possible!
        self.strChannelId = strChannelId
        # either number of zsclice or projection type
        self.oZSliceOrProjection = oZSliceOrProjection
        self.channelRegistration = channelRegistration
        self.registration_start = registration_start
        self.new_image_size = new_image_size
        self.strImageOutCompression = strImageOutCompression
        self.strPathOutDebug = strPathOutDebug
        self.lstFeatureCategories = lstFeatureCategories
        self.dctFeatureParameters = dctFeatureParameters
        self.lstFeatureNames = lstFeatureNames
        self.bFlatfieldCorrection = bFlatfieldCorrection
        self.strBackgroundImagePath = strBackgroundImagePath
        self.fBackgroundCorrection = fBackgroundCorrection
        self.fNormalizeMin = fNormalizeMin
        self.fNormalizeMax = fNormalizeMax
        self.fNormalizeRatio = fNormalizeRatio
        self.fNormalizeOffset = fNormalizeOffset

        self._zslices = []
        self.containers = {}
        self._regions = {}
        self.meta_image = None
        self._features_calculated = False

        try:
            self.plugin_mgr = MetaPluginManager()[self.NAME.lower()]
            if self.plugin_mgr.number_loaded_plugins() < 1:
                if check_for_plugins:
                    raise RuntimeError(
                        ("You need to load at least one segmentation"
                         " plugin for channel '%s'" %self.NAME))
        except KeyError:
            self.plugin_mgr = None

    def __cmp__(self, channel):
        return cmp(self._rank, channel._rank)

    @classmethod
    def is_virtual(cls):
        return cls._is_virtual

    def region_names(self):
        return self._regions.keys()

    def get_region(self, name):
        return self._regions[name]

    def has_region(self, name):
        return self._regions.has_key(name)

    def get_container(self, name):
        return self.containers[name]

    def append_zslice(self, meta_image):
        self._zslices.append(meta_image)

    def clear(self):
        self._zslices = []
        self._regions = {}
        self.meta_image = None
        self.containers = {}
Esempio n. 10
0
class ChannelCore(LoggerObject):

    NAME = None
    _rank = None
    _is_virtual = False

    def __init__(
            self,
            strChannelId,
            # either number of zsclice or projection type
            oZSliceOrProjection=1,
            channelRegistration=None,
            registration_start=None,
            new_image_size=None,
            strImageOutCompression="80",
            strPathOutDebug=None,
            feature_groups=None,
            lstFeatureNames=None,
            bFlatfieldCorrection=False,
            strBackgroundImagePath="",
            fBackgroundCorrection="",
            fNormalizeMin="",
            fNormalizeMax="",
            fNormalizeRatio="",
            fNormalizeOffset="",
            check_for_plugins=True):
        super(ChannelCore, self).__init__()

        # remove all the hungarian bullshit as soon as possible!
        self.strChannelId = strChannelId
        # either number of zsclice or projection type
        self.oZSliceOrProjection = oZSliceOrProjection
        self.channelRegistration = channelRegistration
        self.registration_start = registration_start
        self.new_image_size = new_image_size
        self.strImageOutCompression = strImageOutCompression
        self.strPathOutDebug = strPathOutDebug
        self.feature_groups = feature_groups
        self.lstFeatureNames = lstFeatureNames
        self.bFlatfieldCorrection = bFlatfieldCorrection
        self.strBackgroundImagePath = strBackgroundImagePath
        self.fBackgroundCorrection = fBackgroundCorrection
        self.fNormalizeMin = fNormalizeMin
        self.fNormalizeMax = fNormalizeMax
        self.fNormalizeRatio = fNormalizeRatio
        self.fNormalizeOffset = fNormalizeOffset

        self._zslices = []
        self.containers = {}
        self._regions = {}
        self.meta_image = None
        self._features_calculated = False

        try:
            self.plugin_mgr = MetaPluginManager()[self.NAME.lower()]
            if self.plugin_mgr.number_loaded_plugins() < 1:
                if check_for_plugins:
                    raise RuntimeError(
                        ("You need to load at least one segmentation"
                         " plugin for channel '%s'" % self.NAME))
        except KeyError:
            self.plugin_mgr = None

    def __cmp__(self, channel):
        return cmp(self._rank, channel._rank)

    @classmethod
    def is_virtual(cls):
        return cls._is_virtual

    def region_names(self):
        return self._regions.keys()

    def get_region(self, name):
        return self._regions[name]

    def has_region(self, name):
        return self._regions.has_key(name)

    def get_container(self, name):
        return self.containers[name]

    def append_zslice(self, meta_image):
        self._zslices.append(meta_image)

    def clear(self):
        self._zslices = []
        self._regions = {}
        self.meta_image = None
        self.containers = {}