Exemplo n.º 1
0
    def __init__(self, feature_names, gallery_dtype, colors, size):

        self.gallery = None
        self.bbox = None
        self.features = None
        self.images = None
        self.contours = defaultdict(list)
        self.colors = colors
        self.image_size = size
        self._images = list()
        self._treatment = list()

        self.feature_names = feature_names
        self._dt_gallery = gallery_dtype
        self._dt_bbox = [('treatment', "S128"), ('label', np.uint32),
                         ('x', np.uint16), ('y', np.uint16), ('top', np.uint16),
                         ('bottom', np.uint16), ('left', np.uint16),
                         ('right', np.uint16)]

        self._dt_features = [(str(n), np.float32) for n in feature_names]
        self._dt_contours = h5py.special_dtype(vlen=np.uint16)
        self._dt_groups = [('feature', "S64")] + \
            [(str(g), "S64") for g in FeatureGroups.keys()]

        # setup the table of feature groups
        self.fgroups = np.empty((len(feature_names), ), dtype=self._dt_groups)
        for i, fname in enumerate(feature_names):
            line = [fname]

            for v in FeatureGroups.values():
                fname2 = cn.splitFeatureName(fname)[1]
                line.append(v.inverse[fname2])
            line = tuple([str(l) for l in line])

            self.fgroups[i] = np.array(line, dtype=self._dt_groups)
Exemplo n.º 2
0
    def __init__(self, feature_names, gallery_dtype, colors, size):

        self.gallery = None
        self.bbox = None
        self.features = None
        self.images = None
        self.contours = defaultdict(list)
        self.colors = colors
        self.image_size = size
        self._images = list()
        self._treatment = list()

        self.feature_names = feature_names
        self._dt_gallery = gallery_dtype
        self._dt_bbox = [('file', 'S128'),
                         ('treatment', "S128"), ('label', np.uint32),
                         ('x', np.uint16), ('y', np.uint16), ('top', np.uint16),
                         ('bottom', np.uint16), ('left', np.uint16),
                         ('right', np.uint16),
                         ('angle', np.float32), ('eccentricity', np.float32)]

        self._dt_features = [(str(n), np.float32) for n in feature_names]
        self._dt_contours = h5py.special_dtype(vlen=np.uint16)
        self._dt_groups = [('feature', "S64")] + \
            [(str(g), "S64") for g in FeatureGroups.keys()]

        # setup the table of feature groups
        self.fgroups = np.empty((len(feature_names), ), dtype=self._dt_groups)
        for i, fname in enumerate(feature_names):
            line = [fname]

            for v in FeatureGroups.values():
                fname2 = cn.splitFeatureName(fname)[1]
                line.append(v.inverse[fname2])
            line = tuple([str(l) for l in line])

            self.fgroups[i] = np.array(line, dtype=self._dt_groups)
Exemplo n.º 3
0
    def featureGroups(self, region=None):
        """Return the feature groups as nested dictionaries.
        e.g. {channel: {meta_group: { group: (feature_list)}}}"""
        fg = self[self.dmodel.feature_groups]

        ftrs = fg.dtype.names[0]
        groups = fg.dtype.names[1:]

        channels = self.channelNames
        ch_groups = OrderedDict()

        for channel in channels:
            meta_group = OrderedDict()
            for group in groups:
                fgroup = FGroup(group, [(g, []) for g in np.unique(fg[group])])
                meta_group[group] = fgroup
            ch_groups[channel] = meta_group

        for line in fg:
            channel, fname = cn.splitFeatureName(line[0])
            channel = cn.validFromShort(channel)
            for i, group in enumerate(groups):
                ch_groups[channel][group][line[i+1]].append(fname)
        return ch_groups
Exemplo n.º 4
0
    def featureGroups(self, region=None):
        """Return the feature groups as nested dictionaries.
        e.g. {channel: {meta_group: { group: (feature_list)}}}"""
        fg = self[self.dmodel.feature_groups]

        ftrs = fg.dtype.names[0]
        groups = fg.dtype.names[1:]

        channels = self.channelNames
        ch_groups = OrderedDict()

        for channel in channels:
            meta_group = OrderedDict()
            for group in groups:
                fgroup = FGroup(group, [(g, []) for g in np.unique(fg[group])])
                meta_group[group] = fgroup
            ch_groups[channel] = meta_group

        for line in fg:
            channel, fname = cn.splitFeatureName(line[0])
            channel = cn.validFromShort(channel)
            for i, group in enumerate(groups):
                ch_groups[channel][group][line[i + 1]].append(fname)
        return ch_groups